Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/knownasilya/index-html-loader
Load and cache index.html using GCP PubSub, works great with ember-cli-deploy
https://github.com/knownasilya/index-html-loader
deployment ember-cli-deploy pubsub
Last synced: 20 days ago
JSON representation
Load and cache index.html using GCP PubSub, works great with ember-cli-deploy
- Host: GitHub
- URL: https://github.com/knownasilya/index-html-loader
- Owner: knownasilya
- Created: 2019-02-13T15:59:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-10T21:40:55.000Z (5 months ago)
- Last Synced: 2024-10-05T11:12:36.701Z (about 1 month ago)
- Topics: deployment, ember-cli-deploy, pubsub
- Language: JavaScript
- Homepage:
- Size: 458 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# index-html-loader
Load `index.html` from some source and compile it arbitrary data using handlebars.
Subsequent requests will use the cache. Cache will be reset and prewarmed
when the subscription is triggered in GCP PubSub.This library works great with [ember-cli-deploy] and specifically the following plugins:
- https://github.com/knownasilya/ember-cli-deploy-gcloud-pubsub
- https://github.com/knownasilya/ember-cli-deploy-gcloud-storage
- https://github.com/mwpastore/ember-cli-deploy-sql## Example
```js
import setupLoader from 'index-html-loader';
import pkg from './package.json';const pubsubOptions = { /* ... */ };
const indexHtml = setupLoader({
project: pkg.name,
version: pkg.version,
env: process.env.NODE_ENV,
// Make sure each pod is invalidated in kubernetes
subscriptionPostfix: process.env.GCP_POD_ID,
pubsubOptions,
findRevision: async (project, revisionId) => {
return await loadHtml(project, revisionId);
}
});router.get('/*', async function (req, res) {
let data = await loadSomeData();
let html = await indexHtml.load(data, req.query.revisionKey);res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
res.header('Expires', '-1');
res.header('Pragma', 'no-cache');
res.send(html);
});
```## Debug
You can log details from this library by adding the following
environment variable to your start/watch script.```sh
DEBUG=index-html-loader npm start
```[ember-cli-deploy]: http://ember-cli-deploy.com/