alp-node 5.2.0 → 6.0.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,19 @@
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
+ ## [6.0.0](https://github.com/christophehurpeau/alp/compare/alp-node@5.2.0...alp-node@6.0.0) (2023-07-29)
7
+
8
+
9
+ ### ⚠ BREAKING CHANGES
10
+
11
+ * drop node 16
12
+
13
+ ### Code Refactoring
14
+
15
+ * update to node 18 ([26280d6](https://github.com/christophehurpeau/alp/commit/26280d638aba1bd46fa42ad5a571b9626f1fff6d))
16
+
17
+
18
+
6
19
  ## [5.2.0](https://github.com/christophehurpeau/alp/compare/alp-node@5.1.2...alp-node@5.2.0) (2023-03-19)
7
20
 
8
21
 
@@ -1,5 +1,5 @@
1
- import path from 'path';
2
- import { deprecate } from 'util';
1
+ import path from 'node:path';
2
+ import { deprecate } from 'node:util';
3
3
  import _listen from 'alp-listen';
4
4
  import _config from 'alp-node-config';
5
5
  import errors from 'alp-node-errors';
@@ -59,6 +59,8 @@ class AlpNodeApp extends Koa {
59
59
  catchErrors() {
60
60
  this.use(errors);
61
61
  }
62
+
63
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
62
64
  listen() {
63
65
  throw new Error('Use start instead');
64
66
  }
@@ -80,14 +82,14 @@ class AlpNodeApp extends Koa {
80
82
  logger.success('started');
81
83
  if (process.send) process.send('ready');
82
84
  return server;
83
- } catch (err) {
85
+ } catch (error) {
84
86
  logger.error('start fail', {
85
- err
87
+ err: error
86
88
  });
87
- throw err;
89
+ throw error;
88
90
  }
89
91
  }
90
92
  }
91
93
 
92
94
  export { AlpNodeApp };
93
- //# sourceMappingURL=AlpNodeApp-node16.mjs.map
95
+ //# sourceMappingURL=AlpNodeApp-node18.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlpNodeApp-node18.mjs","sources":["../src/AlpNodeApp.ts"],"sourcesContent":["import type { IncomingMessage, Server, ServerResponse } from 'node:http';\nimport path from 'node:path';\nimport { deprecate } from 'node: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: Config & NodeConfig;\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 // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n listen(): never {\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 (error: unknown) {\n logger.error('start fail', { err: error });\n throw error;\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","error","err"],"mappings":";;;;;;;;;;;;;AAwBA,MAAMA,MAAM,GAAG,IAAIC,MAAM,CAAC,KAAK,CAAC,CAAA;AAqBzB,MAAMC,UAAU,SAASC,GAAG,CAA0C;AAa3E;A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d,CAAC,OAAOM,KAAc,EAAE;AACvBnD,MAAAA,MAAM,CAACmD,KAAK,CAAC,YAAY,EAAE;AAAEC,QAAAA,GAAG,EAAED,KAAAA;AAAM,OAAC,CAAC,CAAA;AAC1C,MAAA,MAAMA,KAAK,CAAA;AACb,KAAA;AACF,GAAA;AACF;;;;"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { IncomingMessage, Server, ServerResponse } from 'http';
2
+ import type { IncomingMessage, Server, ServerResponse } from 'node:http';
3
3
  import type { Config } from 'alp-node-config';
4
4
  import type { NodeApplication, NodeConfig, Context as AlpContext, ContextState, ContextRequest } from 'alp-types';
5
5
  import Koa from 'koa';
@@ -25,7 +25,7 @@ export declare class AlpNodeApp extends Koa<ContextState> implements NodeApplica
25
25
  dirname: string;
26
26
  certPath: string;
27
27
  publicPath: string;
28
- config: NodeConfig & Config;
28
+ config: Config & NodeConfig;
29
29
  request: BaseRequest & ContextRequest;
30
30
  _server?: Server;
31
31
  /**
@@ -39,7 +39,7 @@ export declare class AlpNodeApp extends Koa<ContextState> implements NodeApplica
39
39
  createContext<StateT = DefaultState>(req: IncomingMessage, res: ServerResponse): ParameterizedContext<StateT>;
40
40
  servePublic(): void;
41
41
  catchErrors(): void;
42
- listen(): Server;
42
+ listen(): never;
43
43
  /**
44
44
  * Close server and emit close event
45
45
  */
@@ -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,EAEZ,cAAc,EACf,MAAM,WAAW,CAAC;AACnB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO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EpB,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC;IAE9C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;gBACS,EACV,UAAU,EACV,cAAc,EACd,MAAM,EACN,QAAQ,EACR,UAAU,GACX,EAAE,iBAAiB;IAwBpB,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;IAKnB,MAAM,IAAI,KAAK;IAIf;;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,14 +1,13 @@
1
1
  import { Config } from 'alp-node-config';
2
2
  import type { AlpNodeAppOptions } from './AlpNodeApp';
3
3
  import { AlpNodeApp } from './AlpNodeApp';
4
- export { default as fetch } from 'node-fetch';
5
4
  export type { Context } from './AlpNodeApp';
6
5
  export { Config } from 'alp-node-config';
7
6
  export declare const appDirname: string;
8
7
  export declare const packageDirname: string;
9
8
  export declare const packageConfig: Record<string, unknown>;
10
9
  export declare const config: Config & import("alp-types").NodeConfig;
11
- export type AppOptions = Omit<AlpNodeAppOptions, 'appDirname' | 'packageDirname' | 'config'>;
10
+ export type AppOptions = Omit<AlpNodeAppOptions, 'appDirname' | 'config' | 'packageDirname'>;
12
11
  export default class App extends AlpNodeApp {
13
12
  constructor(options?: AppOptions);
14
13
  }
@@ -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;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,MAAM,MAAM,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,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,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,iBAAiB,EACjB,YAAY,GAAG,QAAQ,GAAG,gBAAgB,CAC3C,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,UAAU;gBAC7B,OAAO,CAAC,EAAE,UAAU;CAQjC"}
@@ -1,9 +1,9 @@
1
- import { readFileSync, existsSync } from 'fs';
2
- import path from 'path';
1
+ import { readFileSync, existsSync } from 'node:fs';
2
+ import path from 'node:path';
3
3
  import _config, { Config } from 'alp-node-config';
4
4
  export { Config } from 'alp-node-config';
5
5
  import { Logger } from 'nightingale-logger';
6
- import { deprecate } from 'util';
6
+ import { deprecate } from 'node:util';
7
7
  import _listen from 'alp-listen';
8
8
  import errors from 'alp-node-errors';
9
9
  import language from 'alp-node-language';
@@ -12,7 +12,6 @@ import translate from 'alp-translate';
12
12
  import Koa from 'koa';
13
13
  import compress from 'koa-compress';
14
14
  import serve from 'koa-static';
15
- export { default as fetch } from 'node-fetch';
16
15
 
17
16
  const logger$1 = new Logger('alp');
18
17
  class AlpNodeApp extends Koa {
@@ -62,6 +61,8 @@ class AlpNodeApp extends Koa {
62
61
  catchErrors() {
63
62
  this.use(errors);
64
63
  }
64
+
65
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
65
66
  listen() {
66
67
  throw new Error('Use start instead');
67
68
  }
@@ -83,11 +84,11 @@ class AlpNodeApp extends Koa {
83
84
  logger$1.success('started');
84
85
  if (process.send) process.send('ready');
85
86
  return server;
86
- } catch (err) {
87
+ } catch (error) {
87
88
  logger$1.error('start fail', {
88
- err
89
+ err: error
89
90
  });
90
- throw err;
91
+ throw error;
91
92
  }
92
93
  }
93
94
  }
@@ -121,4 +122,4 @@ class App extends AlpNodeApp {
121
122
  }
122
123
 
123
124
  export { appDirname, config, App as default, packageConfig, packageDirname };
124
- //# sourceMappingURL=index-node16.mjs.map
125
+ //# sourceMappingURL=index-node18.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-node18.mjs","sources":["../src/AlpNodeApp.ts","../src/index.ts"],"sourcesContent":["import type { IncomingMessage, Server, ServerResponse } from 'node:http';\nimport path from 'node:path';\nimport { deprecate } from 'node: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: Config & NodeConfig;\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 // eslint-disable-next-line @typescript-eslint/class-methods-use-this\n listen(): never {\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 (error: unknown) {\n logger.error('start fail', { err: error });\n throw error;\n }\n }\n}\n\nexport type { Context } from 'koa';\n","import { existsSync, readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { Config } from 'alp-node-config';\nimport { Logger } from 'nightingale-logger';\nimport type { AlpNodeAppOptions } from './AlpNodeApp';\nimport { AlpNodeApp } from './AlpNodeApp';\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, 'utf8'),\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' | 'config' | 'packageDirname'\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","error","err","resolve","packagePath","String","debug","packageConfig","JSON","parse","readFileSync","buildedConfigPath","configPath","existsSync","Config","loadSync","App","options"],"mappings":";;;;;;;;;;;;;;;AAwBA,MAAMA,QAAM,GAAG,IAAIC,MAAM,CAAC,KAAK,CAAC,CAAA;AAqBzB,MAAMC,UAAU,SAASC,GAAG,CAA0C;AAa3E;AACF;AACA;AACA;AACA;AACEC,EAAAA,WAAWA,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,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WAAW,GAAG3C,IAAI,CAAC0C,OAAO,CAAC,cAAc,CAAC,CAAA;AAChD,IAAI,CAACC,WAAW,EAAE;EAChB,MAAM,IAAIf,KAAK,CAAE,CAAA,8BAAA,EAAgCgB,MAAM,CAACD,WAAW,CAAE,CAAA,CAAA,CAAE,CAAC,CAAA;AAC1E,CAAA;AACO,MAAMhD,cAAc,GAAGK,IAAI,CAACD,OAAO,CAAC4C,WAAW,EAAC;AAEvDtD,MAAM,CAACwD,KAAK,CAAC,MAAM,EAAE;EAAEnD,UAAU;AAAEC,EAAAA,cAAAA;AAAe,CAAC,CAAC,CAAA;AAEvCmD,MAAAA,aAAsC,GAAGC,IAAI,CAACC,KAAK,CAC9DC,YAAY,CAACN,WAAW,EAAE,MAAM,CAClC,EAA4B;AAE5B,MAAMO,iBAAiB,GAAI,CAAExD,EAAAA,UAAW,CAAe,cAAA,CAAA,CAAA;AACvD,MAAMyD,UAAU,GAAGC,UAAU,CAACF,iBAAiB,CAAC,GAC5CA,iBAAiB,GAChB,CAAExD,EAAAA,UAAW,CAAS,QAAA,CAAA,CAAA;AAEpB,MAAME,MAAM,GAAG,IAAIyD,MAAM,CAACF,UAAU,CAAC,CAACG,QAAQ,CAAC;AAAER,EAAAA,aAAAA;AAAc,CAAC,EAAC;AAOzD,MAAMS,GAAG,SAAShE,UAAU,CAAC;EAC1CE,WAAWA,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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alp-node",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
4
4
  "description": "framework based on koa 2",
5
5
  "keywords": [
6
6
  "springbokjs",
@@ -22,35 +22,29 @@
22
22
  },
23
23
  "type": "module",
24
24
  "engines": {
25
- "node": ">=16.0.0"
25
+ "node": ">=18.12.0"
26
26
  },
27
- "main": "./dist/index-node16.mjs",
27
+ "main": "./dist/index-node18.mjs",
28
28
  "types": "./dist/definitions/index.d.ts",
29
29
  "typesVersions": {
30
30
  ">=3.1": {
31
31
  "AlpNodeApp": [
32
32
  "./dist/AlpNodeApp.d.ts"
33
- ],
34
- "fetch": [
35
- "./dist/fetch.d.ts"
36
33
  ]
37
34
  }
38
35
  },
39
36
  "exports": {
40
37
  "./package.json": "./package.json",
41
38
  ".": {
39
+ "types": "./dist/definitions/index.d.ts",
42
40
  "node": {
43
- "import": "./dist/index-node16.mjs"
41
+ "import": "./dist/index-node18.mjs"
44
42
  }
45
43
  },
46
44
  "./AlpNodeApp": {
45
+ "types": "./dist/definitions/index.d.ts",
47
46
  "node": {
48
- "import": "./dist/AlpNodeApp-node16.mjs"
49
- }
50
- },
51
- "./fetch": {
52
- "node": {
53
- "import": "./dist/fetch-node16.mjs"
47
+ "import": "./dist/AlpNodeApp-node18.mjs"
54
48
  }
55
49
  }
56
50
  },
@@ -69,42 +63,40 @@
69
63
  "babelEnvs": [
70
64
  {
71
65
  "target": "node",
72
- "version": "16"
66
+ "version": "18"
73
67
  }
74
68
  ],
75
69
  "entries": [
76
70
  "index",
77
- "AlpNodeApp",
78
- "fetch"
71
+ "AlpNodeApp"
79
72
  ]
80
73
  },
