Lloyd Brookes
9 years ago
6 changed files with 24 additions and 125 deletions
-
54README.md
-
27example/stack/cache-control.js
-
10example/stack/live-reload-optional/index.html
-
24example/stack/live-reload-optional/stack.js
-
10example/stack/live-reload/index.html
-
14example/stack/live-reload/stack.js
@ -1,27 +0,0 @@ |
|||||
'use strict' |
|
||||
const LocalWebServer = require('../../') |
|
||||
const cacheControl = require('koa-cache-control') |
|
||||
const DefaultStack = require('local-web-server-default-stack') |
|
||||
|
|
||||
class CacheControl extends DefaultStack { |
|
||||
addAll () { |
|
||||
return this.addLogging('dev') |
|
||||
.addCacheControl() |
|
||||
.addStatic() |
|
||||
.addIndex() |
|
||||
} |
|
||||
addCacheControl () { |
|
||||
this.add({ |
|
||||
optionDefinitions: { |
|
||||
name: 'maxage', type: Number, |
|
||||
description: 'The maxage to set on each response.' |
|
||||
}, |
|
||||
middleware: function (options) { |
|
||||
return cacheControl({ maxAge: options.maxage }) |
|
||||
} |
|
||||
}) |
|
||||
return this |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
module.exports = CacheControl |
|
@ -1,10 +0,0 @@ |
|||||
<!DOCTYPE html> |
|
||||
<html> |
|
||||
<head> |
|
||||
<meta charset="utf-8"> |
|
||||
<title>live-reload demo</title> |
|
||||
</head> |
|
||||
<body> |
|
||||
<h1>Live reloaded potentially attached</h1> |
|
||||
</body> |
|
||||
</html> |
|
@ -1,24 +0,0 @@ |
|||||
'use strict' |
|
||||
const LocalWebServer = require('../../../') |
|
||||
const liveReload = require('koa-livereload') |
|
||||
const DefaultStack = require('local-web-server-default-stack') |
|
||||
|
|
||||
class LiveReloadStack extends DefaultStack { |
|
||||
addAll () { |
|
||||
return this.addLogging('dev') |
|
||||
.add({ |
|
||||
optionDefinitions: { |
|
||||
name: 'live-reload', type: Boolean, |
|
||||
description: 'Add live reload.' |
|
||||
}, |
|
||||
middleware: function (options) { |
|
||||
if (options['live-reload']) { |
|
||||
return liveReload() |
|
||||
} |
|
||||
} |
|
||||
}) |
|
||||
.addStatic() |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
module.exports = LiveReloadStack |
|
@ -1,10 +0,0 @@ |
|||||
<!DOCTYPE html> |
|
||||
<html> |
|
||||
<head> |
|
||||
<meta charset="utf-8"> |
|
||||
<title>live-reload demo</title> |
|
||||
</head> |
|
||||
<body> |
|
||||
<h1>Live reloaded attached</h1> |
|
||||
</body> |
|
||||
</html> |
|
@ -1,14 +0,0 @@ |
|||||
'use strict' |
|
||||
const LocalWebServer = require('../../../') |
|
||||
const liveReload = require('koa-livereload') |
|
||||
const DefaultStack = require('local-web-server-default-stack') |
|
||||
|
|
||||
class LiveReloadStack extends DefaultStack { |
|
||||
addAll () { |
|
||||
return this.addLogging('dev') |
|
||||
.add({ middleware: liveReload }) |
|
||||
.addStatic() |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
module.exports = LiveReloadStack |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue