Skip to content

Commit

Permalink
basic server config done
Browse files Browse the repository at this point in the history
  • Loading branch information
nibab-boo committed Jun 8, 2022
1 parent e00db18 commit d28f8c8
Show file tree
Hide file tree
Showing 4 changed files with 1,402 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "crud_on_subdocument_with_mongodb",
"version": "1.0.0",
"main": "index.js",
"author": "Babin Bohora <bohorababin1@gmail.com>",
"license": "MIT",
"type": "module",
"scripts": {
"start": "node server/index.js",
"dev": "nodemon server/index.js"
},
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"mongoose": "^6.3.6",
"nodemon": "^2.0.16"
}
}
20 changes: 20 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import express from "express";
import cors from 'cors';
import 'dotenv/config';

// changes port based on enviroment
const PORT = process.env.PORT || 1234

const app = express();
// using CORS to bypass cors blocker for frontend.
app.use(cors());






// telling server to listen at PORT.
app.listen(PORT, () => {
console.log(`SERVER ${process.env.HAPPY} starting on ${PORT}`);
});
Loading

0 comments on commit d28f8c8

Please sign in to comment.