81
74
  "peerDependencies": {
82
- "router-segments": "^6.0.0"
75
+ "router-segments": "^7.0.0"
83
76
  },
84
77
  "dependencies": {
85
78
  "@types/koa": "^2.13.1",
86
- "@types/node": ">=16.0.0",
87
- "@types/node-fetch": "^3.0.3",
88
- "alp-listen": "6.2.0",
89
- "alp-node-config": "8.3.0",
90
- "alp-node-errors": "7.2.0",
91
- "alp-node-language": "6.2.0",
92
- "alp-params": "5.2.0",
93
- "alp-translate": "7.3.0",
79
+ "@types/node": ">=18.0.0",
80
+ "@types/node-fetch": "^2.6.4",
81
+ "alp-listen": "7.0.0",
82
+ "alp-node-config": "9.0.0",
83
+ "alp-node-errors": "8.0.0",
84
+ "alp-node-language": "7.0.0",
85
+ "alp-params": "6.0.0",
86
+ "alp-translate": "8.0.0",
94
87
  "alp-types": "3.1.0",
95
88
  "koa": "^2.13.1",
96
89
  "koa-compress": "^5.0.0",
97
90
  "koa-static": "^5.0.0",
98
- "nightingale-logger": "^13.0.0",
99
- "node-fetch": "^3.2.0"
91
+ "nightingale-logger": "^14.1.0"
100
92
  },
