33 lines
1018 B
TypeScript
33 lines
1018 B
TypeScript
import 'reflect-metadata';
|
|
import connectDB from './connectDB.js';
|
|
import express, { type Request, type Response } from "express"
|
|
import session from "express-session";
|
|
import path from 'node:path';
|
|
import { LiteHashDRBG } from './util/LiteHashDRBG.js';
|
|
import { simpleSerialize } from './util/simpleSerialize.js';
|
|
import { buildAPISystem } from './api/generator.js';
|
|
import { unwrap } from './util/unwrap.js';
|
|
import { sammoAPI } from './api/api.js';
|
|
import { ownConfig } from './serverConfig.js';
|
|
|
|
connectDB.then(async (db) => {
|
|
// create express app
|
|
const app = express()
|
|
app.use(express.json());
|
|
app.use(session({
|
|
secret: unwrap(ownConfig.sessionSecret),
|
|
resave: false,
|
|
saveUninitialized: false,
|
|
}))
|
|
//app.set('etag', false);
|
|
|
|
app.use('/api', buildAPISystem(sammoAPI));
|
|
|
|
// start express server
|
|
app.listen(ownConfig.port)
|
|
|
|
console.log(`Express server has started on port ${ownConfig.port}`)
|
|
|
|
}).catch(error => console.log(error));
|
|
|
|
export default {}; |