forked from expressjs/compression
-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.js
28 lines (24 loc) · 792 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var express = require('express')
var http = require('http')
var yargs = require('yargs')
var args = yargs(process.argv)
.usage('Usage: $0 [options]')
.option('c', {
default: 'compression',
choices: ['compression', 'shrink-ray', 'none'],
describe: 'The compression middleware to use (compression or shrink-ray)'
})
.option('p', {
default: 3000,
describe: 'The port on which to serve the content'
})
.help('?')
.alias('?', 'help')
.argv
var app = express()
if (args.c !== 'none') app.use(require(args.c)({filter: function () { return true }}))
app.use(express.static('canterbury'))
var server = http.createServer(app)
server.listen(args.p, function () {
console.log('Compressed Canterbury corpus app listening on port ' + args.p + ' with ' + args.c + ' middleware!')
})