Skip to content

agnostio/instant-static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#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!


npm install instant-static --save
const iStat = require('instant-static');
iStat(configObject, callbackFunction);
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

About

A simple API for creating static routes in node JS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published