unpkg/server.js

25 lines
821 B
JavaScript
Raw Normal View History

2016-02-22 06:05:44 +00:00
const createRequestHandler = require('npm-http-server').createRequestHandler
const express = require('express')
const cors = require('cors')
2016-02-22 02:52:19 +00:00
2016-03-06 05:59:53 +00:00
const registryURL = process.env.npm_package_config_registryURL
const bowerBundle = process.env.npm_package_config_bowerBundle
2016-03-18 19:45:49 +00:00
const redirectTTL = process.env.npm_package_config_redirectTTL
2016-03-26 07:09:07 +00:00
const autoIndex = process.env.npm_package_config_autoIndex
2016-02-22 06:05:44 +00:00
const port = process.env.PORT || process.env.npm_package_config_port
const app = express()
2016-02-22 02:52:19 +00:00
app.disable('x-powered-by')
app.use(cors())
app.use(express.static('public', { maxAge: 60000 }))
app.use(createRequestHandler({
registryURL: registryURL,
2016-03-18 19:45:49 +00:00
bowerBundle: bowerBundle,
2016-03-26 07:09:07 +00:00
redirectTTL: redirectTTL,
autoIndex: autoIndex
}))
2016-02-22 02:52:19 +00:00
app.listen(port, function () {
2016-03-07 03:29:49 +00:00
console.log('Server started on port %s, Ctrl+C to quit', port)
2016-02-22 02:52:19 +00:00
})