2020-12-04 20:38:34 +00:00
|
|
|
import consola from "consola";
|
|
|
|
import "reflect-metadata";
|
2020-11-25 18:28:12 +00:00
|
|
|
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';
|
2020-11-24 18:28:57 +00:00
|
|
|
|
2020-11-25 18:28:12 +00:00
|
|
|
const app = createExpressServer({
|
2020-11-27 20:24:55 +00:00
|
|
|
authorizationChecker: authchecker,
|
2020-12-05 16:59:43 +00:00
|
|
|
middlewares: [ErrorHandler],
|
2020-12-06 09:29:56 +00:00
|
|
|
development: config.development,
|
2020-11-27 18:32:54 +00:00
|
|
|
cors: true,
|
2020-11-27 18:32:29 +00:00
|
|
|
routePrefix: "/api",
|
|
|
|
controllers: [__dirname + "/controllers/*.ts"],
|
2020-11-25 18:28:12 +00:00
|
|
|
});
|
|
|
|
|
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();
|