fix
This commit is contained in:
35
book/node_modules/tiny-lr/examples/express/app.js
generated
vendored
Normal file
35
book/node_modules/tiny-lr/examples/express/app.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
const path = require('path');
|
||||
const express = require('express');
|
||||
const tinylr = require('../..');
|
||||
const debug = require('debug')('tinylr:server');
|
||||
const gaze = require('gaze');
|
||||
|
||||
process.env.DEBUG = process.env.DEBUG || 'tinylr*';
|
||||
|
||||
var app = module.exports = express();
|
||||
|
||||
function logger (fmt) {
|
||||
fmt = fmt || '%s - %s';
|
||||
|
||||
return function logger (req, res, next) {
|
||||
debug(fmt, req.method, req.url);
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
(function watch (em) {
|
||||
em = em || new (require('events').EventEmitter)();
|
||||
|
||||
gaze(path.join(__dirname, 'styles/site.css'), function () {
|
||||
this.on('changed', function (filepath) {
|
||||
tinylr.changed(filepath);
|
||||
});
|
||||
});
|
||||
|
||||
return watch;
|
||||
})();
|
||||
|
||||
app
|
||||
.use(logger())
|
||||
.use('/', express.static(path.join(__dirname)))
|
||||
.use(tinylr.middleware({ app: app }));
|
Reference in New Issue
Block a user