Skip to content

Instantly share code, notes, and snippets.

@jasper07
Last active January 2, 2016 02:39
Show Gist options
  • Save jasper07/8238214 to your computer and use it in GitHub Desktop.
Save jasper07/8238214 to your computer and use it in GitHub Desktop.
Node and express serving compressed and cached static sapui5 content
var express = require('express'),
open = require('open'),
app = express(),
port = process.env.PORT || 8888,
sapui5 = '/sapui5',
url = 'http://localhost:' + port + sapui5, // + "/latest";
year = 60 * 60 * 24 * 365 * 1000;
// Use compress middleware to gzip content
app.use(express.compress());
//set default mime type to xml for ".library" files
express.static.mime.default_type = "text/xml";
// Serve up content directory showing hidden (leading dot) files
app.use(sapui5, express.static(__dirname, {
maxAge: year,
hidden: true
}));
// enable directory listening
app.use(sapui5, express.directory(__dirname));
app.listen(port);
open(url); //open in default browser
console.log("Static file server running at\n => " + url + " \nCTRL + C to shutdown");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment