Closed nassirdreffy closed 5 years ago
const bodyParser = require('body-parser'); const server = require('restana/libs/turbo-http') const router = require('find-my-way') const routerFactory = (options) => {return router(options)}
const service = require('restana')({routerFactory, server* }); //server occurs an error:
{ "errClass": "TypeError", "code": 500, "message": "stream.on is not a function" }
service.start(3000) service.use(bodyParser.json()); service.use(bodyParser.urlencoded({extended:true}));
service.get('/', async (req, res) => { res.send("Hello World"); }); service.get('/user/:id', async (req, res) => { res.send("User ID: " + req.params.id); }); service.post('/user', async (req, res) => { res.send(req.body.name); });
/#################################################################
Regards
hi, I'm not sure if koa-bodyparser can work with restana. If you want to investigate the error, you should first look at the error stack to find where the error occured.
restana
const bodyParser = require('body-parser'); const server = require('restana/libs/turbo-http') const router = require('find-my-way') const routerFactory = (options) => {return router(options)}
const service = require('restana')({routerFactory, server* }); //server occurs an error:
service.start(3000) service.use(bodyParser.json()); service.use(bodyParser.urlencoded({extended:true}));
service.get('/', async (req, res) => { res.send("Hello World"); }); service.get('/user/:id', async (req, res) => { res.send("User ID: " + req.params.id); }); service.post('/user', async (req, res) => { res.send(req.body.name); });
/#################################################################
Regards