37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import 'reflect-metadata';
|
|
import gatewayDB from './connectGatewayDB.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 { SammoGatewayAPI } from './clientAPI/sammoGatewayAPI.js';
|
|
import { buildAPISystem } from './api/generator.js';
|
|
import { sammoGatewayAPI } from './api/gatewayAPI.js';
|
|
import { unwrap } from './util/unwrap.js';
|
|
import { gatewayConfig } from './gatewayConfig.js';
|
|
|
|
|
|
|
|
|
|
gatewayDB.then(async (gatewayDB) => {
|
|
// create express app
|
|
const app = express()
|
|
app.use(express.json());
|
|
app.use(session({
|
|
secret: unwrap(gatewayConfig.sessionSecret),
|
|
resave: false,
|
|
saveUninitialized: false,
|
|
}))
|
|
//app.set('etag', false);
|
|
|
|
app.use('/gateway_api', buildAPISystem(sammoGatewayAPI));
|
|
|
|
// start express server
|
|
app.listen(gatewayConfig.port)
|
|
|
|
console.log(`Gateway server has started on port ${gatewayConfig.port}`)
|
|
|
|
}).catch(error => console.log(error));
|
|
|
|
export default {}; |