Slim Node.js HTTP Server
Installation
- Install the npm package
npm install slim-node-server
- Import the module to your project (see example below)
Usage
After installing installing the framework, create a new instance of Slim
and start creating your server:
// import slim frameworkconst Slim = ; // create new slim server with logginglet app = true; app ;
Middleware
- All request types support middleware functions
- The last function must end the response
- All route handler functions are executed in the order they are specified
Example:
{ console; ;} // add middleware to log page url visited to server consoleapp;
Query Parameters
Parse query parameters as needed using the request
object in a handler function. Example:
app
Body Parsing
Parse a payload body as needed using the request
object in a handler function. Example:
app
Router
Routes can be imported from other files to reduce file size. Example:
app ;