-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.js
29 lines (27 loc) · 809 Bytes
/
get.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
const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const app = express();
const cors = require("cors");
const dotenv = require('dotenv');
app.use(
cors({
origin: "*",
})
);
dotenv.config({path: './config.env'})
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
const router = require("./Routes/routes");
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
mongoose.connect(process.env.databaseLink);
var db = mongoose.connection;
db.on("error", console.error.bind(console, "connection error:"));
db.once("open", function callback() {
console.log("Database Connected!");
});
app.use("/api", router);
app.listen(process.env.port, () => {
console.log("Server Running...");
});