2021-11-02 18:51:52 +00:00
|
|
|
import express from 'express';
|
2021-08-22 19:25:02 +01:00
|
|
|
import 'express-async-errors';
|
2021-11-02 18:51:52 +00:00
|
|
|
import applyMiddleware from './functions/apply-middleware';
|
|
|
|
import applyRoutes from './functions/apply-routes';
|
|
|
|
import applyErrorHandling from './functions/apply-error-handling';
|
2021-08-22 19:25:02 +01:00
|
|
|
|
2021-12-24 04:26:15 +00:00
|
|
|
export const app = express();
|
|
|
|
|
2021-08-26 12:47:46 +01:00
|
|
|
export class REST {
|
2021-11-02 19:22:05 +00:00
|
|
|
constructor() {
|
2021-11-02 18:51:52 +00:00
|
|
|
const prefix = `/v2`;
|
2021-08-22 19:25:02 +01:00
|
|
|
|
2021-11-02 18:51:52 +00:00
|
|
|
applyMiddleware(app);
|
|
|
|
applyRoutes(app, prefix);
|
|
|
|
applyErrorHandling(app, prefix);
|
2021-08-22 19:25:02 +01:00
|
|
|
|
2025-03-22 13:42:37 +00:00
|
|
|
const port = process.env.PORT || 3000;
|
2021-11-02 18:51:52 +00:00
|
|
|
const server = app.listen(port, async () => {
|
2021-11-01 22:12:16 +00:00
|
|
|
log.info(`API is running on port ${port}`);
|
2021-11-02 19:22:05 +00:00
|
|
|
await deps.webSocket.init(server);
|
2021-08-22 19:25:02 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|