Last active
November 20, 2017 18:04
-
-
Save nitish24p/c35a271dac0850eb5550e3540dbae75b to your computer and use it in GitHub Desktop.
Qucikfire node server
This file contains hidden or 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
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const app = express(); | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({extended: true})) | |
app.get('/status', (req , res) => { | |
res.send({ | |
status: 'Ok' | |
}) | |
}) | |
app.get('/greet', (req , res) => { | |
const name = req.query.name; | |
const food = req.query.food; | |
res.send({ | |
message: `hello ${name} would you like a ${food}` | |
}) | |
}) | |
app.post('/register', (req , res) => { | |
const { body } = req; | |
if (!body.username) { | |
return res.status(400).send({ | |
message: 'username is missing' | |
}) | |
} | |
if (!body.password) { | |
return res.status(400).send({ | |
message: 'password is missing' | |
}) | |
} | |
return res.send({ | |
message: `new user created` | |
}) | |
}) | |
module.exports = app; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment