0.1.3 • Published 7 years ago

instant-static v0.1.3

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

#Instant Static ##A simple API for creating static routes in node JS. Under the hood, it's using express, and the express.static function to create your routes. Since that's all the module does, it was easy to keep the API simple!

const iStat = require('instant-static');
iStat({
    preferedPort: 3111, // number - this port is attempted, if it's unavailable, another port will be used.
    localOnly: true, // boolean - true makes this route only available on localhost, false makes it available to the network
    routes: [{ // array of objects - define your routes
        url: '/img', // string - domain:port{{url given}}
        location: `${__dirname}/img` // string - folder that this URL maps to
    }]
}, function(info) {
	console.log(info);
});

console.log(info); from above gives the following:

{
    port: 3111,
    routes: [{
        url: '/img',
        location: '/Users/Adam/Desktop/_temp/tests/img'
    }],
    localOnly: true
}

That's it! Calling the function created our route(s) and when complete, information about the route(s) created is/are reported back in the callback function.

https://github.com/adammeola01/instant-static

https://www.npmjs.com/package/instant-static