-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
51 lines (38 loc) · 1.14 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import express from "express";
import { AddressInfo } from "net";
import { logger } from "./src/log/logger";
import { dataSource } from "./src/datasource/datasource";
import { environment } from "./src/environment/environment";
import { controller } from "./src/datasource/orders/controller";
var cors = require("cors");
let app = express();
let PORT = process.env.PORT || 8080;
let CronJob = require("cron").CronJob;
app.use(cors());
app.use(express.json());
app.get("/app/health-check", (req, res) => {
res.json({ code: "0000", status: "success" });
});
let dataSourceRoutes = dataSource.getRoute();
new CronJob(
"0 0 0 * * *",
async function () {
try {
await controller.addMilkCapacity()
} catch (error) {
logger.log("error", error);
}
},
null,
true,
"Asia/Kolkata"
);
app.use("/api", dataSourceRoutes);
app.get("/*", (req, res) => {
return res.send({ status: "failure", message: "404 permission!!!" });
});
console.log(environment);
let server = app.listen(PORT, function () {
var { address, port } = server.address() as AddressInfo;
logger.log("debug", "running at http://" + address + ":" + port);
});