101
93
  "devDependencies": {
102
- "@babel/core": "7.21.3",
94
+ "@babel/core": "7.22.9",
103
95
  "@types/koa-compress": "4.0.3",
104
96
  "@types/koa-static": "4.0.2",
105
97
  "@types/minimist": "1.2.2",
106
- "pob-babel": "35.6.2",
107
- "typescript": "4.9.5"
98
+ "pob-babel": "36.2.0",
99
+ "typescript": "5.1.6"
108
100
  },
109
- "gitHead": "f7dfa98e33968879e3b16541652a316e92782259"
101
+ "gitHead": "c01392e16b2d914a332fe835333dd6a82c677ab8"
110
102
  }
package/src/AlpNodeApp.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { IncomingMessage, Server, ServerResponse } from 'http';
2
- import path from 'path';
3
- import { deprecate } from 'util';
1
+ import type { IncomingMessage, Server, ServerResponse } from 'node:http';
2
+ import path from 'node:path';
3
+ import { deprecate } from 'node:util';
4
4
  import _listen from 'alp-listen';
5
5
  import type { Config } from 'alp-node-config';
6
6
  import _config from 'alp-node-config';
@@ -50,7 +50,7 @@ export class AlpNodeApp extends Koa<ContextState> implements NodeApplication {
50
50
 
51
51
  publicPath: string;
52
52
 
53
- config: NodeConfig & Config;
53
+ config: Config & NodeConfig;
54
54
 
55
55
  declare request: BaseRequest & ContextRequest;
56
56
 
@@ -116,7 +116,8 @@ export class AlpNodeApp extends Koa<ContextState> implements NodeApplication {
116
116
  this.use(errors);
117
117
  }
118
118
 
119
- listen(): Server {
119
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
120
+ listen(): never {
120
121
  throw new Error('Use start instead');
121
122
  }
122
123
 
@@ -138,9 +139,9 @@ export class AlpNodeApp extends Koa<ContextState> implements NodeApplication {
138
139
  logger.success('started');
139
140
  if (process.send) process.send('ready');
140
141
  return server;
141
- } catch (err: unknown) {
142
- logger.error('start fail', { err });
143
- throw err;
142
+ } catch (error: unknown) {
143
+ logger.error('start fail', { err: error });
144
+ throw error;
144
145
  }
145
146
  }
146
147
  }
