Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav-18max committed May 1, 2021
1 parent 6ac8054 commit 116d7d9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
5 changes: 5 additions & 0 deletions mock/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"cookie": "^0.4.1",
"cors": "^2.8.5",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1"
"jsonwebtoken": "^8.5.1",
"routes": "^2.1.0"
}
}
25 changes: 25 additions & 0 deletions mock/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const router = express.Router()
const cookie = require('cookie')

const auth = require('./auth')

const {getUserData, generateToken} = require('./utils')

const users = [
Expand Down Expand Up @@ -103,4 +104,28 @@ router.get('/logout', auth, (req, res) => {
res.status(200).send()
})

router.post('/registration',(req,res)=>{
let newuserdetails =new user({
name:req.body.name,
username:req.body.username,
phone:req.body.phonenumber,
location:req.body.location,
email:req.body.email,
password:req.body.password
})


newuserdetails.save((err)=> {
if(err){
res.json({msg: 'failed to add details'});
console.log(err);
res.status(401).send()
}
else{
res.json({msg:'details added'});
res.status(200).send()
}
})
})

module.exports = router
7 changes: 5 additions & 2 deletions mock/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const cors = require('cors')
const app = express()
const PORT = 5001


const corsOptions = {
origin: 'http://localhost:3000',
credentials: true
Expand All @@ -12,9 +13,11 @@ const corsOptions = {
app.use(cors(corsOptions))
app.use(express.json())

const routes = require('./routes')

const routes =require('./routes')

app.use('/api', routes)

app.listen(PORT, () => {
console.log("Mock Server Running of Port " + PORT)
})
})

0 comments on commit 116d7d9

Please sign in to comment.