@makano/rew 1.2.86 → 1.2.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ const { run } = require('../main');
6
6
  const { runPath } = require('../modules/runtime');
7
7
  const { cleanCache } = require('../functions/import');
8
8
  const { REW_FILE_TYPE } = require('../const/ext');
9
+ const { Usage } = require('../const/usage');
9
10
 
10
11
  const lookUpFiles = ['route', 'page', 'page.s'];
11
12
 
@@ -85,6 +86,17 @@ module.exports = (context) => {
85
86
  return this;
86
87
  }
87
88
 
89
+ onFetch(fn, override = false){
90
+ if(this.options.fetch && !override){
91
+ const originalFn = fn;
92
+ fn = (...args) => {
93
+ return originalFn(...args, this.options.fetch(...args));
94
+ }
95
+ }
96
+ this.options.fetch = fn;
97
+ return this;
98
+ }
99
+
88
100
  port(port){
89
101
  this.listen = port;
90
102
  return this;
@@ -301,6 +313,11 @@ module.exports = (context) => {
301
313
  return new Server(options);
302
314
  }
303
315
 
316
+ service = Usage.prototype.create('svr.service', (cb) => {
317
+ const server = Svr.prototype.create();
318
+ cb(server);
319
+ });
320
+
304
321
  router({ id = '/', type = 'normal', ...options }){
305
322
  let router;
306
323
  if(type == 'default') router = SvrRouter.new(IttyRouter, {...options}, { id });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.86",
3
+ "version": "1.2.87",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {