@adonisjs/core 6.1.5-26 → 6.1.5-28

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.
Files changed (58) hide show
  1. package/build/commands/configure.js +1 -0
  2. package/build/factories/core/ace.d.ts +1 -1
  3. package/build/factories/core/ignitor.d.ts +1 -1
  4. package/build/factories/core/ignitor.js +2 -4
  5. package/build/factories/core/main.d.ts +0 -1
  6. package/build/factories/core/main.js +0 -1
  7. package/build/factories/core/test_utils.d.ts +1 -1
  8. package/build/factories/stubs.d.ts +2 -2
  9. package/build/index.d.ts +10 -139
  10. package/build/index.js +4 -0
  11. package/build/modules/ace/codemods.d.ts +11 -6
  12. package/build/modules/ace/shell.d.ts +1 -1
  13. package/build/modules/env/editor.d.ts +1 -0
  14. package/build/modules/env/editor.js +9 -0
  15. package/build/modules/hash/define_config.d.ts +29 -13
  16. package/build/modules/hash/define_config.js +49 -14
  17. package/build/modules/hash/main.d.ts +1 -2
  18. package/build/modules/hash/main.js +1 -2
  19. package/build/modules/hash/phc_formatter.d.ts +1 -0
  20. package/build/modules/hash/phc_formatter.js +9 -0
  21. package/build/modules/http/main.js +1 -0
  22. package/build/modules/http/request_validator.js +2 -2
  23. package/build/providers/app_provider.d.ts +14 -0
  24. package/build/providers/app_provider.js +42 -0
  25. package/build/providers/edge_provider.d.ts +1 -1
  26. package/build/providers/hash_provider.d.ts +1 -9
  27. package/build/providers/hash_provider.js +11 -28
  28. package/build/providers/vinejs_provider.d.ts +1 -1
  29. package/build/src/config_provider.d.ts +9 -0
  30. package/build/src/config_provider.js +26 -0
  31. package/build/src/debug.d.ts +1 -1
  32. package/build/src/ignitor/http.d.ts +2 -2
  33. package/build/src/ignitor/main.d.ts +1 -1
  34. package/build/src/test_utils/http.d.ts +2 -2
  35. package/build/src/test_utils/main.d.ts +3 -3
  36. package/build/src/types.d.ts +12 -14
  37. package/build/stubs/make/command/main.stub +6 -4
  38. package/build/stubs/make/controller/api.stub +6 -4
  39. package/build/stubs/make/controller/main.stub +6 -4
  40. package/build/stubs/make/controller/resource.stub +6 -4
  41. package/build/stubs/make/event/main.stub +5 -3
  42. package/build/stubs/make/exception/main.stub +5 -3
  43. package/build/stubs/make/listener/for_event.stub +6 -4
  44. package/build/stubs/make/listener/main.stub +5 -3
  45. package/build/stubs/make/middleware/main.stub +7 -5
  46. package/build/stubs/make/preload_file/main.stub +5 -3
  47. package/build/stubs/make/provider/main.stub +6 -4
  48. package/build/stubs/make/service/main.stub +5 -3
  49. package/build/stubs/make/test/main.stub +5 -3
  50. package/build/stubs/make/validator/main.stub +5 -3
  51. package/build/stubs/make/view/main.stub +5 -3
  52. package/package.json +36 -34
  53. package/build/modules/hash/drivers_collection.d.ts +0 -21
  54. package/build/modules/hash/drivers_collection.js +0 -45
  55. package/build/providers/http_provider.d.ts +0 -26
  56. package/build/providers/http_provider.js +0 -61
  57. /package/build/modules/{env.d.ts → env/main.d.ts} +0 -0
  58. /package/build/modules/{env.js → env/main.js} +0 -0
@@ -61,6 +61,7 @@ export default class Configure extends BaseCommand {
61
61
  const codemods = await this.createCodemods();
62
62
  await codemods.updateRcFile((rcFile) => {
63
63
  rcFile.addProvider('@adonisjs/core/providers/edge_provider');
64
+ rcFile.addMetaFile('resources/views/**/*.edge', false);
64
65
  });
65
66
  }
