first
This commit is contained in:
commit
925c5d1ab2
60 changed files with 18843 additions and 0 deletions
45
src/app.ts
Normal file
45
src/app.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import "dotenv/config";
|
||||
import "reflect-metadata";
|
||||
import cors from "cors";
|
||||
import express from "express";
|
||||
import swaggerUi from "swagger-ui-express";
|
||||
import swaggerDocument from "./swagger.json";
|
||||
import * as cron from "node-cron";
|
||||
import error from "./middlewares/error";
|
||||
import { AppDataSource } from "./database/data-source";
|
||||
import { RegisterRoutes } from "./routes";
|
||||
import logMiddleware from "./middlewares/logs";
|
||||
|
||||
async function main() {
|
||||
await AppDataSource.initialize();
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(
|
||||
cors({
|
||||
origin: "*",
|
||||
}),
|
||||
);
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
app.use(logMiddleware);
|
||||
app.use("/", express.static("static"));
|
||||
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
||||
|
||||
RegisterRoutes(app);
|
||||
|
||||
app.use(error);
|
||||
const APP_HOST = process.env.APP_HOST || "0.0.0.0";
|
||||
const APP_PORT = +(process.env.APP_PORT || 3000);
|
||||
|
||||
app.listen(
|
||||
APP_PORT,
|
||||
APP_HOST,
|
||||
() => (
|
||||
console.log(`[APP] Application is running on: http://localhost:${APP_PORT}`),
|
||||
console.log(`[APP] Swagger on: http://localhost:${APP_PORT}/api-docs`)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
main();
|
||||
Loading…
Add table
Add a link
Reference in a new issue