pford68 / gulp-scaffold

Scaffolding for my Gulp projects, done the way I like it, instead of the way Yeoman likes it.
MIT License
0 stars 0 forks source link

Generate my typical development server file #1

Closed pford68 closed 8 years ago

pford68 commented 9 years ago

Template:

/**
 * <h2>Angular-D3 Visualization</h2>
 *
 * <p>
 * Command-line Options:
 * <ul>
 *      <li>--main:  starts the server</li>
 *      <li>--port:  defaults to 9000</li>
 * </ul>
 * </p>
 *
 */
process.env.NODE_ENV = process.env.NODE_ENV || 'development';

var args = require("minimist")(process.argv);

// For express
var express = require("express"),
    bodyParser = require("body-parser"),
    methodOverride = require("method-override"),
    config = require("config"),
    app = express();

//============================================================ Middleware
app.use(methodOverride());
// parse application/x-www-form-urlencoded
// Causes POST requests to hang when proxied.  See https://github.com/nodejitsu/node-http-proxy/issues/530
//app.use(bodyParser.urlencoded({ extended: true }));

// parse application/json
app.use(bodyParser.json());

app.use("/ngd3-client", express.static("./build"));

app.get("/ngd3-services/test", function(req, res){
    res.send("OK")
});

//=========================================================== Public
exports.start = function(port){
    app.listen(port, function(){
        console.log("Starting Angular-D3 client on port " + port + "....");
    });
};

if (args.main){
    exports.start(args.port || process.env.PORT || config.port || 9000);
}
pford68 commented 8 years ago

I copy from the resources directory, rather than generate.