66
67
  /**
@@ -1,4 +1,4 @@
1
- /// <reference types="@types/node" resolution-mode="require"/>
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  import { Ignitor } from '../../src/ignitor/main.js';
3
3
  import type { IgnitorOptions } from '../../src/types.js';
4
4
  import type { Kernel } from '../../modules/ace/kernel.js';
@@ -1,4 +1,4 @@
1
- /// <reference types="@types/node" resolution-mode="require"/>
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  import { Ignitor } from '../../src/ignitor/main.js';
3
3
  import type { ApplicationService, IgnitorOptions } from '../../src/types.js';
4
4
  type FactoryParameters = {
@@ -7,6 +7,7 @@
7
7
  * file that was distributed with this source code.
8
8
  */
9
9
  import { Ignitor } from '../../src/ignitor/main.js';
10
+ import { drivers } from '../../modules/hash/define_config.js';
10
11
  import { defineConfig as defineHttpConfig } from '../../modules/http/main.js';
11
12
  import { defineConfig as defineLoggerConfig } from '../../modules/logger.js';
12
13
  import { defineConfig as defineHashConfig } from '../../modules/hash/main.js';
@@ -35,7 +36,6 @@ export class IgnitorFactory {
35
36
  return [
36
37
  '@adonisjs/core/providers/app_provider',
37
38
  '@adonisjs/core/providers/hash_provider',
38
- '@adonisjs/core/providers/http_provider',
39
39
  '@adonisjs/core/providers/repl_provider',
40
40
  ].concat(providers || []);
41
41
  }
