Last active
January 2, 2016 02:39
-
-
Save jasper07/8238214 to your computer and use it in GitHub Desktop.
Node and express serving compressed and cached static sapui5 content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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