package/src/index.ts CHANGED
@@ -1,12 +1,10 @@
1
- import { existsSync, readFileSync } from 'fs';
2
- import path from 'path';
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
3
  import { Config } from 'alp-node-config';
4
4
  import { Logger } from 'nightingale-logger';
5
5
  import type { AlpNodeAppOptions } from './AlpNodeApp';
6
6
  import { AlpNodeApp } from './AlpNodeApp';
7
7
 
8
- export { default as fetch } from 'node-fetch';
9
-
10
8
  export type { Context } from './AlpNodeApp';
11
9
  export { Config } from 'alp-node-config';
12
10
 
@@ -35,7 +33,7 @@ export const config = new Config(configPath).loadSync({ packageConfig });
35
33
 
36
34
  export type AppOptions = Omit<
37
35
  AlpNodeAppOptions,
38
- 'appDirname' | 'packageDirname' | 'config'
36
+ 'appDirname' | 'config' | 'packageDirname'
39
37
  >;
40
38
 
41
39
  export default class App extends AlpNodeApp {
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlpNodeApp-node16.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,WAAWA,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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AC,EAAAA,MAAMA,GAAW;AACf,IAAA,MAAM,IAAIC,KAAK,CAAC,mBAAmB,CAAC,CAAA;AACtC,GAAA;;AAEA;AACF;AACA;AACEC,EAAAA,KAAKA,GAAS;IACZ,IAAI,IAAI,CAACC,OAAO,EAAE;AAChB,MAAA,IAAI,CAACA,OAAO,CAACD,KAAK,EAAE,CAAA;AACpB,MAAA,IAAI,CAACE,IAAI,CAAC,OAAO,CAAC,CAAA;AACpB,KAAA;AACF,GAAA;EAEA,MAAMC,KAAKA,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,3 +0,0 @@
1
- import nodeFetch from 'node-fetch';
2
- export default nodeFetch;
3
- //# sourceMappingURL=fetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AASnC,eAAe,SAAS,CAAC"}
@@ -1,9 +0,0 @@
1
- import nodeFetch from 'node-fetch';
2
- export { default } from 'node-fetch';
3
-
4
- // TODO remove with node 18 since is native
5
- // https://nodejs.org/en/blog/announcements/v18-release-announce/
6
-
7
- // @ts-expect-error -- node-fetch does not exactly match dom api
8
- global.fetch = nodeFetch;
9
- //# sourceMappingURL=fetch-node16.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch-node16.mjs","sources":["../src/fetch.ts"],"sourcesContent":["import nodeFetch from 'node-fetch';\n\n// TODO remove with node 18 since is native\n// https://nodejs.org/en/blog/announcements/v18-release-announce/\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;AACA;;AAEA;AACAA,MAAM,CAACC,KAAK,GAAGC,SAAS"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-node16.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, 'utf8'),\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,WAAWA,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;;;;"}
package/src/fetch.ts DELETED
@@ -1,10 +0,0 @@
1
- import nodeFetch from 'node-fetch';
2
-
3
- // TODO remove with node 18 since is native
4
- // https://nodejs.org/en/blog/announcements/v18-release-announce/
5
-
6
- // @ts-expect-error -- node-fetch does not exactly match dom api
7
- global.fetch = nodeFetch;
8
-
9
- // eslint-disable-next-line unicorn/prefer-export-from
10
- export default nodeFetch;