50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import 'reflect-metadata';
|
|
import { BasicQueryDTO } from './api/index.js';
|
|
import { validate } from 'class-validator';
|
|
import express, { Request, Response } from "express"
|
|
import { AppDataSource } from "./data_source"
|
|
import dotenv from "dotenv";
|
|
import session from "express-session";
|
|
import path from 'node:path';
|
|
|
|
dotenv.config({
|
|
path: `.env.server.${process.env.NODE_ENV}`
|
|
});
|
|
|
|
export async function test() {
|
|
console.log("Hello World!");
|
|
|
|
const dto = new BasicQueryDTO();
|
|
dto.command = 'None';
|
|
dto.generalID = 1.1;
|
|
|
|
const result = await validate(dto);
|
|
console.log(result);
|
|
//must be integer가 나타나야함
|
|
}
|
|
|
|
|
|
await test();
|
|
|
|
|
|
AppDataSource.initialize().then(async () => {
|
|
|
|
// create express app
|
|
const app = express()
|
|
app.use(session({
|
|
secret: ownConfig.sessionSecret,
|
|
resave: false,
|
|
saveUninitialized: false,
|
|
}))
|
|
app.set('etag', false);
|
|
|
|
app.use('/', rootRouter);
|
|
|
|
// start express server
|
|
app.listen(ownConfig.port)
|
|
|
|
console.log(`Express server has started on port ${ownConfig.port}`)
|
|
|
|
}).catch(error => console.log(error))
|
|
|
|
export default {}; |