@makano/rew 1.2.85 → 1.2.87

Sign up to get free protection for your applications and to get access to all the features.
@@ -149,6 +149,16 @@ module.exports.prepareContext = function (
149
149
  }
150
150
  }
151
151
 
152
+ if(!context.app){
153
+ context.appPackage = (packageName) => context.app = { config: { manifest: { package: packageName } } }
154
+ }
155
+
156
+ Object.defineProperty(context, 'packageName', {
157
+ get: () => context.app?.config?.manifest?.package,
158
+ enumerable: true,
159
+ configurable: true
160
+ });
161
+
152
162
  if (
153
163
  context.module.main ||
154
164
  (options.fromMain == true && options.as == "main")
@@ -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.85",
3
+ "version": "1.2.87",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {