backend/src/app.ts

27 lines
740 B
TypeScript
Raw Normal View History

2020-12-04 20:38:34 +00:00
import consola from "consola";
import "reflect-metadata";
import { createExpressServer } from "routing-controllers";
2020-11-27 20:24:55 +00:00
import authchecker from "./authchecker";
2020-12-06 09:29:56 +00:00
import { config } from './config';
2020-12-04 20:38:34 +00:00
import loaders from "./loaders/index";
2020-11-27 20:24:55 +00:00
import { ErrorHandler } from './middlewares/ErrorHandler';
const app = createExpressServer({
2020-11-27 20:24:55 +00:00
authorizationChecker: authchecker,
middlewares: [ErrorHandler],
2020-12-06 09:29:56 +00:00
development: config.development,
cors: true,
2020-11-27 18:32:29 +00:00
routePrefix: "/api",
controllers: [__dirname + "/controllers/*.ts"],
});
2020-11-25 17:31:06 +00:00
async function main() {
2020-11-27 17:46:04 +00:00
await loaders(app);
2020-12-06 09:29:56 +00:00
app.listen(config.internal_port, () => {
2020-11-27 17:46:04 +00:00
consola.success(
2020-12-06 09:29:56 +00:00
`⚡️[server]: Server is running at http://localhost:${config.internal_port}`
2020-11-27 17:46:04 +00:00
);
});
2020-11-25 17:31:06 +00:00
}
2020-11-25 17:43:08 +00:00
main();