Skip to content

Commit

Permalink
Added cache-pug-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Sep 12, 2017
1 parent 2418016 commit f7f54bd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ DEBUG=* yarn start
4. See the [Continuous Integration and Code Coverage](#continuous-integration-and-code-coverage) and [Tutorials](#tutorials) sections below for instructions on how to setup continuous integration, code coverage, and deployment.
5. If you specify the environment variables `AWS_CF_DOMAIN` then your assets will need to be published to Amazon S3/Cloudfront. To do so run `npm run publish-assets` (or with yarn as `yarn publish-assets`).
5. If you specify the environment variables `AWS_CF_DOMAIN` then your assets will need to be published to Amazon S3/Cloudfront. To do so run `npm run publish-assets` (or with yarn as `yarn publish-assets`).
#### Tests
Expand Down Expand Up @@ -641,7 +641,7 @@ If you are seeking permission to use these trademarks, then please [contact us](
[MIT](LICENSE) © [Nick Baugh](http://niftylettuce.com)
##
##
<a href="#"><img src="media/lad-footer.png" alt="#" /></a>
Expand Down
1 change: 1 addition & 0 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"boom": "^5.2.0",
"bootstrap": "^4.0.0-beta",
"bootstrap-social": "^5.1.1",
"cache-pug-templates": "^0.0.4",
"chalk": "^2.1.0",
"chart.js": "^2.6.0",
"clipboard": "^1.7.1",
Expand Down
14 changes: 11 additions & 3 deletions template/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const flash = require('koa-better-flash');
const CSRF = require('koa-csrf');
const StoreIPAddress = require('@ladjs/store-ip-address');
const isajax = require('koa-isajax');
const cachePugTemplates = require('cache-pug-templates');
// const Meta = require('koa-meta');
const Timeout = require('koa-better-timeout');
const Mongoose = require('@ladjs/mongoose');
Expand Down Expand Up @@ -68,6 +69,9 @@ let server;
app.on('error', helpers.logger.contextError.bind(helpers.logger));
app.on('log', helpers.logger.log.bind(helpers.logger));

// inherit cache variable for cache-pug-templates
app.cache = config.views.locals.cache;

// trust proxy
app.proxy = true;

Expand Down Expand Up @@ -223,9 +227,13 @@ if (config.protocols.web === 'http') server = http.createServer(app.callback());
else server = https.createServer(config.ssl.web, app.callback());

if (!module.parent)
server = server.listen(config.ports.web, () =>
helpers.logger.info(`web server listening on ${config.ports.web}`)
);
server = server.listen(config.ports.web, () => {
helpers.logger.info(`web server listening on ${config.ports.web}`);
cachePugTemplates(app, redisClient, config.views.root, (err, cached) => {
if (err) return helpers.logger.error(err);
helpers.logger.debug(`successfully cached ${cached.length} views`);
});
});

// handle process events and graceful restart
const graceful = new Graceful({
Expand Down
10 changes: 9 additions & 1 deletion template/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ async@^1.4.0, async@~1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"

async@^2.1.2:
async@^2.1.2, async@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/async/-/async-2.5.0.tgz#843190fd6b7357a0b9e1c956edddd5ec8462b54d"
dependencies:
Expand Down Expand Up @@ -1549,6 +1549,14 @@ bytes@^2.3.0, bytes@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.5.0.tgz#4c9423ea2d252c270c41b2bdefeff9bb6b62c06a"

cache-pug-templates@^0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/cache-pug-templates/-/cache-pug-templates-0.0.4.tgz#49f4f4c918a9e3801c46a8042afe87bf817356df"
dependencies:
async "^2.5.0"
debug "^3.0.1"
rev-hash "^2.0.0"

cached-path-relative@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/cached-path-relative/-/cached-path-relative-1.0.1.tgz#d09c4b52800aa4c078e2dd81a869aac90d2e54e7"
Expand Down

0 comments on commit f7f54bd

Please sign in to comment.