1.0.3 • Published 1 year ago
@nexhero/kiwi v1.0.3
Table of Contents
Libraries
Kiwi is based in those libraries:
Requirements:
npm i -g bareInstall:
git clone https://github.com/nexhero/Kiwi.git
cd Kiwi
npm installStatic HTTP Server P2p:
bare kiwi.js -p 8080 -d /var/www/htmlHow to use:
Create server object
const port = 3001
const server = new Kiwi(port)Register new route
server.router.on('GET','/name/:name',(req,res,params)=>{
console.log(params)
res.setHeader('Content-Type', 'text/plain')
res.end("Hello: "+params.name)
})Register middleware
const nameMW = (req,res)=>{
res.write("This is middleware for route /name \n")
}
server.useMiddleware('/name/*',nameWM)Start up server
server.start()
// Or start up server with holesail
//server.start("63d709c4f93884009c3e8db69ad1dfd2000ca5b6a5ae1984a23acffa75d058c2")Example:
The repository comes with a example server
bare example/demo-kiwi.js