-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9aaa14c
commit 8794a8f
Showing
7 changed files
with
1,373 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
URL="mongodb+srv://harshit:harshit@employee.ikeltpi.mongodb.net/?retryWrites=true&w=majority&appName=Employee" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
.env.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require('dotenv').config() | ||
|
||
const express = require('express') | ||
const app = express() | ||
const mongoose = require('mongoose') | ||
const getEmployees = require('./routes/getEmployees') | ||
const createEmployee = require('./routes/createEmployee') | ||
const updateEmployee = require('./routes/updateEmployee') | ||
const deleteEmployee = require('./routes/deleteEmployee') | ||
const getEmployeeById = require('./routes/getEmployeeById') | ||
const searchEmployee = require('./routes/searchEmployee') | ||
const cors = require("cors"); | ||
|
||
app.use(cors()); | ||
|
||
mongoose.connect(process.env.URL, { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true | ||
}) | ||
|
||
const db = mongoose.connection; | ||
app.use(express.json()) | ||
|
||
db.on("error", console.error.bind(console, "connection error: ")); | ||
db.once("open", function () { | ||
console.log("Connected successfully"); | ||
}); | ||
|
||
|
||
|
||
app.use('/employee', getEmployees) | ||
app.use('/employee', createEmployee) | ||
app.use('/employee', updateEmployee) | ||
app.use('/employee', deleteEmployee) | ||
app.use('/searchemployee', searchEmployee) | ||
app.use('/employee', getEmployeeById) | ||
|
||
|
||
|
||
|
||
|
||
app.listen(3100, ()=>console.log('server started in port 3100')) |
Oops, something went wrong.