-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (27 loc) · 956 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
import express, { json } from "express";
import mongoose from "mongoose";
import dotenv from "dotenv";
dotenv.config();
const app = express();
app.use(json());
import createRoute from "./router/create.route.js";
import readRoute from "./router/read.route.js";
import readAllRoute from "./router/readAll.route.js";
import updateRoute from "./router/update.route.js";
import deleteRoute from "./router/delete.route.js";
const PORT = process.env.PORT || 7000;
//Mongoose Connection.
mongoose.connect(process.env.MONGO_DB);
mongoose.connection.on("error", (err) => {
console.log("Connection failed");
});
mongoose.connection.on("connected", (connected) => {
console.log("Connected with database......");
});
//route
app.use("/create", createRoute);
app.use("/read", readRoute);
app.use("/readAll", readAllRoute);
app.use("/update", updateRoute);
app.use("/delete", deleteRoute);
app.listen(PORT, () => console.log(`server listening at port ${PORT}`));