-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (23 loc) · 737 Bytes
/
index.js
File metadata and controls
27 lines (23 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require('rootpath')();
const express = require('express');
const cors = require('cors');
const helmet = require('helmet');
const compression = require('compression');
const morgan = require('morgan');
const api = require('@appgeist/restful-api');
const ensureDatabase = require('seed/ensureDatabase');
const [host, port] = ['0.0.0.0', 3000];
(async () => {
await ensureDatabase();
express()
.use(cors())
.use(helmet())
.use(compression())
.use(morgan(process.env.NODE_ENV === 'production' ? 'short' : 'dev'))
.use(api())
.listen(port, host, (err) => {
if (err) throw err;
// eslint-disable-next-line no-console
console.log(`Server listening on http://${host}:${port}...`);
});
})();