alp-node 4.0.3 → 4.1.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,24 @@
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.1.0](https://github.com/christophehurpeau/alp/compare/alp-node@4.0.3...alp-node@4.1.0) (2022-02-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * alp-node/fetch typings ([4bcc2a6](https://github.com/christophehurpeau/alp/commit/4bcc2a69d7ecb416f63c707a33237bc868e85696))
12
+ * request.searchParams ([d4552c6](https://github.com/christophehurpeau/alp/commit/d4552c6ce41dc3bf7aeeaa24f5e4ddc16164ae7f))
13
+
14
+
15
+ ### Features
16
+
17
+ * **alp-node:** update for newest version of alp-params ([6391d96](https://github.com/christophehurpeau/alp/commit/6391d96b61666e1eb64c9a49779327a08cdaaf66))
18
+ * update node-fetch ([ffeb05d](https://github.com/christophehurpeau/alp/commit/ffeb05d17f299af13f6ec498503feca1e08ae214))
19
+
20
+
21
+
22
+
23
+
6
24
  ## [4.0.3](https://github.com/christophehurpeau/alp/compare/alp-node@4.0.2...alp-node@4.0.3) (2022-01-15)
7
25
 
8
26
  **Note:** Version bump only for package alp-node
@@ -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} from 'alp-types';\nimport Koa from 'koa';\nimport type { ParameterizedContext, DefaultState } 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}\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 _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":";;;;;;;;;;;;;AAuBA,MAAMA,MAAM,GAAG,IAAIC,MAAJ,CAAW,KAAX,CAAf;AAmBO,MAAMC,UAAN,SAAyBC,GAAzB,CAAsE;AAW3E;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;AAG5CC,MAAAA,UAAU,EAAE;AAHgC,KAA9C;AAMA,SAAKV,QAAL,GAAgBA,QAAQ,IAAK,GAAEF,cAAe,cAA9C;AACA,SAAKG,UAAL,GAAkBA,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,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;;AAjG0E;;;;"}
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;AAG5CC,MAAAA,UAAU,EAAE;AAHgC,KAA9C;AAMA,SAAKV,QAAL,GAAgBA,QAAQ,IAAK,GAAEF,cAAe,cAA9C;AACA,SAAKG,UAAL,GAAkBA,UAAU,IAAK,GAAEH,cAAe,UAAlD;AAEA,SAAKC,MAAL,GAAcY,OAAO,CAAC,IAAD,EAAOZ,MAAP,CAArB;AACA,SAAKa,OAAL,CAAab,MAAb,GAAsB,KAAKA,MAA3B;AAEAc,IAAAA,MAAM,CAAC,IAAD,CAAN;AACAC,IAAAA,QAAQ,CAAC,IAAD,CAAR;AACAC,IAAAA,SAAS,CAAC,SAAD,CAAT,CAAqB,IAArB;AAEA,SAAKC,GAAL,CAASC,QAAQ,EAAj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CAACoD,KAAP,CAAa,YAAb,EAA2B;AAAED,QAAAA;AAAF,OAA3B;AACA,YAAMA,GAAN;AACD;AACF;;AAnG0E;;;;"}
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import type { IncomingMessage, Server, ServerResponse } from 'http';
3
3
  import type { Config } from 'alp-node-config';
4
- import type { NodeApplication, NodeConfig, Context as AlpContext, ContextState } from 'alp-types';
4
+ import type { NodeApplication, NodeConfig, Context as AlpContext, ContextState, ContextRequest } from 'alp-types';
5
5
  import Koa from 'koa';
6
- import type { ParameterizedContext, DefaultState } from 'koa';
6
+ import type { ParameterizedContext, DefaultState, BaseRequest } from 'koa';
7
7
  export interface AlpNodeAppOptions {
8
8
  appDirname: string;
9
9
  packageDirname: string;
@@ -18,12 +18,15 @@ declare module 'koa' {
18
18
  }
19
19
  interface BaseContext extends AlpContext {
20
20
  }
21
+ interface BaseRequest extends ContextRequest {
22
+ }
21
23
  }
22
24
  export declare class AlpNodeApp extends Koa<ContextState> implements NodeApplication {
23
25
  dirname: string;
24
26
  certPath: string;
25
27
  publicPath: string;
26
28
  config: NodeConfig & Config;
29
+ request: BaseRequest & ContextRequest;
27
30
  _server?: Server;
28
31
  /**
29
32
  * @param {Object} [options]
@@ -1 +1 @@
1
- {"version":3,"file":"AlpNodeApp.d.ts","sourceRoot":"","sources":["../src/AlpNodeApp.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAIpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAM9C,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,OAAO,IAAI,UAAU,EACrB,YAAY,EAEb,MAAM,WAAW,CAAC;AACnB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAO9D,MAAM,WAAW,iBAAi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AwBpB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAItE,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAIlE,aAAa,CAAC,MAAM,GAAG,YAAY,EACjC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,GAClB,oBAAoB,CAAC,MAAM,CAAC;IAM/B,WAAW,IAAI,IAAI;IAInB,WAAW,IAAI,IAAI;IAInB,MAAM,IAAI,MAAM;IAIhB;;OAEG;IACH,KAAK,IAAI,IAAI;IAOP,KAAK,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;CAa7D;AAED,YAAY,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-node14.mjs","sources":["../src/fetch.ts"],"sourcesContent":["import nodeFetch from 'node-fetch';\n\ndeclare global {\n // eslint-disable-next-line vars-on-top, no-var\n var fetch: typeof nodeFetch;\n}\n\nglobal.fetch = nodeFetch;\n\n// eslint-disable-next-line unicorn/prefer-export-from\nexport default nodeFetch;\n"],"names":["global","fetch","nodeFetch"],"mappings":";;;AAOAA,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":";;;AAGAA,MAAM,CAACC,KAAP,GAAeC,SAAf"}
package/dist/fetch.d.ts CHANGED
@@ -1,6 +1,3 @@
1
1
  import nodeFetch from 'node-fetch';
2
- declare global {
3
- var fetch: typeof nodeFetch;
4
- }
5
2
  export default nodeFetch;
6
3
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,KAAK,EAAE,OAAO,SAAS,CAAC;CAC7B;AAKD,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAMnC,eAAe,SAAS,CAAC"}
@@ -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} from 'alp-types';\nimport Koa from 'koa';\nimport type { ParameterizedContext, DefaultState } 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}\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 _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":";;;;;;;;;;;;;;;;AAuBA,MAAMA,QAAM,GAAG,IAAIC,MAAJ,CAAW,KAAX,CAAf;AAmBO,MAAMC,UAAN,SAAyBC,GAAzB,CAAsE;AAW3E;AACF;AACA;AACA;AACA;AACEC,EAAAA,WAAW,CAAC;AACVC,IAAAA,UADU;AAEVC,IAAAA,cAFU;AAGVC,IAAAA,MAHU;AAI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AAb,EAAqB;AAAEnD,EAAAA,UAAF;AAAcC,EAAAA;AAAd,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\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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,CAAa,OAAb;AAE1B,MAAMC,WAAW,GAAG3C,IAAI,CAAC0C,OAAL,CAAa,cAAb,CAApB;;AACA,IAAI,CAACC,WAAL,EAAkB;AAChB,QAAM,IAAIf,KAAJ,CAAW,iCAAgCgB,MAAM,CAACD,WAAD,CAAc,GAA/D,CAAN;AACD;;MACYhD,cAAc,GAAGK,IAAI,CAACD,OAAL,CAAa4C,WAAb;AAE9BtD,MAAM,CAACwD,KAAP,CAAa,MAAb,EAAqB;AAAEnD,EAAAA,UAAF;AAAcC,EAAAA;AAAd,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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alp-node",
3
- "version": "4.0.3",
3
+ "version": "4.1.0",
4
4
  "description": "framework based on koa 2",
5
5
  "keywords": [
6
6
  "springbokjs",
@@ -61,12 +61,13 @@
61
61
  },
62
62
  "sideEffects": false,
63
63
  "scripts": {
64
- "build": "pob-build && yarn run build:definitions",
64
+ "build": "yarn clean:build && rollup --config rollup.config.mjs && yarn run build:definitions",
65
65
  "build:definitions": "tsc -p tsconfig.build.json",
66
- "clean": "rm -Rf dist",
66
+ "clean": "yarn clean:build",
67
+ "clean:build": "rm -Rf dist",
67
68
  "lint": "yarn run lint:eslint",
68
69
  "lint:eslint": "cd ../.. && yarn run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/alp-node",
69
- "watch": "pob-watch"
70
+ "watch": "yarn clean:build && rollup --config rollup.config.mjs --watch"
70
71
  },
71
72
  "prettier": {
72
73
  "trailingComma": "all",
@@ -91,27 +92,28 @@
91
92
  },
92
93
  "dependencies": {
93
94
  "@types/koa": "^2.13.1",
94
- "@types/node-fetch": "^2.5.8",
95
- "alp-listen": "5.0.0",
96
- "alp-node-config": "7.0.0",
97
- "alp-node-errors": "6.0.0",
98
- "alp-node-language": "5.1.0",
99
- "alp-params": "4.1.0",
100
- "alp-translate": "6.0.1",
101
- "alp-types": "^3.0.0",
95
+ "@types/node": ">=14.0.0",
96
+ "@types/node-fetch": "^3.0.3",
97
+ "alp-listen": "5.0.1",
98
+ "alp-node-config": "7.0.1",
99
+ "alp-node-errors": "6.0.1",
100
+ "alp-node-language": "5.1.1",
101
+ "alp-params": "4.2.0",
102
+ "alp-translate": "6.0.2",
103
+ "alp-types": "3.1.0",
102
104
  "koa": "^2.13.1",
103
105
  "koa-compress": "^5.0.0",
104
106
  "koa-static": "^5.0.0",
105
- "nightingale-logger": "^12.1.2",
106
- "node-fetch": "^2.6.1"
107
+ "nightingale-logger": "^12.1.4",
108
+ "node-fetch": "^3.2.0"
107
109
  },
108
110
  "devDependencies": {
109
- "@babel/core": "7.16.7",
111
+ "@babel/core": "7.17.0",
110
112
  "@types/koa-compress": "4.0.3",
111
113
  "@types/koa-static": "4.0.2",
112
114
  "@types/minimist": "1.2.2",
113
- "pob-babel": "29.6.1",
114
- "typescript": "4.5.4"
115
+ "pob-babel": "31.0.0",
116
+ "typescript": "4.5.5"
115
117
  },
116
- "gitHead": "a69797c459e219e09fcf22cc2ea46aa60dce396b"
118
+ "gitHead": "1af3cf2eb4bba25ab23f174cda860416ff68a63d"
117
119
  }
package/rollup.config.mjs CHANGED
@@ -1,3 +1,5 @@
1
1
  import createRollupConfig from 'pob-babel/createRollupConfig.js';
2
2
 
3
- export default createRollupConfig({});
3
+ export default createRollupConfig({
4
+ cwd: new URL('.', import.meta.url).pathname,
5
+ });
package/src/AlpNodeApp.ts CHANGED
@@ -14,9 +14,10 @@ import type {
14
14
  Context as AlpContext,
15
15
  ContextState,
16
16
  ContextSanitizedState,
17
+ ContextRequest,
17
18
  } from 'alp-types';
18
19
  import Koa from 'koa';
19
- import type { ParameterizedContext, DefaultState } from 'koa';
20
+ import type { ParameterizedContext, DefaultState, BaseRequest } from 'koa';
20
21
  import compress from 'koa-compress';
21
22
  import serve from 'koa-static';
22
23
  import { Logger } from 'nightingale-logger';
@@ -38,6 +39,8 @@ declare module 'koa' {
38
39
  interface DefaultContext extends AlpContext {}
39
40
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
40
41
  interface BaseContext extends AlpContext {}
42
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-shadow
43
+ interface BaseRequest extends ContextRequest {}
41
44
  }
42
45
 
43
46
  export class AlpNodeApp extends Koa<ContextState> implements NodeApplication {
@@ -49,6 +52,8 @@ export class AlpNodeApp extends Koa<ContextState> implements NodeApplication {
49
52
 
50
53
  config: NodeConfig & Config;
51
54
 
55
+ declare request: BaseRequest & ContextRequest;
56
+
52
57
  _server?: Server;
53
58
 
54
59
  /**
package/src/fetch.ts CHANGED
@@ -1,10 +1,6 @@
1
1
  import nodeFetch from 'node-fetch';
2
2
 
3
- declare global {
4
- // eslint-disable-next-line vars-on-top, no-var
5
- var fetch: typeof nodeFetch;
6
- }
7
-
3
+ // @ts-expect-error -- node-fetch does not exactly match dom api
8
4
  global.fetch = nodeFetch;
9
5
 
10
6
  // eslint-disable-next-line unicorn/prefer-export-from
package/AlpNodeApp.js DELETED
@@ -1 +0,0 @@
1
- export * from './dist/AlpNodeApp-node14.mjs';
package/fetch.js DELETED
@@ -1,2 +0,0 @@
1
- // eslint-disable-next-line no-restricted-exports
2
- export { default } from './dist/fetch-node14.mjs';