poeticninja / hapi-cache-buster Goto Github PK
View Code? Open in Web Editor NEWBrowser asset cache buster.
License: MIT License
Browser asset cache buster.
License: MIT License
Sometimes Iโm getting this error:
TypeError: Uncaught error: Cannot read property 'version' of undefined
at /Users/me/project/node_modules/hapi-cache-buster/index.js:24:53
context
is undefined in that case.
By register using register: require('hapi-cache-buster'). By default it picks version no from package.json file.
Issue: Eg. for version no's 1.2.11 and 1.21.1 the {{version.cache}} render the same ?v=1211 for both. So for that it will not buster the cache.
Because lodash's isEmpty
returns true for numbers (as they don't have a length property) if you pass a number as the options
it will use the package version instead. Right now options must be a string. That's fine, except the documentation uses the word number. This should either:
Thanks for the plugin, Saul.
If you are not aware yet, Hapi v17 is making the transition from callbacks to async
/await
, as well as deprecating some other rarely used functionality. This is a breaking change that may make your plugin no longer compatible with the Hapi API.
Draft release notes can be found here: hapijs/hapi#3658
The target release date for v17 is the beginning of November.
async
/await
compatible using the v17
branch from Hapi for testing
npm link
within the Hapi reponpm link hapi
within your plugin repov17
of Hapi branch for testsnpm
. Please use a major version increment as this will be a breaking change and it would be terrible for it to sneak into current versions of Hapi.<8.0.0
.v16
will continue to be supported for as long as there exists a Node LTS actively being supported that is not compatible with v17
.server.ext('onPreResponse', (req, res) => {
if(req.response.isBoom){
const err = req.response;
const errName = err.output.payload.error;
const statusCode = err.output.payload.statusCode;
res.view('error', {
title: `${statusCode} ${errName}`,
env: process.env.NODE_ENV,
err: err,
errName: errName,
statusCode: statusCode
}).code(statusCode);
}
else {
res.continue();
}
});
In this case the version.cache
is undefined. Is it possible to pass the version.cache
from hapi-cache-buster
to the onPreResponse
"event"?
I downloaded your 'https://github.com/poeticninja/hapi-ninja' and started installing required backages & tried to run the app but it was failing.
It gives me,
D:\Projects\NodeExamples\HapiEx1>node server
module.js:333
throw err;
^
Error: Cannot find module 'c:\Users----\AppData\Roaming\npm/package.jso
n'
at Function.Module._resolveFilename (module.js:331:15)
at Function.Module._load (module.js:273:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at exports.register (C:\Users----\AppData\Roaming\npm\node_modules
hapi-cache-buster\index.js:8:36)
at internals.Pack._plugin (C:\Users-----------\AppData\Roaming\npm\node_mo
dules\hapi\lib\pack.js:447:21)
at C:\Users-----------\AppData\Roaming\npm\node_modules\hapi\lib\pack.js:2
60:14
at iterate (C:\Users-------------\AppData\Roaming\npm\node_modules\hapi\node
_modules\items\lib\index.js:35:13)
at done (C:\Users-------------\AppData\Roaming\npm\node_modules\hapi\node_mo
dules\items\lib\index.js:27:25)
at exports.register (C:\Users---------\AppData\Roaming\npm\node_modules
hapi-named-routes\index.js:53:12)
But when i tried to install the hapi-cache-buster locally, the app was successfully launched.
I downloaded your 'https://github.com/poeticninja/hapi-ninja' and started installing required backages & tried to run the app but it was failing.
It gives me,
D:\Projects\NodeExamples\HapiEx1>node server
module.js:333
throw err;
^
Error: Cannot find module 'c:\Users----\AppData\Roaming\npm/package.jso
n'
at Function.Module._resolveFilename (module.js:331:15)
at Function.Module._load (module.js:273:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at exports.register (C:\Users----\AppData\Roaming\npm\node_modules
hapi-cache-buster\index.js:8:36)
at internals.Pack._plugin (C:\Users-----------\AppData\Roaming\npm\node_mo
dules\hapi\lib\pack.js:447:21)
at C:\Users-----------\AppData\Roaming\npm\node_modules\hapi\lib\pack.js:2
60:14
at iterate (C:\Users-------------\AppData\Roaming\npm\node_modules\hapi\node
_modules\items\lib\index.js:35:13)
at done (C:\Users-------------\AppData\Roaming\npm\node_modules\hapi\node_mo
dules\items\lib\index.js:27:25)
at exports.register (C:\Users---------\AppData\Roaming\npm\node_modules
hapi-named-routes\index.js:53:12)
But when i tried to install the hapi-cache-buster locally, the app was successfully launched.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.