Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

node-net

1.0.7 • Public • Published

Simple server for Node.js

Pure Package, Simple Code, Use 'this' keywords

Installation

Install via npm:

$ npm i node-net

Usage

Hello World

const server = require('node-net')
const app = new server()
 
// response
app.use(async function() {
  this.body = 'Hello World';
});
 
app.listen(3000);

Middleware

app.use(async function (next) {
    console.log(this.url)
    setTimeout(() => {
        assert(this, app, 'should equal')
    })
    await next()
    console.log('m1')
}, function () {
    console.log('end')
})

Error Handler

app.on('error', (err) => {
    throw new Error(err)
    console.log('err: ' + err)
})

Cookies

app.keys = '' // Use Keygrip
this.cookies.set( name, [ value ], [ options ] )
this.cookies.get( name, [ options ] )

Authors

Yanglin (i@yangl.in)

License

Copyright (c) 2018 Yanglin

Released under the MIT license

install

npm i node-net

Downloadsweekly downloads

11

version

1.0.7

license

MIT

homepage

jslang.org

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability