@srfnstack/spliffy

1.2.3 • Public • Published

Spliffy

directory based routing with js request handlers and static file serving

Getting started

Create a directories for your app

mkdir -p ~/app/www

Install spliffy

cd ~/app && npm install spliffy

Create a handler for the desired route name

vi ~/app/www/spliffy.js

module.exports = {
    GET: () => ({hello: "spliffy"})
}

Create the start script, vi ~/app/serve.js

require('spliffy')({routeDir: __dirname+ '/www'})

because the routeDir is ~/app/www, the filename spliffy.js creates the path /spliffy

The object passed to spliffy is the config. See the Config section for more information.

routeDir is the only required property and should be an absolute path.

10420 is the default port for http, and can be changed by setting the port in the config

start the server node ~/app/serve.js

Go to localhost:10420/spliffy

Documentation

Examples

Package Sidebar

Install

npm i @srfnstack/spliffy

Weekly Downloads

163

Version

1.2.3

License

MIT

Unpacked Size

59.7 kB

Total Files

19

Last publish

Collaborators

  • narcoleptic_snowman