Skip to content

Instantly share code, notes, and snippets.

@pingkunga
Created June 30, 2018 07:16
Show Gist options
  • Save pingkunga/d2e08eaf101587bd2a5e0f5892a4e371 to your computer and use it in GitHub Desktop.
Save pingkunga/d2e08eaf101587bd2a5e0f5892a4e371 to your computer and use it in GitHub Desktop.
test camunda bpmn http-connector
const jsonServer = require('json-server')
const server = jsonServer.create()
const router = jsonServer.router('db.json')
const middlewares = jsonServer.defaults()
console.log("I am PingkungA")
// Set default middlewares (logger, static, cors and no-cache)
server.use(middlewares)
// Add custom routes before JSON Server router
server.get('/echo', (req, res) => {
res.jsonp(req.query)
})
// To handle POST, PUT and PATCH you need to use a body-parser
// You can use the one used by JSON Server
server.use(jsonServer.bodyParser)
server.use((req, res, next) => {
if (req.method === 'POST') {
req.body.createdAt = Date.now()
}
//Get Request Body
console.log(req.body)
// Continue to JSON Server router
next()
})
// Use default router
server.use(router)
server.listen(3000, () => {
console.log('JSON Server is running')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment