Create a static file server for a given npm package

node v0.12.18
version: 1.0.0
endpointsharetweet
module.exports = function(exports, packageName) { var path = require("path") var express = require("express") var tonicExpress = require("notebook")("tonic/express-endpoint/1.0.0") var app = tonicExpress(exports) app.use(require('compression')()) app.use(express.static(path.dirname(require.resolve(packageName)))) return "https://tonicdev.io" + process.env.TONIC_ENDPOINT_PATH }
This will create a static file server, in the root of a package directory. So, if you're app contains some static files that you can load as an example, just append the path to the return value of this function. NOTE: You MUST require() the package outside of this function for it to work. If your package doesn't load in a node.js environment, just require("<package-name>/package.json").
Loading…

no comments

    sign in to comment