40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import 'dotenv/config';
|
|
import 'reflect-metadata';
|
|
import { validate } from 'class-validator';
|
|
import express, { type Request, type Response } from "express"
|
|
import { AppDataSource } from "./data_source.js"
|
|
import session from "express-session";
|
|
import path from 'node:path';
|
|
import { LiteHashDRBG } from './util/LiteHashDRBG.js';
|
|
import { simpleSerialize } from './util/simpleSerialize.js';
|
|
import { SammoRootAPI } from './clientAPI/sammoRootAPI.js';
|
|
import { buildAPISystem } from './api/generator.js';
|
|
import { sammoRootAPI } from './api/root.js';
|
|
|
|
const ownConfig = {
|
|
sessionSecret: process.env.SESSION_SECRET,
|
|
port: Number(process.env.SERVER_PORT),
|
|
}
|
|
|
|
|
|
AppDataSource.initialize().then(async () => {
|
|
// create express app
|
|
const app = express()
|
|
app.use(express.json());
|
|
app.use(session({
|
|
secret: ownConfig.sessionSecret,
|
|
resave: false,
|
|
saveUninitialized: false,
|
|
}))
|
|
//app.set('etag', false);
|
|
|
|
app.use('/rootAPI', buildAPISystem(sammoRootAPI));
|
|
|
|
// start express server
|
|
app.listen(ownConfig.port)
|
|
|
|
console.log(`Express server has started on port ${ownConfig.port}`)
|
|
|
|
}).catch(error => console.log(error))
|
|
|
|
export default {}; |