compare error stack between egg@1
(co-base) and egg@2
(async-base)
// /app/service/test.js
class TestService extends Service {
echo() {
// https://tsplay.dev/WJ73Zw | |
type MountPlugin<T, TestRunner> = { | |
[key in keyof T]: T[key] extends (core: TestRunner, ...args: infer I) => any ? (...args: I) => MountPlugin<T, TestRunner> : undefined; | |
} & TestRunner; | |
interface PluginLike { | |
[key: string]: (core: any, ...args: any[]) => any; | |
} | |
type RestParam<T> = T extends (first: any, ...args: infer R) => any ? R : any; |
// https://tsplay.dev/WG4bKw | |
class TestRunner { | |
plugin(plugins) { | |
for (const key of Object.keys(plugins)) { | |
const initFn = plugins[key]; | |
this[key] = (...args) => { | |
initFn(this, ...args); | |
return this; | |
}; | |
} |
import { AsyncLocalStorage } from 'async_hooks'; | |
class App { | |
private asyncLocalStorage = new AsyncLocalStorage(); | |
private middlewares = []; | |
async use(fn, opts) { | |
const mw = fn(this, opts); | |
this.middlewares.push(mw); | |
} |
function lazyRequire(id) { | |
return new Proxy({}, { | |
get: (_, key, reciver) => { | |
const mod = require(id); | |
return Reflect.get(mod, key, reciver); | |
}, | |
}); | |
} | |
const fs = lazyRequire('fs'); |
OS: darwin x64 | |
Adapter node: v7.9.0 x64 | |
vscode-chrome-debug-core: 5.0.2 | |
16:27:32, 2018-6-13 | |
node-debug2: 1.24.2 | |
From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"node2","locale":"en","linesStartAt1":true,"columnsStartAt1":true,"pathFormat":"path","supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true}) | |
To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"exceptionBreakpointFilters":[{"label":"All Exceptions","filter":"all","default":false},{"label":"Uncaught Exceptions","filter":"uncaught","default":false}],"supportsConfigurationDoneRequest":true,"supportsSetVariable":true,"supportsConditionalBreakpoints":true,"supportsCompletionsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsRestartFrame":true,"supportsExceptionInfoRequest":true,"supportsDelayedStackTraceLoading":true,"supportsValueFormattingOptions":true,"supportsEvaluateForHovers":true,"supportsLogPoints":true}} |
➜ showcase git:(now) ✗ now log https://showcase-vonarcxljh.now.sh/ | |
10/10 12:55 PM npm install | |
10/10 12:55 PM ⧗ Installing 11 main dependencies… | |
10/10 12:56 PM ✓ Installed 896 modules [13s] | |
10/10 12:56 PM npm start | |
10/10 12:56 PM npm WARN lifecycle The node binary used for scripts is /home/nowuser/bin/node but npm is using /usr/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. | |
10/10 12:56 PM | |
> [email protected] start /home/nowuser/src | |
> egg-scripts start --workers=1 | |
10/10 12:56 PM |
quick npm owner add
eggjs/egg#241 太长了,重开一个,讨论第一期的实现方案。
仅提供 egg-scripts start
和 egg-scripts stop
几条最基础的线上指令。
而看了下原内网的实现,会比较依赖于环境变量,本方案更倾向于用 cli options 的方式
$ egg-scripts start --baseDir=<APP_BASE> --port=7001 --env=prod --workers=2 --no-daemon
'use strict'; | |
const Benchmark = require('benchmark'); | |
const benchmarks = require('beautify-benchmark'); | |
const suite = new Benchmark.Suite(); | |
suite | |
.add('get header all lower case', function() { | |
const res = {}; | |
res['x-frame-options1'] = 'X-Frame-Options1 value'; |