dragonrend-response
v0.4.2
Published
Dragonrend Response Handler
Downloads
6
Maintainers
Readme
Dragonrend Response
Installation
$ npm install dragonrend-response
Example
const { Dragonrend } = require('dragonrend')
const response = require('dragonrend-response')
const app = new Dragonrend()
response(app, {
defaultStatus: 201, // default is 200
defaultContentType: 'text/plain', // default is application/json
defaultBody: 'Created' // default is empty string
}) // second options argument is not required
// Server will return Response with status 201, contentType 'plain/text' and body 'Hello There'
app.get((ctx) => {
ctx.response.status = 200
ctx.response.contentType = 'application/json'
ctx.response.body = { message: 'Hi There' }
})
app.toServer().listen(8080)
Author
Egor Repnikov - GitHub
License
This project is licensed under the MIT License - see the LICENSE file for details