Skip to content

Instantly share code, notes, and snippets.

@nitish24p
Last active November 20, 2017 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitish24p/c35a271dac0850eb5550e3540dbae75b to your computer and use it in GitHub Desktop.
Save nitish24p/c35a271dac0850eb5550e3540dbae75b to your computer and use it in GitHub Desktop.
Qucikfire node server
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