forked from MetinKONUK/GPT4TestUserServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (53 loc) · 2 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const express = require('express')
const mongoose = require('mongoose')
const cors = require('cors')
const dotenv = require('dotenv')
const logger = require('./logger')
// Import routes
const userActionsRecap = require('./routes/userActionsRecapRoutes')
const testGenerationHistories = require('./routes/testGenerationHistoriesRoutes')
const editorSettingsRoutes = require('./routes/editorSettingsRoutes')
const modelSettingsRoutes = require('./routes/modelSettingsRoutes')
const executionTerminalSettingsRoutes = require('./routes/executionTerminalSettingsRoutes')
const specialCommandTerminalSettingsRoutes = require('./routes/specialCommandTerminalSettingsRoutes')
const authRoutes = require('./routes/authRoutes')
const comparisonResultsHistories = require('./routes/modelComparisonHistoryRoutes')
dotenv.config()
const { SERVER_PORT, CLIENT_URL, DATABASE_URI } = process.env
mongoose.set('strictQuery', false)
mongoose.connect(DATABASE_URI)
const db = mongoose.connection
const server = express()
server.use(express.json())
server.use(
cors({
origin: '*',
credentials: true,
optionSuccessStatus: 200,
})
)
// Use routes
server.use('/api/users/userActionsRecap', userActionsRecap)
server.use('/api/users/testGenerationHistories', testGenerationHistories)
server.use('/api/users/editorSettings', editorSettingsRoutes)
server.use('/api/users/modelSettings', modelSettingsRoutes)
server.use(
'/api/users/executionTerminalSettings',
executionTerminalSettingsRoutes
)
server.use(
'/api/users/specialCommandTerminalSettings',
specialCommandTerminalSettingsRoutes
)
server.use('/api/auth', authRoutes)
server.use('/api/users/comparisonResults', comparisonResultsHistories)
db.on('error', error => {
logger.error(`DB connection error, message: ${error.message}`)
})
db.once('open', () => {
logger.info(`connected to DB: ${DATABASE_URI}`)
})
server.listen(SERVER_PORT, () => {
console.log(`server started, PORT=${SERVER_PORT}`)
logger.info(`server started, PORT=${SERVER_PORT}`)
})