-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
56 lines (50 loc) · 1.43 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
48
49
50
51
52
53
54
55
56
import express from "express";
import { json } from "body-parser";
import dotenv from "dotenv";
import cors from "cors";
import winston from "winston";
import expressWinston from "express-winston";
import { MongoSetup } from "./config/mongo";
import { todoRouter } from "./src/routes/todo";
import { UserRouter } from "./src/routes/user";
import { ProductRouter } from "./src/routes/product";
import { TransaksiRouter } from "./src/routes/transaksi";
import { TransaksiV2R } from "./src/routes/transaksiv2";
dotenv.config();
const app = express();
app.use(json());
// view engine
app.set("view engine", "pug");
app.get("/", (req, res) => {
res.render("index", {
title: "LiLia Dev",
message: "Wellcome to GeoTirta Service App",
});
});
app.use(
expressWinston.logger({
transports: [new winston.transports.Console()],
format: winston.format.combine(
winston.format.colorize(),
winston.format.json()
),
meta: true,
msg: "HTTP {{req.method}} {{req.url}}",
expressFormat: true,
colorize: false,
ignoreRoute: (req, res) => {
return false;
},
})
);
app.use(cors());
// imported routes
app.use("/test", todoRouter);
app.use("/user", UserRouter);
app.use("/product", ProductRouter);
app.use("/transaksi", TransaksiRouter);
app.use("/transaksi/v2", TransaksiV2R);
MongoSetup(process.env.DB_URL);
app.listen(process.env.PORT, () => {
console.log("Server is listening on port " + process.env.PORT);
});