forked from surajdevere09/Blinkit-clone-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (41 loc) · 1.78 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const express = require('express');
const path = require('path');
const { body, validationResult } = require('express-validator');
const bodyParser = require('body-parser');
const connect = require("./configs/db")
const coldController = require("./controllers/cold.controller")
const groceryController = require("./controllers/grocery.controller")
const vegController = require("./controllers/vegetable.controller")
const personalController = require("./controllers/personal.controller")
const userController = require("./controllers/user.controller")
const cors = require("cors")
const {register,login} = require("./controllers/auth.controller")
const port = process.env.PORT || 5008;
const app = express();
app.use(cors())
app.use(express.json())
app.use('/',express.static(path.join(__dirname,'public')))
app.use(bodyParser.json())
// app.use("/",coldController)
app.use("/cold",coldController)
app.use("/grocery",groceryController)
app.use("/vegetable",vegController)
app.use("/personal",personalController)
app.post("/register",body("firstname").isLength({min:2,max:30}),body("lastname").isLength({min:2,max:30}),body("email").isEmail(),body("password").isStrongPassword() ,register)
app.post("/login",login)
app.use("/user",userController)
// firstname: { type: String, required: true },
// lastname: { type: String, required: true },
// email: { type: String, required: true },
// password: { type: String, required: true },
// app.set("view engine","ejs");
// app.use("/styles", express.static(path.resolve(__dirname, "public/styles")));
// app.use("/scripts", express.static(path.resolve(__dirname, "public/scripts")));
app.listen(port, async ()=>{
try {
await connect();
console.log('listening on port 5008')
} catch (e) {
console.log('e:', e.message);
}
})