Skip to content

Instantly share code, notes, and snippets.

@nandunbandara
Created May 17, 2017 07:16
Show Gist options
  • Save nandunbandara/75c9119db32e783daeaa0affe5892fc7 to your computer and use it in GitHub Desktop.
Save nandunbandara/75c9119db32e783daeaa0affe5892fc7 to your computer and use it in GitHub Desktop.
Sample express service
const express = require("express")
bodyParser = require("body-parser");
app = express();
app.use(bodyParser.urlencoded({ extended:false }));
app.use(bodyParser.json());
app.get('/', (req,res)=>{
res.json({message: "sample service"});
})
app.post('/', (req,res)=>{
res.json({received:req.body, status:"success"});
})
app.get('/:id', (req,res)=>{
res.json({recieved:req.params.id, status:"success"});
})
app.listen(9001, ()=>{
console.log("Listening on port 9001");
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment