1.0.23 • Published 4 months ago

neat-webserver v1.0.23

Weekly downloads
4
License
ISC
Repository
github
Last release
4 months ago

neat-webserver

Installation

npm install neat-webserver --save

Configuration

{
    port: 13337,                    // port on which to run the app
    maxBodySize: '10mb',            // max body size the server will accept
    cookieParser: {         
        "domain": "",               // domain for the cookie parser
        "secret": "neat-secret"     // secret for the cookie CHANGE THIS!
    },
    session: {
        name: "neat",               // name of the cookie being set for the session
        secret: "neat-secret",      // should be the same as above    
        enabled: true,              // enable sessions duh!
        resave: true,               // resave the session
        saveUninitialized: true,    // do save the session even if nothing has been set        
        cookie: {
            domain: "",             // domain for the session cookie parser
            secure: false           // use secure (SSL) cookies
        },
        store: {
            host: "localhost",      // redis host
            port: 6379,             // redis port
            password: null,         // redis password
            db: 0                   // redis db
        }
    },
    cors: [                         // array of domains where you would like to accept CORS ajax requests from
        "www.google.de"
    ]
}

Usage

In your main.js
Application.registerModule("webserver", require("neat-webserver"));
In any module

Add a route

Application.modules.webserver.addRoute("get" || "post", "/url/for/route/.*?-:id.html", (req, res) => {
    res.end("Hello World");
});

Add middleware

Application.modules.webserver.addMiddleware("/path" || null, (req, res, next) => {
    req.test = true;
    next();    
});
1.0.23

4 months ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago