ecliptica/server/index.js

51 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-08-01 13:14:02 +03:00
const express = require('express')
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const session = require('express-session')
const app = express()
const cors = require('cors')
require('dotenv').config()
2024-10-16 11:06:23 +03:00
exports.app = app
2023-08-01 13:14:02 +03:00
const config = require('../.serverrc')
const { setIo } = require('./io')
app.use(cookieParser())
app.options('*', cors())
app.use(cors())
const server = setIo(app)
const sess = {
secret: 'super-secret-key',
resave: true,
saveUninitialized: true,
cookie: {
},
}
if (app.get('env') === 'production') {
app.set('trust proxy', 1)
sess.cookie.secure = true
}
app.use(session(sess))
app.use(bodyParser.json({
limit: '50mb',
}))
app.use(bodyParser.urlencoded({
limit: '50mb',
extended: true,
}))
app.use(require('./root'))
/**
* Добавляйте сюда свои routers.
*/
2024-10-12 12:06:52 +03:00
app.use('/epja-2024-1', require('./routers/epja-2024-1'))
2024-10-16 11:06:23 +03:00
app.use('/todo', require('./routers/todo/routes'))
2023-08-01 13:14:02 +03:00
app.use(require('./error'))
server.listen(config.port, () => console.log(`Listening on http://localhost:${config.port}`))