-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (28 loc) · 888 Bytes
/
index.js
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
import "dotenv/config";
import express from "express";
import bodyParser from "body-parser";
import db from "./utils/db.js";
const app = express();
const PORT = process.env.APP_PORT || 5000;
// app.use(express.json());
// create application/json parser
const jsonParser = bodyParser.json();
// create application/x-www-form-urlencoded parser
const urlEncodedParser = bodyParser.urlencoded({
extended: true,
});
app.use(jsonParser);
app.use(urlEncodedParser);
// routing files
import userRoute from "./routes/user.js";
import authRoute from "./routes/auth.js";
import productRoute from "./routes/product.js";
app.get("/api/test", () => {
console.info("test is successfull");
});
app.use("/api/auth", authRoute);
app.use("/api/users", userRoute);
app.use("/api/products", productRoute);
app.listen(PORT, () => {
console.log(`Service running on http://localhost:${PORT}`);
});