alp-node 4.1.3 → 4.2.0

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.2.0](https://github.com/christophehurpeau/alp/compare/alp-node@4.1.4...alp-node@4.2.0) (2022-10-16)
7
+
8
+
9
+ ### Features
10
+
11
+ * update to react 18 ([6ac42b8](https://github.com/christophehurpeau/alp/commit/6ac42b84b80bf76853773f3b93819666684327d1))
12
+
13
+
14
+
15
+
16
+
17
+ ## [4.1.4](https://github.com/christophehurpeau/alp/compare/alp-node@4.1.3...alp-node@4.1.4) (2022-10-13)
18
+
19
+ **Note:** Version bump only for package alp-node
20
+
21
+
22
+
23
+
24
+
6
25
  ## [4.1.3](https://github.com/christophehurpeau/alp/compare/alp-node@4.1.2...alp-node@4.1.3) (2022-03-05)
7
26
 
8
27
  **Note:** Version bump only for package alp-node
@@ -0,0 +1,41 @@
1
+ import Alp from 'alp-node';
2
+ import { addConfig, appLogger } from 'nightingale-app-console';
3
+ import type { Logger } from 'nightingale-logger';
4
+ import webProcessor from 'nightingale-web-processor';
5
+ import './server/hello';
6
+
7
+ declare module 'alp-types' {
8
+ interface Context {
9
+ logger: Logger;
10
+ }
11
+ }
12
+
13
+ const app = new Alp();
14
+
15
+ addConfig(
16
+ {
17
+ processors: [webProcessor],
18
+ },
19
+ true,
20
+ );
21
+
22
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
23
+ app.start(() => {
24
+ // init
25
+ // call here any init app
26
+
27
+ // middlewares
28
+ app.servePublic();
29
+ app.use((ctx, next) => {
30
+ ctx.logger = appLogger.context({ request: ctx.req });
31
+ return next();
32
+ });
33
+ app.use((ctx, next) => {
34
+ ctx.logger.info('Request');
35
+ return next();
36
+ });
37
+ app.catchErrors();
38
+ app.use((ctx) => {
39
+ ctx.body = { ok: true };
40
+ });
41
+ });
@@ -41,21 +41,17 @@ class AlpNodeApp extends Koa {
41
41
  translate('locales')(this);
42
42
  this.use(compress());
43
43
  }
44
-
45
44
  existsConfigSync(name) {
46
45
  return this.config.existsConfigSync(name);
47
46
  }
48
-
49
47
  loadConfigSync(name) {
50
48
  return this.config.loadConfigSync(name);
51
49
  }
52
-
53
50
  createContext(req, res) {
54
51
  const ctx = super.createContext(req, res);
55
52
  ctx.sanitizedState = {};
56
53
  return ctx;
57
54
  }
58
-
59
55
  servePublic() {
60
56
  this.use(serve(this.publicPath)); // static files
61
57
  }
@@ -63,26 +59,21 @@ class AlpNodeApp extends Koa {
63
59
  catchErrors() {
64
60
  this.use(errors);
65
61
  }
66
-
67
62
  listen() {
68
63
  throw new Error('Use start instead');
69
64
  }
65
+
70
66
  /**
71
67
  * Close server and emit close event
72
68
  */
73
-
74
-
75
69
  close() {
76
70
  if (this._server) {
77
71
  this._server.close();
78
-
79
72
  this.emit('close');
80
73
  }
81
74
  }
82
-
83
75
  async start(fn) {
84
76
  await fn();
85
-
86
77
  try {
87
78
  const server = await _listen(this.config, this.callback(), this.certPath);
88
79
  this._server = server;
@@ -96,7 +87,6 @@ class AlpNodeApp extends Koa {
96
87
  throw err;
97
88
  }
98
89
  }
99
-
100
90
  }
101
91
 
102
92
  export { AlpNodeApp };
@@ -1 +1 @@
1
- {"version":3,"file":"AlpNodeApp-node14.mjs","sources":["../src/AlpNodeApp.ts"],"sourcesContent":["import type { IncomingMessage, Server, ServerResponse } from 'http';\nimport path from 'path';\nimport { deprecate } from 'util';\nimport _listen from 'alp-listen';\nimport type { Config } from 'alp-node-config';\nimport _config from 'alp-node-config';\nimport errors from 'alp-node-errors';\nimport language from 'alp-node-language';\nimport params from 'alp-params';\nimport translate from 'alp-translate';\nimport type {\n NodeApplication,\n NodeConfig,\n Context as AlpContext,\n ContextState,\n ContextSanitizedState,\n ContextRequest,\n} from 'alp-types';\nimport Koa from 'koa';\nimport type { ParameterizedContext, DefaultState, BaseRequest } from 'koa';\nimport compress from 'koa-compress';\nimport serve from 'koa-static';\nimport { Logger } from 'nightingale-logger';\n\nconst logger = new Logger('alp');\n\nexport interface AlpNodeAppOptions {\n appDirname: string;\n packageDirname: string;\n config: Config & NodeConfig;\n certPath?: string;\n publicPath?: string;\n}\n\ndeclare module 'koa' {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow\n interface DefaultState extends ContextState {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface DefaultContext extends AlpContext {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface BaseContext extends AlpContext {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow\n interface BaseRequest extends ContextRequest {}\n}\n\nexport class AlpNodeApp extends Koa<ContextState> implements NodeApplication {\n dirname: string;\n\n certPath: string;\n\n publicPath: string;\n\n config: NodeConfig & Config;\n\n declare request: BaseRequest & ContextRequest;\n\n _server?: Server;\n\n /**\n * @param {Object} [options]\n * @param {string} [options.certPath] directory of the ssl certificates\n * @param {string} [options.publicPath] directory of public files\n */\n constructor({\n appDirname,\n packageDirname,\n config,\n certPath,\n publicPath,\n }: AlpNodeAppOptions) {\n super();\n\n this.dirname = path.normalize(appDirname);\n\n Object.defineProperty(this, 'packageDirname', {\n get: deprecate(() => packageDirname, 'packageDirname'),\n configurable: false,\n enumerable: false,\n });\n\n this.certPath = certPath || `${packageDirname}/config/cert`;\n this.publicPath = publicPath || `${packageDirname}/public/`;\n\n this.config = _config(this, config);\n this.context.config = this.config;\n\n params(this);\n language(this);\n translate('locales')(this);\n\n this.use(compress());\n }\n\n existsConfigSync(name: string): ReturnType<Config['existsConfigSync']> {\n return this.config.existsConfigSync(name);\n }\n\n loadConfigSync(name: string): ReturnType<Config['loadConfigSync']> {\n return this.config.loadConfigSync(name);\n }\n\n createContext<StateT = DefaultState>(\n req: IncomingMessage,\n res: ServerResponse,\n ): ParameterizedContext<StateT> {\n const ctx = super.createContext<StateT>(req, res);\n ctx.sanitizedState = {} as ContextSanitizedState;\n return ctx;\n }\n\n servePublic(): void {\n this.use(serve(this.publicPath)); // static files\n }\n\n catchErrors(): void {\n this.use(errors);\n }\n\n listen(): Server {\n throw new Error('Use start instead');\n }\n\n /**\n * Close server and emit close event\n */\n close(): void {\n if (this._server) {\n this._server.close();\n this.emit('close');\n }\n }\n\n async start(fn: () => Promise<void> | void): Promise<Server> {\n await fn();\n try {\n const server = await _listen(this.config, this.callback(), this.certPath);\n this._server = server;\n logger.success('started');\n if (process.send) process.send('ready');\n return server;\n } catch (err: unknown) {\n logger.error('start fail', { err });\n throw err;\n }\n }\n}\n\nexport type { Context } from 'koa';\n"],"names":["logger","Logger","AlpNodeApp","Koa","constructor","appDirname","packageDirname","config","certPath","publicPath","dirname","path","normalize","Object","defineProperty","get","deprecate","configurable","enumerable","_config","context","params","language","translate","use","compress","existsConfigSync","name","loadConfigSync","createContext","req","res","ctx","sanitizedState","servePublic","serve","catchErrors","errors","listen","Error","close","_server","emit","start","fn","server","_listen","callback","success","process","send","err","error"],"mappings":";;;;;;;;;;;;;AAwBA,MAAMA,MAAM,GAAG,IAAIC,MAAJ,CAAW,KAAX,CAAf;AAqBO,MAAMC,UAAN,SAAyBC,GAAzB,CAAsE;AAa3E;AACF;AACA;AACA;AACA;AACEC,EAAAA,WAAW,CAAC;AACVC,IAAAA,UADU;AAEVC,IAAAA,cAFU;AAGVC,IAAAA,MAHU;AAIVC,IAAAA,QAJU;AAKVC,IAAAA;AALU,GAAD,EAMW;AACpB;AAEA,SAAKC,OAAL,GAAeC,IAAI,CAACC,SAAL,CAAeP,UAAf,CAAf;AAEAQ,IAAAA,MAAM,CAACC,cAAP,CAAsB,IAAtB,EAA4B,gBAA5B,EAA8C;AAC5CC,MAAAA,GAAG,EAAEC,SAAS,CAAC,MAAMV,cAAP,EAAuB,gBAAvB,CAD8B;AAE5CW,MAAAA,YAAY,EAAE,KAF8B;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E,IAAL,CAAU,OAAV;AACD;AACF;;AAEU,QAALC,KAAK,CAACC,EAAD,EAAkD;AAC3D,UAAMA,EAAE,EAAR;;AACA,QAAI;AACF,YAAMC,MAAM,GAAG,MAAMC,OAAO,CAAC,KAAKvC,MAAN,EAAc,KAAKwC,QAAL,EAAd,EAA+B,KAAKvC,QAApC,CAA5B;AACA,WAAKiC,OAAL,GAAeI,MAAf;AACA7C,MAAAA,MAAM,CAACgD,OAAP,CAAe,SAAf;AACA,UAAIC,OAAO,CAACC,IAAZ,EAAkBD,OAAO,CAACC,IAAR,CAAa,OAAb;AAClB,aAAOL,MAAP;AACD,KAND,CAME,OAAOM,GAAP,EAAqB;AACrBnD,MAAAA,MAAM,CAACoD,KAAP,CAAa,YAAb,EAA2B;AAAED,QAAAA;AAAF,OAA3B;AACA,YAAMA,GAAN;AACD;AACF;;AAnG0E;;;;"}
1
+ {"version":3,"file":"AlpNodeApp-node14.mjs","sources":["../src/AlpNodeApp.ts"],"sourcesContent":["import type { IncomingMessage, Server, ServerResponse } from 'http';\nimport path from 'path';\nimport { deprecate } from 'util';\nimport _listen from 'alp-listen';\nimport type { Config } from 'alp-node-config';\nimport _config from 'alp-node-config';\nimport errors from 'alp-node-errors';\nimport language from 'alp-node-language';\nimport params from 'alp-params';\nimport translate from 'alp-translate';\nimport type {\n NodeApplication,\n NodeConfig,\n Context as AlpContext,\n ContextState,\n ContextSanitizedState,\n ContextRequest,\n} from 'alp-types';\nimport Koa from 'koa';\nimport type { ParameterizedContext, DefaultState, BaseRequest } from 'koa';\nimport compress from 'koa-compress';\nimport serve from 'koa-static';\nimport { Logger } from 'nightingale-logger';\n\nconst logger = new Logger('alp');\n\nexport interface AlpNodeAppOptions {\n appDirname: string;\n packageDirname: string;\n config: Config & NodeConfig;\n certPath?: string;\n publicPath?: string;\n}\n\ndeclare module 'koa' {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow\n interface DefaultState extends ContextState {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface DefaultContext extends AlpContext {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface BaseContext extends AlpContext {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow\n interface BaseRequest extends ContextRequest {}\n}\n\nexport class AlpNodeApp extends Koa<ContextState> implements NodeApplication {\n dirname: string;\n\n certPath: string;\n\n publicPath: string;\n\n config: NodeConfig & Config;\n\n declare request: BaseRequest & ContextRequest;\n\n _server?: Server;\n\n /**\n * @param {Object} [options]\n * @param {string} [options.certPath] directory of the ssl certificates\n * @param {string} [options.publicPath] directory of public files\n */\n constructor({\n appDirname,\n packageDirname,\n config,\n certPath,\n publicPath,\n }: AlpNodeAppOptions) {\n super();\n\n this.dirname = path.normalize(appDirname);\n\n Object.defineProperty(this, 'packageDirname', {\n get: deprecate(() => packageDirname, 'packageDirname'),\n configurable: false,\n enumerable: false,\n });\n\n this.certPath = certPath || `${packageDirname}/config/cert`;\n this.publicPath = publicPath || `${packageDirname}/public/`;\n\n this.config = _config(this, config);\n this.context.config = this.config;\n\n params(this);\n language(this);\n translate('locales')(this);\n\n this.use(compress());\n }\n\n existsConfigSync(name: string): ReturnType<Config['existsConfigSync']> {\n return this.config.existsConfigSync(name);\n }\n\n loadConfigSync(name: string): ReturnType<Config['loadConfigSync']> {\n return this.config.loadConfigSync(name);\n }\n\n createContext<StateT = DefaultState>(\n req: IncomingMessage,\n res: ServerResponse,\n ): ParameterizedContext<StateT> {\n const ctx = super.createContext<StateT>(req, res);\n ctx.sanitizedState = {} as ContextSanitizedState;\n return ctx;\n }\n\n servePublic(): void {\n this.use(serve(this.publicPath)); // static files\n }\n\n catchErrors(): void {\n this.use(errors);\n }\n\n listen(): Server {\n throw new Error('Use start instead');\n }\n\n /**\n * Close server and emit close event\n */\n close(): void {\n if (this._server) {\n this._server.close();\n this.emit('close');\n }\n }\n\n async start(fn: () => Promise<void> | void): Promise<Server> {\n await fn();\n try {\n const server = await _listen(this.config, this.callback(), this.certPath);\n this._server = server;\n logger.success('started');\n if (process.send) process.send('ready');\n return server;\n } catch (err: unknown) {\n logger.error('start fail', { err });\n throw err;\n }\n }\n}\n\nexport type { Context } from 'koa';\n"],"names":["logger","Logger","AlpNodeApp","Koa","constructor","appDirname","packageDirname","config","certPath","publicPath","dirname","path","normalize","Object","defineProperty","get","deprecate","configurable","enumerable","_config","context","params","language","translate","use","compress","existsConfigSync","name","loadConfigSync","createContext","req","res","ctx","sanitizedState","servePublic","serve","catchErrors","errors","listen","Error","close","_server","emit","start","fn","server","_listen","callback","success","process","send","err","error"],"mappings":";;;;;;;;;;;;;AAwBA,MAAMA,MAAM,GAAG,IAAIC,MAAM,CAAC,KAAK,CAAC,CAAA;AAqBzB,MAAMC,UAAU,SAASC,GAAG,CAA0C;AAa3E;AACF;AACA;AACA;AACA;AACEC,EAAAA,WAAW,CAAC;IACVC,UAAU;IACVC,cAAc;IACdC,MAAM;IACNC,QAAQ;AACRC,IAAAA,UAAAA;AACiB,GAAC,EAAE;AACpB,IAAA,KAAK,EAAE,CAAA;IAEP,IAAI,CAACC,OAAO,GAAGC,IAAI,CAACC,SAAS,CAACP,UAAU,CAAC,CAAA;AAEzCQ,IAAAA,MAAM,CAACC,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE;AAC5CC,MAAAA,GAAG,EAAEC,SAAS,CAAC,MAAMV,cAAc,EAAE,gBAAgB,CAAC;AACtDW,MAAAA,YAAY,EAAE,KAAK;AACnBC,MAAAA,UAAU,EAAE,KAAA;AACd,KAAC,CAAC,CAAA;AAEF,IAAA,IAAI,CAACV,QAAQ,GAAGA,QAAQ,IAAK,CAAA,EAAEF,cAAe,CAAa,YAAA,CAAA,CAAA;AAC3D,IAAA,IAAI,CAACG,UAAU,GAAGA,UAAU,IAAK,CAAA,EAAEH,cAAe,CAAS,QAAA,CAAA,CAAA;IAE3D,IAAI,CAACC,MAAM,GAAGY,OAAO,CAAC,IAAI,EAAEZ,MAAM,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AACE,IAAI,CAAC,OAAO,CAAC,CAAA;AACpB,KAAA;AACF,GAAA;EAEA,MAAMC,KAAK,CAACC,EAA8B,EAAmB;AAC3D,IAAA,MAAMA,EAAE,EAAE,CAAA;IACV,IAAI;AACF,MAAA,MAAMC,MAAM,GAAG,MAAMC,OAAO,CAAC,IAAI,CAACvC,MAAM,EAAE,IAAI,CAACwC,QAAQ,EAAE,EAAE,IAAI,CAACvC,QAAQ,CAAC,CAAA;MACzE,IAAI,CAACiC,OAAO,GAAGI,MAAM,CAAA;AACrB7C,MAAAA,MAAM,CAACgD,OAAO,CAAC,SAAS,CAAC,CAAA;MACzB,IAAIC,OAAO,CAACC,IAAI,EAAED,OAAO,CAACC,IAAI,CAAC,OAAO,CAAC,CAAA;AACvC,MAAA,OAAOL,MAAM,CAAA;KACd,CAAC,OAAOM,GAAY,EAAE;AACrBnD,MAAAA,MAAM,CAACoD,KAAK,CAAC,YAAY,EAAE;AAAED,QAAAA,GAAAA;AAAI,OAAC,CAAC,CAAA;AACnC,MAAA,MAAMA,GAAG,CAAA;AACX,KAAA;AACF,GAAA;AACF;;;;"}
@@ -1,5 +1,6 @@
1
1
  import nodeFetch from 'node-fetch';
2
2
  export { default } from 'node-fetch';
3
3
 
4
- global.fetch = nodeFetch; // eslint-disable-next-line unicorn/prefer-export-from
4
+ // @ts-expect-error -- node-fetch does not exactly match dom api
5
+ global.fetch = nodeFetch;
5
6
  //# sourceMappingURL=fetch-node14.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-node14.mjs","sources":["../src/fetch.ts"],"sourcesContent":["import nodeFetch from 'node-fetch';\n\n// @ts-expect-error -- node-fetch does not exactly match dom api\nglobal.fetch = nodeFetch;\n\n// eslint-disable-next-line unicorn/prefer-export-from\nexport default nodeFetch;\n"],"names":["global","fetch","nodeFetch"],"mappings":";;;AAGAA,MAAM,CAACC,KAAP,GAAeC,SAAf"}
1
+ {"version":3,"file":"fetch-node14.mjs","sources":["../src/fetch.ts"],"sourcesContent":["import nodeFetch from 'node-fetch';\n\n// @ts-expect-error -- node-fetch does not exactly match dom api\nglobal.fetch = nodeFetch;\n\n// eslint-disable-next-line unicorn/prefer-export-from\nexport default nodeFetch;\n"],"names":["global","fetch","nodeFetch"],"mappings":";;;AAEA;AACAA,MAAM,CAACC,KAAK,GAAGC,SAAS"}
@@ -44,21 +44,17 @@ class AlpNodeApp extends Koa {
44
44
  translate('locales')(this);
45
45
  this.use(compress());
46
46
  }
47
-
48
47
  existsConfigSync(name) {
49
48
  return this.config.existsConfigSync(name);
50
49
  }
51
-
52
50
  loadConfigSync(name) {
53
51
  return this.config.loadConfigSync(name);
54
52
  }
55
-
56
53
  createContext(req, res) {
57
54
  const ctx = super.createContext(req, res);
58
55
  ctx.sanitizedState = {};
59
56
  return ctx;
60
57
  }
61
-
62
58
  servePublic() {
63
59
  this.use(serve(this.publicPath)); // static files
64
60
  }
@@ -66,26 +62,21 @@ class AlpNodeApp extends Koa {
66
62
  catchErrors() {
67
63
  this.use(errors);
68
64
  }
69
-
70
65
  listen() {
71
66
  throw new Error('Use start instead');
72
67
  }
68
+
73
69
  /**
74
70
  * Close server and emit close event
75
71
  */
76
-
77
-
78
72
  close() {
79
73
  if (this._server) {
80
74
  this._server.close();
81
-
82
75
  this.emit('close');
83
76
  }
84
77
  }
85
-
86
78
  async start(fn) {
87
79
  await fn();
88
-
89
80
  try {
90
81
  const server = await _listen(this.config, this.callback(), this.certPath);
91
82
  this._server = server;
@@ -99,18 +90,14 @@ class AlpNodeApp extends Koa {
99
90
  throw err;
100
91
  }
101
92
  }
102
-
103
93
  }
104
94
 
105
- const logger = new Logger('alp'); // see alp-dev
106
-
95
+ const logger = new Logger('alp');
107
96
  const appDirname = path.resolve('build');
108
97
  const packagePath = path.resolve('package.json');
109
-
110
98
  if (!packagePath) {
111
99
  throw new Error(`Could not find package.json: "${String(packagePath)}"`);
112
100
  }
113
-
114
101
  const packageDirname = path.dirname(packagePath);
115
102
  logger.debug('init', {
116
103
  appDirname,
@@ -124,13 +111,13 @@ const config = new Config(configPath).loadSync({
124
111
  });
125
112
  class App extends AlpNodeApp {
126
113
  constructor(options) {
127
- super({ ...options,
114
+ super({
115
+ ...options,
128
116
  appDirname,
129
117
  packageDirname,
130
118
  config
131
119
  });
132
120
  }
133
-
134
121
  }
135
122
 
136
123
  export { appDirname, config, App as default, packageConfig, packageDirname };
@@ -1 +1 @@
1
- {"version":3,"file":"index-node14.mjs","sources":["../src/AlpNodeApp.ts","../src/index.ts"],"sourcesContent":["import type { IncomingMessage, Server, ServerResponse } from 'http';\nimport path from 'path';\nimport { deprecate } from 'util';\nimport _listen from 'alp-listen';\nimport type { Config } from 'alp-node-config';\nimport _config from 'alp-node-config';\nimport errors from 'alp-node-errors';\nimport language from 'alp-node-language';\nimport params from 'alp-params';\nimport translate from 'alp-translate';\nimport type {\n NodeApplication,\n NodeConfig,\n Context as AlpContext,\n ContextState,\n ContextSanitizedState,\n ContextRequest,\n} from 'alp-types';\nimport Koa from 'koa';\nimport type { ParameterizedContext, DefaultState, BaseRequest } from 'koa';\nimport compress from 'koa-compress';\nimport serve from 'koa-static';\nimport { Logger } from 'nightingale-logger';\n\nconst logger = new Logger('alp');\n\nexport interface AlpNodeAppOptions {\n appDirname: string;\n packageDirname: string;\n config: Config & NodeConfig;\n certPath?: string;\n publicPath?: string;\n}\n\ndeclare module 'koa' {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow\n interface DefaultState extends ContextState {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface DefaultContext extends AlpContext {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface BaseContext extends AlpContext {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow\n interface BaseRequest extends ContextRequest {}\n}\n\nexport class AlpNodeApp extends Koa<ContextState> implements NodeApplication {\n dirname: string;\n\n certPath: string;\n\n publicPath: string;\n\n config: NodeConfig & Config;\n\n declare request: BaseRequest & ContextRequest;\n\n _server?: Server;\n\n /**\n * @param {Object} [options]\n * @param {string} [options.certPath] directory of the ssl certificates\n * @param {string} [options.publicPath] directory of public files\n */\n constructor({\n appDirname,\n packageDirname,\n config,\n certPath,\n publicPath,\n }: AlpNodeAppOptions) {\n super();\n\n this.dirname = path.normalize(appDirname);\n\n Object.defineProperty(this, 'packageDirname', {\n get: deprecate(() => packageDirname, 'packageDirname'),\n configurable: false,\n enumerable: false,\n });\n\n this.certPath = certPath || `${packageDirname}/config/cert`;\n this.publicPath = publicPath || `${packageDirname}/public/`;\n\n this.config = _config(this, config);\n this.context.config = this.config;\n\n params(this);\n language(this);\n translate('locales')(this);\n\n this.use(compress());\n }\n\n existsConfigSync(name: string): ReturnType<Config['existsConfigSync']> {\n return this.config.existsConfigSync(name);\n }\n\n loadConfigSync(name: string): ReturnType<Config['loadConfigSync']> {\n return this.config.loadConfigSync(name);\n }\n\n createContext<StateT = DefaultState>(\n req: IncomingMessage,\n res: ServerResponse,\n ): ParameterizedContext<StateT> {\n const ctx = super.createContext<StateT>(req, res);\n ctx.sanitizedState = {} as ContextSanitizedState;\n return ctx;\n }\n\n servePublic(): void {\n this.use(serve(this.publicPath)); // static files\n }\n\n catchErrors(): void {\n this.use(errors);\n }\n\n listen(): Server {\n throw new Error('Use start instead');\n }\n\n /**\n * Close server and emit close event\n */\n close(): void {\n if (this._server) {\n this._server.close();\n this.emit('close');\n }\n }\n\n async start(fn: () => Promise<void> | void): Promise<Server> {\n await fn();\n try {\n const server = await _listen(this.config, this.callback(), this.certPath);\n this._server = server;\n logger.success('started');\n if (process.send) process.send('ready');\n return server;\n } catch (err: unknown) {\n logger.error('start fail', { err });\n throw err;\n }\n }\n}\n\nexport type { Context } from 'koa';\n","import { existsSync, readFileSync } from 'fs';\nimport path from 'path';\nimport { Config } from 'alp-node-config';\nimport { Logger } from 'nightingale-logger';\nimport type { AlpNodeAppOptions } from './AlpNodeApp';\nimport { AlpNodeApp } from './AlpNodeApp';\n\nexport { default as fetch } from 'node-fetch';\n\nexport type { Context } from './AlpNodeApp';\nexport { Config } from 'alp-node-config';\n\nconst logger = new Logger('alp');\n\n// see alp-dev\nexport const appDirname = path.resolve('build');\n\nconst packagePath = path.resolve('package.json');\nif (!packagePath) {\n throw new Error(`Could not find package.json: \"${String(packagePath)}\"`);\n}\nexport const packageDirname = path.dirname(packagePath);\n\nlogger.debug('init', { appDirname, packageDirname });\n\nexport const packageConfig: Record<string, unknown> = JSON.parse(\n readFileSync(packagePath, 'utf-8'),\n) as Record<string, unknown>;\n\nconst buildedConfigPath = `${appDirname}/build/config/`;\nconst configPath = existsSync(buildedConfigPath)\n ? buildedConfigPath\n : `${appDirname}/config/`;\n\nexport const config = new Config(configPath).loadSync({ packageConfig });\n\nexport type AppOptions = Omit<\n AlpNodeAppOptions,\n 'appDirname' | 'packageDirname' | 'config'\n>;\n\nexport default class App extends AlpNodeApp {\n constructor(options?: AppOptions) {\n super({\n ...options,\n appDirname,\n packageDirname,\n config,\n });\n }\n}\n"],"names":["logger","Logger","AlpNodeApp","Koa","constructor","appDirname","packageDirname","config","certPath","publicPath","dirname","path","normalize","Object","defineProperty","get","deprecate","configurable","enumerable","_config","context","params","language","translate","use","compress","existsConfigSync","name","loadConfigSync","createContext","req","res","ctx","sanitizedState","servePublic","serve","catchErrors","errors","listen","Error","close","_server","emit","start","fn","server","_listen","callback","success","process","send","err","error","resolve","packagePath","String","debug","packageConfig","JSON","parse","readFileSync","buildedConfigPath","configPath","existsSync","Config","loadSync","App","options"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAMA,QAAM,GAAG,IAAIC,MAAJ,CAAW,KAAX,CAAf;AAqBO,MAAMC,UAAN,SAAyBC,GAAzB,CAAsE;AAa3E;AACF;AACA;AACA;AACA;AACEC,EAAAA,WAAW,CAAC;AACVC,IAAAA,UADU;AAEVC,IAAAA,cAFU;AAGVC,IAAAA,MAHU;AAIVC,IAAAA,QAJU;AAKVC,IAAAA;AALU,GAAD,EAMW;A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AAd,CAArB;MAEamD,aAAsC,GAAGC,IAAI,CAACC,KAAL,CACpDC,YAAY,CAACN,WAAD,EAAc,OAAd,CADwC;AAItD,MAAMO,iBAAiB,GAAI,GAAExD,UAAW,gBAAxC;AACA,MAAMyD,UAAU,GAAGC,UAAU,CAACF,iBAAD,CAAV,GACfA,iBADe,GAEd,GAAExD,UAAW,UAFlB;MAIaE,MAAM,GAAG,IAAIyD,MAAJ,CAAWF,UAAX,EAAuBG,QAAvB,CAAgC;AAAER,EAAAA;AAAF,CAAhC;AAOP,MAAMS,GAAN,SAAkBhE,UAAlB,CAA6B;AAC1CE,EAAAA,WAAW,CAAC+D,OAAD,EAAuB;AAChC,UAAM,EACJ,GAAGA,OADC;AAEJ9D,MAAAA,UAFI;AAGJC,MAAAA,cAHI;AAIJC,MAAAA;AAJI,KAAN;AAMD;;AARyC;;;;"}
1
+ {"version":3,"file":"index-node14.mjs","sources":["../src/AlpNodeApp.ts","../src/index.ts"],"sourcesContent":["import type { IncomingMessage, Server, ServerResponse } from 'http';\nimport path from 'path';\nimport { deprecate } from 'util';\nimport _listen from 'alp-listen';\nimport type { Config } from 'alp-node-config';\nimport _config from 'alp-node-config';\nimport errors from 'alp-node-errors';\nimport language from 'alp-node-language';\nimport params from 'alp-params';\nimport translate from 'alp-translate';\nimport type {\n NodeApplication,\n NodeConfig,\n Context as AlpContext,\n ContextState,\n ContextSanitizedState,\n ContextRequest,\n} from 'alp-types';\nimport Koa from 'koa';\nimport type { ParameterizedContext, DefaultState, BaseRequest } from 'koa';\nimport compress from 'koa-compress';\nimport serve from 'koa-static';\nimport { Logger } from 'nightingale-logger';\n\nconst logger = new Logger('alp');\n\nexport interface AlpNodeAppOptions {\n appDirname: string;\n packageDirname: string;\n config: Config & NodeConfig;\n certPath?: string;\n publicPath?: string;\n}\n\ndeclare module 'koa' {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow\n interface DefaultState extends ContextState {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface DefaultContext extends AlpContext {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface BaseContext extends AlpContext {}\n // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow\n interface BaseRequest extends ContextRequest {}\n}\n\nexport class AlpNodeApp extends Koa<ContextState> implements NodeApplication {\n dirname: string;\n\n certPath: string;\n\n publicPath: string;\n\n config: NodeConfig & Config;\n\n declare request: BaseRequest & ContextRequest;\n\n _server?: Server;\n\n /**\n * @param {Object} [options]\n * @param {string} [options.certPath] directory of the ssl certificates\n * @param {string} [options.publicPath] directory of public files\n */\n constructor({\n appDirname,\n packageDirname,\n config,\n certPath,\n publicPath,\n }: AlpNodeAppOptions) {\n super();\n\n this.dirname = path.normalize(appDirname);\n\n Object.defineProperty(this, 'packageDirname', {\n get: deprecate(() => packageDirname, 'packageDirname'),\n configurable: false,\n enumerable: false,\n });\n\n this.certPath = certPath || `${packageDirname}/config/cert`;\n this.publicPath = publicPath || `${packageDirname}/public/`;\n\n this.config = _config(this, config);\n this.context.config = this.config;\n\n params(this);\n language(this);\n translate('locales')(this);\n\n this.use(compress());\n }\n\n existsConfigSync(name: string): ReturnType<Config['existsConfigSync']> {\n return this.config.existsConfigSync(name);\n }\n\n loadConfigSync(name: string): ReturnType<Config['loadConfigSync']> {\n return this.config.loadConfigSync(name);\n }\n\n createContext<StateT = DefaultState>(\n req: IncomingMessage,\n res: ServerResponse,\n ): ParameterizedContext<StateT> {\n const ctx = super.createContext<StateT>(req, res);\n ctx.sanitizedState = {} as ContextSanitizedState;\n return ctx;\n }\n\n servePublic(): void {\n this.use(serve(this.publicPath)); // static files\n }\n\n catchErrors(): void {\n this.use(errors);\n }\n\n listen(): Server {\n throw new Error('Use start instead');\n }\n\n /**\n * Close server and emit close event\n */\n close(): void {\n if (this._server) {\n this._server.close();\n this.emit('close');\n }\n }\n\n async start(fn: () => Promise<void> | void): Promise<Server> {\n await fn();\n try {\n const server = await _listen(this.config, this.callback(), this.certPath);\n this._server = server;\n logger.success('started');\n if (process.send) process.send('ready');\n return server;\n } catch (err: unknown) {\n logger.error('start fail', { err });\n throw err;\n }\n }\n}\n\nexport type { Context } from 'koa';\n","import { existsSync, readFileSync } from 'fs';\nimport path from 'path';\nimport { Config } from 'alp-node-config';\nimport { Logger } from 'nightingale-logger';\nimport type { AlpNodeAppOptions } from './AlpNodeApp';\nimport { AlpNodeApp } from './AlpNodeApp';\n\nexport { default as fetch } from 'node-fetch';\n\nexport type { Context } from './AlpNodeApp';\nexport { Config } from 'alp-node-config';\n\nconst logger = new Logger('alp');\n\nexport const appDirname = path.resolve('build');\n\nconst packagePath = path.resolve('package.json');\nif (!packagePath) {\n throw new Error(`Could not find package.json: \"${String(packagePath)}\"`);\n}\nexport const packageDirname = path.dirname(packagePath);\n\nlogger.debug('init', { appDirname, packageDirname });\n\nexport const packageConfig: Record<string, unknown> = JSON.parse(\n readFileSync(packagePath, 'utf-8'),\n) as Record<string, unknown>;\n\nconst buildedConfigPath = `${appDirname}/build/config/`;\nconst configPath = existsSync(buildedConfigPath)\n ? buildedConfigPath\n : `${appDirname}/config/`;\n\nexport const config = new Config(configPath).loadSync({ packageConfig });\n\nexport type AppOptions = Omit<\n AlpNodeAppOptions,\n 'appDirname' | 'packageDirname' | 'config'\n>;\n\nexport default class App extends AlpNodeApp {\n constructor(options?: AppOptions) {\n super({\n ...options,\n appDirname,\n packageDirname,\n config,\n });\n }\n}\n"],"names":["logger","Logger","AlpNodeApp","Koa","constructor","appDirname","packageDirname","config","certPath","publicPath","dirname","path","normalize","Object","defineProperty","get","deprecate","configurable","enumerable","_config","context","params","language","translate","use","compress","existsConfigSync","name","loadConfigSync","createContext","req","res","ctx","sanitizedState","servePublic","serve","catchErrors","errors","listen","Error","close","_server","emit","start","fn","server","_listen","callback","success","process","send","err","error","resolve","packagePath","String","debug","packageConfig","JSON","parse","readFileSync","buildedConfigPath","configPath","existsSync","Config","loadSync","App","options"],"mappings":";;;;;;;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C;AAOzD,MAAMS,GAAG,SAAShE,UAAU,CAAC;EAC1CE,WAAW,CAAC+D,OAAoB,EAAE;AAChC,IAAA,KAAK,CAAC;AACJ,MAAA,GAAGA,OAAO;MACV9D,UAAU;MACVC,cAAc;AACdC,MAAAA,MAAAA;AACF,KAAC,CAAC,CAAA;AACJ,GAAA;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC;AAE9C,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzC,eAAO,MAAM,UAAU,QAAwB,CAAC;AAMhD,eAAO,MAAM,cAAc,QAA4B,CAAC;AAIxD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAEtB,CAAC;AAO7B,eAAO,MAAM,MAAM,yCAAqD,CAAC;AAEzE,oBAAY,UAAU,GAAG,IAAI,CAC3B,iBAAiB,EACjB,YAAY,GAAG,gBAAgB,GAAG,QAAQ,CAC3C,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,UAAU;gBAC7B,OAAO,CAAC,EAAE,UAAU;CAQjC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC;AAE9C,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAIzC,eAAO,MAAM,UAAU,QAAwB,CAAC;AAMhD,eAAO,MAAM,cAAc,QAA4B,CAAC;AAIxD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAEtB,CAAC;AAO7B,eAAO,MAAM,MAAM,yCAAqD,CAAC;AAEzE,oBAAY,UAAU,GAAG,IAAI,CAC3B,iBAAiB,EACjB,YAAY,GAAG,gBAAgB,GAAG,QAAQ,CAC3C,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,UAAU;gBAC7B,OAAO,CAAC,EAAE,UAAU;CAQjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alp-node",
3
- "version": "4.1.3",
3
+ "version": "4.2.0",
4
4
  "description": "framework based on koa 2",
5
5
  "keywords": [
6
6
  "springbokjs",
@@ -90,16 +90,20 @@
90
90
  "fetch"
91
91
  ]
92
92
  },
93
+ "peerDependencies": {
94
+ "react": "^18.1.0",
95
+ "router-segments": "^5.0.0"
96
+ },
93
97
  "dependencies": {
94
98
  "@types/koa": "^2.13.1",
95
99
  "@types/node": ">=14.0.0",
96
100
  "@types/node-fetch": "^3.0.3",
97
- "alp-listen": "5.0.4",
98
- "alp-node-config": "7.0.4",
99
- "alp-node-errors": "6.0.4",
100
- "alp-node-language": "5.1.4",
101
- "alp-params": "4.2.3",
102
- "alp-translate": "6.0.5",
101
+ "alp-listen": "5.1.0",
102
+ "alp-node-config": "7.1.0",
103
+ "alp-node-errors": "6.1.0",
104
+ "alp-node-language": "5.2.0",
105
+ "alp-params": "4.3.0",
106
+ "alp-translate": "6.1.0",
103
107
  "alp-types": "3.1.0",
104
108
  "koa": "^2.13.1",
105
109
  "koa-compress": "^5.0.0",
@@ -108,12 +112,12 @@
108
112
  "node-fetch": "^3.2.0"
109
113
  },
110
114
  "devDependencies": {
111
- "@babel/core": "7.17.5",
115
+ "@babel/core": "7.17.10",
112
116
  "@types/koa-compress": "4.0.3",
113
117
  "@types/koa-static": "4.0.2",
114
118
  "@types/minimist": "1.2.2",
115
- "pob-babel": "32.2.0",
119
+ "pob-babel": "34.2.0",
116
120
  "typescript": "4.6.2"
117
121
  },
118
- "gitHead": "b6ce6531ed3bd7f594c7e3068c730864776824a0"
122
+ "gitHead": "de936d28d0779f271849b412d8a40ade84f22012"
119
123
  }
package/src/index.ts CHANGED
@@ -12,7 +12,6 @@ export { Config } from 'alp-node-config';
12
12
 
13
13
  const logger = new Logger('alp');
14
14
 
15
- // see alp-dev
16
15
  export const appDirname = path.resolve('build');
17
16
 
18
17
  const packagePath = path.resolve('package.json');