1.0.23 • Published 1 year ago
neat-webserver v1.0.23
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
1 year ago
1.0.22
5 years ago
1.0.21
5 years ago
1.0.20
8 years ago
1.0.19
8 years ago
1.0.18
8 years ago
1.0.17
8 years ago
1.0.16
8 years ago
1.0.15
8 years ago
1.0.14
8 years ago
1.0.13
8 years ago
1.0.12
8 years ago
1.0.10
9 years ago
1.0.9
9 years ago
1.0.8
9 years ago
1.0.7
9 years ago
1.0.6
9 years ago
1.0.5
9 years ago
1.0.4
9 years ago
1.0.3
9 years ago
1.0.2
9 years ago
1.0.1
9 years ago
1.0.0
9 years ago