-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (34 loc) · 896 Bytes
/
index.js
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
require('./envloader')()
const express = require('express')
const cors = require('cors')
const baseRouter = require('./router')
const compression = require('compression')
const morgan = require('morgan')
const app = express()
const PORT = process.env.PORT || 3000
app.use(cors())
app.use(express.json())
app.use(
morgan(
'REQUEST :response-time ms [:date[clf]] ":method :url HTTP/:http-version" :status :user-agent',
{
immediate: true,
skip: function (req) { return (req.path === '/api/') },
},
),
)
app.use(
express.urlencoded({
extended: true,
limit: '2mb',
parameterLimit: 1e6,
}),
)
app.use(compression())
app.use('/api/', baseRouter)
app.get('/', (req, res) => {
return res.send('GPT server is up and running')
})
app.listen(PORT, () => {
console.log('Server is running at port:',PORT)
})