express-roads

NodeJS - Express Application and API Routes Management

Usage no npm install needed!

<script type="module">
  import expressRoads from 'https://cdn.skypack.dev/express-roads';
</script>

README

nodejs-express-roads

NodeJS - Express Application and API Routes Management

Installation

npm install express-roads

Use

var http = require('http')
   ,express = require('express')
   ,ExpressRoads = require('express-roads')
   ,app = express();
 
ExpressRoads.initialize(app, {
   ,baseDir: __dirname
   ,routesDir: './src/routes' // Relative to baseDir

   ,useAPI: true
   ,apiBaseDir: './src/routes/api' // Relatives to baseDir
   ,debug: true
}, function() {

    //
    // Public directory to serve
    //
    app.use(express.static(path.join(__dirname, 'www')));


    //
    // Start listening...
    //
    http.createServer(app).listen(app.get('port'), function(){
      console.log("\n[Started] Backend is listening on port: " + app.get('port'));
    });

});

See examples...