@@ -74,9 +74,7 @@ export class IgnitorFactory {
74
74
  hash: defineHashConfig({
75
75
  default: 'scrypt',
76
76
  list: {
77
- scrypt: {
78
- driver: 'scrypt',
79
- },
77
+ scrypt: drivers.scrypt({}),
80
78
  },
81
79
  }),
82
80
  logger: defineLoggerConfig({
@@ -1,4 +1,3 @@
1
1
  export { AceFactory } from './ace.js';
2
- export { StubsFactory } from '../stubs.js';
3
2
  export { IgnitorFactory } from './ignitor.js';
4
3
  export { TestUtilsFactory } from './test_utils.js';
@@ -7,6 +7,5 @@
7
7
  * file that was distributed with this source code.
8
8
  */
9
9
  export { AceFactory } from './ace.js';
10
- export { StubsFactory } from '../stubs.js';
11
10
  export { IgnitorFactory } from './ignitor.js';
12
11
  export { TestUtilsFactory } from './test_utils.js';
@@ -1,4 +1,4 @@
1
- /// <reference types="@types/node" resolution-mode="require"/>
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  import { Ignitor } from '../../index.js';
3
3
  import type { IgnitorOptions } from '../../src/types.js';
4
4
  import { TestUtils } from '../../src/test_utils/main.js';
@@ -16,10 +16,10 @@ export declare class StubsFactory {
16
16
  * Prepares a stub
17
17
  */
18
18
  prepare(stubPath: string, data: Record<string, any>): Promise<{
19
- contents: any;
19
+ contents: string;
20
20
  destination: any;
21
21
  force: any;
22
- attributes: any;
22
+ attributes: Record<string, any>;
23
23
  }>;
24
24
  }
25
25
  export {};
package/build/index.d.ts CHANGED
@@ -1,145 +1,16 @@
1
- /// <reference types="@types/node" resolution-mode="require"/>
1
+ import { errors as aceErrors } from '@adonisjs/ace';
2
+ import { errors as envErrors } from '@adonisjs/env';
3
+ import { errors as appErrors } from '@adonisjs/application';
4
+ import { errors as encryptionErrors } from '@adonisjs/encryption';
5
+ import { errors as httpServerErrors } from '@adonisjs/http-server';
2
6
  export { stubsRoot } from './stubs/main.js';
3
7
  export { inject } from './modules/container.js';
4
8
  export { Ignitor } from './src/ignitor/main.js';
5
- export declare const errors: {
6
- E_INVALID_ENV_VARIABLES: {
7
- new (message?: string | undefined, options?: (ErrorOptions & {
8
- code?: string | undefined;
9
- status?: number | undefined;
10
- }) | undefined): {
11
- help: string;
12
- name: string;
13
- code?: string | undefined;
14
- status: number;
15
- toString(): string;
16
- message: string;
17
- stack?: string | undefined;
18
- cause?: unknown;
19
- readonly [Symbol.toStringTag]: string;
20
- };
21
- message: string;
22
- code: string;
23
- help?: string | undefined;
24
- status?: number | undefined;
25
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
26
- prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
27
- stackTraceLimit: number;
28
- };
29
- E_COMMAND_NOT_FOUND: {
30
- new (args: [command: string]): {
31
- commandName: string;
32
- name: string;
33
- help?: string | undefined;
34
- code?: string | undefined;
35
- status: number;
36
- toString(): string;
37
- message: string;
38
- stack?: string | undefined;
39
- cause?: unknown;
40
- readonly [Symbol.toStringTag]: string;
41
- };
42
- help?: string | undefined;
43
- code?: string | undefined;
44
- status?: number | undefined;
45
- message?: string | undefined;
46
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
47
- prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
48
- stackTraceLimit: number;
49
- };
50
- E_INVALID_FLAG: new (args: [flag: string, expectedDataType: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
51
- E_MISSING_ARG: new (args: [arg: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
52
- E_MISSING_ARG_VALUE: new (args: [arg: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
53
- E_MISSING_COMMAND_NAME: new (args: [command: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
54
- E_MISSING_FLAG: new (args: [flag: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
55
- E_MISSING_FLAG_VALUE: new (args: [flag: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
56
- E_UNKNOWN_FLAG: new (args: [flag: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
57
- E_MISSING_METAFILE_PATTERN: new (args: [fileProperty: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
58
- E_MISSING_PRELOAD_FILE: new (args: [preloadProperty: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
59
- E_MISSING_PROVIDER_FILE: new (args: [preloadProperty: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
60
- E_MISSING_SUITE_NAME: new (args: [suiteProperty: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
61
- E_MISSING_SUITE_FILES: new (args: [suiteProperty: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
62
- E_MISSING_BUNDLER_DEV_COMMAND: new (args?: any, options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
63
- E_MISSING_BUNDLER_BUILD_COMMAND: new (args?: any, options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
64
- E_MISSING_BUNDLER_NAME: new (args?: any, options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
65
- E_ROUTE_NOT_FOUND: new (args: [method: string, url: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
66
- E_CANNOT_LOOKUP_ROUTE: new (args: [routeIdentifier: string], options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
67
- E_HTTP_EXCEPTION: {
68
- new (message?: string | undefined, options?: (ErrorOptions & {
69
- code?: string | undefined;
70
- status?: number | undefined;
71
- }) | undefined): {
72
- body: any;
73
- name: string;
74
- help?: string | undefined;
75
- code?: string | undefined;
76
- status: number;
77
- toString(): string;
78
- message: string;
79
- stack?: string | undefined;
80
- cause?: unknown;
81
- readonly [Symbol.toStringTag]: string;
82
- };
83
- code: string;
84
- invoke(body: any, status: number, code?: string | undefined): {
85
- body: any;
86
- name: string;
87
- help?: string | undefined;
88
- code?: string | undefined;
89
- status: number;
90
- toString(): string;
91
- message: string;
92
- stack?: string | undefined;
93
- cause?: unknown;
94
- readonly [Symbol.toStringTag]: string;
95
- };
96
- help?: string | undefined;
97
- status?: number | undefined;
98
- message?: string | undefined;
99
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
100
- prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
101
- stackTraceLimit: number;
102
- };
103
- E_HTTP_REQUEST_ABORTED: {
104
- new (message?: string | undefined, options?: (ErrorOptions & {
105
- code?: string | undefined;
106
- status?: number | undefined;
107
- }) | undefined): {
108
- handle(error: any, ctx: import("@adonisjs/http-server").HttpContext): void;
109
- body: any;
110
- name: string;
111
- help?: string | undefined;
112
- code?: string | undefined;
113
- status: number;
114
- toString(): string;
115
- message: string;
116
- stack?: string | undefined;
117
- cause?: unknown;
118
- readonly [Symbol.toStringTag]: string;
119
- };
120
- code: string;
121
- invoke(body: any, status: number, code?: string | undefined): {
122
- body: any;
123
- name: string;
124
- help?: string | undefined;
125
- code?: string | undefined;
126
- status: number;
127
- toString(): string;
128
- message: string;
129
- stack?: string | undefined;
130
- cause?: unknown;
131
- readonly [Symbol.toStringTag]: string;
132
- };
133
- help?: string | undefined;
134
- status?: number | undefined;
135
- message?: string | undefined;
136
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
137
- prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
138
- stackTraceLimit: number;
139
- };
140
- E_INSECURE_APP_KEY: new (args?: any, options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
141
- E_MISSING_APP_KEY: new (args?: any, options?: ErrorOptions | undefined) => import("@poppinss/utils").Exception;
142
- };
9
+ export { configProvider } from './src/config_provider.js';
10
+ /**
11
+ * Aggregated errors from all modules.
12
+ */
13
+ export declare const errors: typeof encryptionErrors & typeof httpServerErrors & typeof appErrors & typeof aceErrors & typeof envErrors;
143
14
  /**
144
15
  * Pretty prints an error with colorful output using
145
16
  * Youch terminal
package/build/index.js CHANGED
@@ -14,6 +14,10 @@ import { errors as httpServerErrors } from '@adonisjs/http-server';
14
14
  export { stubsRoot } from './stubs/main.js';
15
15
  export { inject } from './modules/container.js';
16
16
  export { Ignitor } from './src/ignitor/main.js';
17
+ export { configProvider } from './src/config_provider.js';
18
+ /**
19
+ * Aggregated errors from all modules.
20
+ */
17
21
  export const errors = {
18
22
  ...encryptionErrors,
19
23
  ...httpServerErrors,
@@ -31,23 +31,28 @@ export declare class Codemods {
31
31
  */
32
32
  makeUsingStub(stubsRoot: string, stubPath: string, stubState: Record<string, any>): Promise<{
33
33
  relativeFileName: string;
34
- contents: any;
34
+ contents: string; /**
35
+ * Reference to lazily imported assembler code transformer
36
+ */
35
37
  destination: any;
36
- attributes: any;
38
+ attributes: Record<string, any>;
37
39
  status: "created";
38
40
  skipReason: null;
39
41
  } | {
40
42
  relativeFileName: string;
41
- contents: any;
43
+ contents: string;
42
44
  destination: any;
43
- attributes: any;
45
+ attributes: Record<string, any>;
46
+ /**
47
+ * Reference to CLI logger to write logs
48
+ */
44
49
  status: "force_created";
45
50
  skipReason: null;
46
51
  } | {
47
52
  relativeFileName: string;
48
- contents: any;
53
+ contents: string;
49
54
  destination: any;
50
- attributes: any;
55
+ attributes: Record<string, any>;
51
56
  status: "skipped";
52
57
  skipReason: string;
53
58
  }>;
@@ -1,4 +1,4 @@
1
- /// <reference types="@types/node" resolution-mode="require"/>
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  /**
3
3
  * Ace shell is used to run the ace commands inside a TypeScript project
4
4
  * without pre-compiling TypeScript source files.
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/env/editor';
@@ -0,0 +1,9 @@
1
+ /*
2
+ * @adonisjs/core
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export * from '@adonisjs/env/editor';
@@ -1,19 +1,35 @@
1
- import type { HashDriversList } from '../../src/types.js';
2
- import type { ManagerDriverFactory } from '../../types/hash.js';
1
+ import type { Argon } from './drivers/argon.js';
2
+ import type { Scrypt } from './drivers/scrypt.js';
3
+ import type { Bcrypt } from './drivers/bcrypt.js';
4
+ import type { ConfigProvider } from '../../src/types.js';
5
+ import type { ArgonConfig, BcryptConfig, ScryptConfig, ManagerDriverFactory } from '../../types/hash.js';
3
6
  /**
4
- * Define config for the hash service.
7
+ * Resolved config from the config provider will be
8
+ * the config accepted by the hash manager
5
9
  */
6
- export declare function defineConfig<KnownHashers extends Record<string, {
7
- [K in keyof HashDriversList]: {
8
- driver: K;
9
- } & Parameters<HashDriversList[K]>[0];
10
- }[keyof HashDriversList]>>(config: {
11
- default?: keyof KnownHashers;
12
- list: KnownHashers;
13
- }): {
10
+ type ResolvedConfig<KnownHashers extends Record<string, ManagerDriverFactory | ConfigProvider<ManagerDriverFactory>>> = {
14
11
  default?: keyof KnownHashers;
15
- driversInUse: Set<keyof HashDriversList>;
16
12
  list: {
17
- [K in keyof KnownHashers]: ManagerDriverFactory;
13
+ [K in keyof KnownHashers]: KnownHashers[K] extends ConfigProvider<infer A> ? A : KnownHashers[K];
18
14
  };
19
15
  };
16
+ /**
17
+ * Define config for the hash service.
18
+ */
19
+ export declare function defineConfig<KnownHashers extends Record<string, ManagerDriverFactory | ConfigProvider<ManagerDriverFactory>>>(config: {
20
+ default?: keyof KnownHashers;
21
+ list: KnownHashers;
22
+ }): ConfigProvider<ResolvedConfig<KnownHashers>>;
23
+ /**
24
+ * Helpers to configure drivers inside the config file. The
25
+ * drivers will be imported and constructed lazily.
26
+ *
27
+ * - Import happens when you first use the hash module
28
+ * - Construction of drivers happens when you first use a driver
29
+ */
30
+ export declare const drivers: {
31
+ argon2: (config: ArgonConfig) => ConfigProvider<() => Argon>;
32
+ bcrypt: (config: BcryptConfig) => ConfigProvider<() => Bcrypt>;
33
+ scrypt: (config: ScryptConfig) => ConfigProvider<() => Scrypt>;
34
+ };
35
+ export {};
@@ -7,7 +7,8 @@
7
7
  * file that was distributed with this source code.
8
8
  */
9
9
  import { InvalidArgumentsException } from '@poppinss/utils';
10
- import driversCollection from './drivers_collection.js';
10
+ import debug from '../../src/debug.js';
11
+ import { configProvider } from '../../src/config_provider.js';
11
12
  /**
12
13
  * Define config for the hash service.
13
14
  */
@@ -25,18 +26,52 @@ export function defineConfig(config) {
25
26
  throw new InvalidArgumentsException(`Missing "list.${String(config.default)}" in hash config. It is referenced by the "default" property`);
26
27
  }
27
28
  /**
28
- * Converting list config to a collection that hash manager can use
29
+ * Config provider to lazily import drivers as they are used inside
30
+ * the user application
29
31
  */
30
- const driversInUse = new Set();
31
- const managerHashers = Object.keys(config.list).reduce((result, disk) => {
32
- const hasherConfig = config.list[disk];
33
- driversInUse.add(hasherConfig.driver);
34
- result[disk] = () => driversCollection.create(hasherConfig.driver, hasherConfig);
35
- return result;
36
- }, {});
37
- return {
38
- driversInUse,
39
- default: config.default,
40
- list: managerHashers,
41
- };
32
+ return configProvider.create(async (app) => {
33
+ debug('resolving hash config');
34
+ const hashersList = Object.keys(config.list);
35
+ const hashers = {};
36
+ for (let hasherName of hashersList) {
37
+ const hasher = config.list[hasherName];
38
+ if (typeof hasher === 'function') {
39
+ hashers[hasherName] = hasher;
40
+ }
41
+ else {
42
+ hashers[hasherName] = await hasher.resolver(app);
43
+ }
44
+ }
45
+ return {
46
+ default: config.default,
47
+ list: hashers,
48
+ };
49
+ });
42
50
  }
51
+ /**
52
+ * Helpers to configure drivers inside the config file. The
53
+ * drivers will be imported and constructed lazily.
54
+ *
55
+ * - Import happens when you first use the hash module
56
+ * - Construction of drivers happens when you first use a driver
57
+ */
58
+ export const drivers = {
59
+ argon2: (config) => {
60
+ return configProvider.create(async () => {
61
+ const { Argon } = await import('./drivers/argon.js');
62
+ return () => new Argon(config);
63
+ });
64
+ },
65
+ bcrypt: (config) => {
66
+ return configProvider.create(async () => {
67
+ const { Bcrypt } = await import('./drivers/bcrypt.js');
68
+ return () => new Bcrypt(config);
69
+ });
70
+ },
71
+ scrypt: (config) => {
72
+ return configProvider.create(async () => {
73
+ const { Scrypt } = await import('./drivers/scrypt.js');
74
+ return () => new Scrypt(config);
75
+ });
76
+ },
77
+ };
@@ -1,3 +1,2 @@
1
1
  export * from '@adonisjs/hash';
2
- export { defineConfig } from './define_config.js';
3
- export { default as driversList } from './drivers_collection.js';
2
+ export { defineConfig, drivers } from './define_config.js';
@@ -7,5 +7,4 @@
7
7
  * file that was distributed with this source code.
8
8
  */
9
9
  export * from '@adonisjs/hash';
10
- export { defineConfig } from './define_config.js';
11
- export { default as driversList } from './drivers_collection.js';
10
+ export { defineConfig, drivers } from './define_config.js';
@@ -0,0 +1 @@
1
+ export * from '@adonisjs/hash/phc_formatter';
@@ -0,0 +1,9 @@
1
+ /*
2
+ * @adonisjs/core
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export * from '@adonisjs/hash/phc_formatter';
@@ -6,5 +6,6 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
+ /// <reference types="@adonisjs/bodyparser/bodyparser_middleware" />
9
10
  export * from '@adonisjs/http-server';
10
11
  export { RequestValidator } from './request_validator.js';
@@ -41,14 +41,14 @@ export class RequestValidator {
41
41
  /**
42
42
  * Assign request specific error reporter
43
43
  */
44
- if (RequestValidator.errorReporter) {
44
+ if (RequestValidator.errorReporter && !validatorOptions.errorReporter) {
45
45
  const errorReporter = RequestValidator.errorReporter(this.#ctx);
46
46
  validatorOptions.errorReporter = () => errorReporter;
47
47
  }
48
48
  /**
49
49
  * Assign request specific messages provider
50
50
  */
51
- if (RequestValidator.messagesProvider) {
51
+ if (RequestValidator.messagesProvider && !validatorOptions.messagesProvider) {
52
52
  validatorOptions.messagesProvider = RequestValidator.messagesProvider(this.#ctx);
53
53
  }
54
54
  /**
@@ -38,8 +38,22 @@ export default class AppServiceProvider {
38
38
  * Register the encryption service to the container
39
39
  */
40
40
  protected registerEncryption(): void;
41
+ /**
42
+ * Registers the HTTP server with the container as a singleton
43
+ */
44
+ protected registerServer(): void;
45
+ /**
46
+ * Registers router with the container as a singleton
47
+ */
48
+ protected registerRouter(): void;
49
+ /**
50
+ * Self construct bodyparser middleware class, since it needs
51
+ * config that cannot be resolved by the container
52
+ */
53
+ protected registerBodyParserMiddleware(): void;
41
54
  /**
42
55
  * Registers bindings
43
56
  */
44
57
  register(): void;
58
+ boot(): Promise<void>;
45
59
  }
@@ -8,7 +8,10 @@
8
8
  */
9
9
  import { Config } from '../modules/config.js';
10
10
  import { Logger } from '../modules/logger.js';
11
+ import { BaseEvent } from '../modules/events.js';
11
12
  import { Encryption } from '../modules/encryption.js';
13
+ import { Router, Server } from '../modules/http/main.js';
14
+ import BodyParserMiddleware from '../modules/bodyparser/bodyparser_middleware.js';
12
15
  /**
13
16
  * The Application Service provider registers all the baseline
14
17
  * features required to run the framework.
@@ -87,6 +90,39 @@ export default class AppServiceProvider {
87
90
  });
88
91
  this.app.container.alias('encryption', Encryption);
89
92
  }
93
+ /**
94
+ * Registers the HTTP server with the container as a singleton
95
+ */
96
+ registerServer() {
97
+ this.app.container.singleton(Server, async (resolver) => {
98
+ const encryption = await resolver.make('encryption');
99
+ const emitter = await resolver.make('emitter');
100
+ const logger = await resolver.make('logger');
101
+ const config = this.app.config.get('app.http');
102
+ return new Server(this.app, encryption, emitter, logger, config);
103
+ });
104
+ this.app.container.alias('server', Server);
105
+ }
106
+ /**
107
+ * Registers router with the container as a singleton
108
+ */
109
+ registerRouter() {
110
+ this.app.container.singleton(Router, async (resolver) => {
111
+ const server = await resolver.make('server');
112
+ return server.getRouter();
113
+ });
114
+ this.app.container.alias('router', Router);
115
+ }
116
+ /**
117
+ * Self construct bodyparser middleware class, since it needs
118
+ * config that cannot be resolved by the container
119
+ */
120
+ registerBodyParserMiddleware() {
121
+ this.app.container.bind(BodyParserMiddleware, () => {
122
+ const config = this.app.config.get('bodyparser');
123
+ return new BodyParserMiddleware(config);
124
+ });
125
+ }
90
126
  /**
91
127
  * Registers bindings
92
128
  */
@@ -99,5 +135,11 @@ export default class AppServiceProvider {
99
135
  this.registerEmitter();
100
136
  this.registerEncryption();
101
137
  this.registerTestUtils();
138
+ this.registerServer();
139
+ this.registerRouter();
140
+ this.registerBodyParserMiddleware();
141
+ }
142
+ async boot() {
143
+ BaseEvent.useEmitter(await this.app.container.make('emitter'));
102
144
  }
103
145
  }
@@ -1,7 +1,7 @@
1
1
  import { type Edge } from 'edge.js';
2
2
  import type { ApplicationService } from '../src/types.js';
3
3
  import { type Route } from '../modules/http/main.js';
4
- declare module '@adonisjs/http-server' {
4
+ declare module '@adonisjs/core/http' {
5
5
  interface HttpContext {
6
6
  /**
7
7
  * Reference to the edge renderer to render templates
@@ -1,14 +1,10 @@
1
- import type { ApplicationService, HashDriversList } from '../src/types.js';
1
+ import type { ApplicationService } from '../src/types.js';
2
2
  /**
3
3
  * Registers the passwords hasher with the container
4
4
  */
5
5
  export default class HashServiceProvider {
6
6
  protected app: ApplicationService;
7
7
  constructor(app: ApplicationService);
8
- /**
9
- * Lazily registers a hash driver with the driversList collection
10
- */
11
- protected registerHashDrivers(driversInUse: Set<keyof HashDriversList>): Promise<void>;
12
8
  /**
13
9
  * Registering the hash class to resolve an instance with the
14
10
  * default hasher.
@@ -22,8 +18,4 @@ export default class HashServiceProvider {
22
18
  * Registers bindings
23
19
  */
24
20
  register(): void;
25
- /**
26
- * Register drivers based upon hash config
27
- */
28
- boot(): void;
29
21
  }