Skip to content

Commit 4bb32fb

Browse files
committed
api: index
1 parent 5c4fe8c commit 4bb32fb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import express from "express";
2+
import { dbConnection } from './db/db.js';
3+
import { entrypoint } from "./entrypoint.js";
4+
import dotenv from "dotenv";
5+
import morgan from "morgan";
6+
import cors from 'cors'
7+
import { createOnlineOrder } from "./components/order/order_controller.js";
8+
9+
dotenv.config();
10+
const app = express();
11+
app.use(cors())
12+
13+
const port = 3000;
14+
app.post('/webhook', express.raw({ type: 'application/json' }), createOnlineOrder);
15+
app.use(express.json());
16+
app.use(morgan("dev"));
17+
app.use(express.static("uploads"));
18+
19+
// call: entrypoint
20+
entrypoint(app);
21+
22+
// initalize DB connection
23+
dbConnection();
24+
25+
// start the server
26+
app.listen(process.env.PORT || port, () => console.log(`Backend running on: ${port}!`));

0 commit comments

Comments
 (0)