forked from forbole/big-dipper-2.0-cosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
43 lines (37 loc) · 1004 Bytes
/
index.ts
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* eslint-disable no-console */
import express, {
Request, Response,
} from 'express';
import next from 'next';
import cors from 'cors';
import dotenv from 'dotenv';
import helmet from 'helmet';
dotenv.config();
const isDev = process.env.NODE_ENV !== 'production';
const app = next({
dev: isDev,
});
const handle = app.getRequestHandler();
const port = process.env.PORT || 3000;
(async () => {
try {
await app.prepare();
const server = express();
server.use(helmet.hidePoweredBy());
// server.use(helmet());
server.use(cors());
server.all('*', (req: Request, res: Response) => {
return handle(req, res);
});
server.listen(port, (err?: any) => {
if (err) throw err;
console.log('> Blast Off Ready On:');
console.log(`> URL: http://localhost:${port}`);
console.log(`> ENV: ${process.env.NODE_ENV || 'development'}`);
console.log(`> PORT: ${port}`);
});
} catch (e) {
console.error(e);
process.exit(1);
}
})();