-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
21 lines (18 loc) · 705 Bytes
/
server.js
File metadata and controls
21 lines (18 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const app = require("./app");
const mongoose = require("mongoose");
require("dotenv").config();
const port = process.env.PORT;
// Mongoose Self involve function
// A "self-involved function" in JavaScript, also known as an Immediately Invoked Function Expression (IIFE), is a function that executes itself immediately after it's defined.
(async () => {
await mongoose.connect(process.env.MONGO_URI);
console.log("MongoDB Connected Successfully");
})();
// Test-For-Get-Req.Headers => Token
app.get("/", (req, res) => {
console.log("Token =>", req.header("Authorization").split(" ")[1]);
res.json("Ok")
})
app.listen(port, () => {
console.log(`Server Running on http://localhost:${port}`);
});