Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
harshit078 committed May 10, 2024
1 parent 9aaa14c commit 8794a8f
Show file tree
Hide file tree
Showing 7 changed files with 1,373 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/.env
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"
2 changes: 2 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
.env.local
42 changes: 42 additions & 0 deletions server/index.js
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'))
Loading

0 comments on commit 8794a8f

Please sign in to comment.