@sasm/router

3.0.1 • Public • Published

SasmRouter

HTTP Router for SASM

NPM Version Node Version Sasm Version SasmRouter Version

Install

npm i @sasm/router

Usage

Please see Sasm Version 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();

Readme

Keywords

Package Sidebar

Install

npm i @sasm/router

Weekly Downloads

8

Version

3.0.1

License

MIT

Unpacked Size

4.26 kB

Total Files

4

Last publish

Collaborators

  • dreamersword
  • s-p-n