swproxy-mod
v0.0.2
Published
base package to write mods for the swproxy library
Downloads
6
Maintainers
Readme
swproxy
work in progress
Base package to write a custom mod for the swproxy library.
1.) install this package as a dev dependency
‘‘‘ npm install --save-dev swproxy-mod ‘‘‘
Mod
''' class ModRewrite { static factoryMethodName() { return 'rewriteRule'; }
static factoryMethod(swproxy) { return (...args) { let rule = new RewriteRule(arg...); swproxy.addFetchRule(rule); } } }
// [...]
swproxy.registerMod(ModRewrite);
swproxy.rewriteRule('param1', 'param2', 'param3'); '''
Rule
''' class RewriteRule { match: (event) => true, execute: (originalEvent, event) { return new Promise((resolve, reject) => { // execute the rule in this promise }); } } '''
License
MIT © Alexander Bartels