-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
34 lines (30 loc) · 944 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
import express, { Express, Request, Response } from 'express';
import bodyParser from 'body-parser';
import { router } from './routes';
import { APP_HOST, APP_HTTP_SCHEMA, APP_PORT, MONGODB_URI, COOKIE_SECRET } from './config';
import mongoose from 'mongoose';
import session from 'cookie-session';
export const app: Express = express();
app.get('/', (req: Request, res: Response) => {
res.send('Go to <a href="/api-docs">/api-docs</a>');
});
app
.use(bodyParser.json())
.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
})
.use(
session({
secret: COOKIE_SECRET,
keys: ['access_token', 'githubId']
})
)
.use('/', router);
mongoose.set('strictQuery', false);
mongoose.connect(MONGODB_URI, {}, () => {
app.listen(APP_PORT, () => {
console.log(`[server]: Server is running at http://localhost:${APP_PORT}`);
console.log('Connected to mongodb');
});
});