@sasm/router v3.0.1
SasmRouter
HTTP Router for SASM
Install
npm i @sasm/router
Usage
Please see for information on how to use Sasm and extensions.
The router requires you to have a public directory for web files and a designated index HTML file in that directory.
For example, if your project is in a folder named "project", here is an example document tree layout for that directory:
project>
package.json
server.js
public>
index.html
With the default configuration left alone, the above document tree will work.
Configuration
You can, of course, change the defaults to your liking- and modify the public directory and default index filename. The default configuration is accessible under sasm.router
.
1. public (string:directory): Public directory. Default: "/public"
2. index (string:HTMLfile): Default index file. Default: "index.html"
For example, if your document tree looks like the following:
project>
package.json
server.js
publicHTML>
index.htm
Your server.js
file could have the following code:
const sasm = require('@sasm/system');
const router = require('@sasm/router');
sasm.
start().
registerRoot(__dirname).
registerExtension(router);
sasm.router.public = "/publicHTML"
sasm.router.index = "index.htm"
sasm.listen();