@adonisjs/core 6.1.5-1 → 6.1.5-10
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/build/commands/build.d.ts +10 -0
- package/build/commands/build.js +65 -22
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.d.ts +36 -0
- package/build/commands/configure.js +84 -6
- package/build/commands/eject.d.ts +4 -0
- package/build/commands/eject.js +14 -7
- package/build/commands/generate_key.d.ts +4 -0
- package/build/commands/generate_key.js +14 -7
- package/build/commands/inspect_rcfile.d.ts +9 -0
- package/build/commands/inspect_rcfile.js +20 -0
- package/build/commands/list/routes.d.ts +36 -0
- package/build/commands/list/routes.js +94 -0
- package/build/commands/make/_base.d.ts +31 -1
- package/build/commands/make/_base.js +18 -10
- package/build/commands/make/command.d.ts +6 -0
- package/build/commands/make/command.js +15 -5
- package/build/commands/make/controller.d.ts +9 -0
- package/build/commands/make/controller.js +30 -11
- package/build/commands/make/event.d.ts +6 -0
- package/build/commands/make/event.js +15 -5
- package/build/commands/make/exception.d.ts +14 -0
- package/build/commands/make/exception.js +35 -0
- package/build/commands/make/listener.d.ts +7 -0
- package/build/commands/make/listener.js +20 -7
- package/build/commands/make/middleware.d.ts +7 -0
- package/build/commands/make/middleware.js +16 -5
- package/build/commands/make/preload.d.ts +22 -0
- package/build/commands/make/preload.js +95 -0
- package/build/commands/make/provider.d.ts +6 -0
- package/build/commands/make/provider.js +22 -6
- package/build/commands/make/service.d.ts +14 -0
- package/build/commands/make/service.js +35 -0
- package/build/commands/make/test.d.ts +9 -0
- package/build/commands/make/test.js +41 -7
- package/build/commands/repl.d.ts +14 -0
- package/build/commands/repl.js +30 -0
- package/build/commands/serve.d.ts +12 -0
- package/build/commands/serve.js +78 -27
- package/build/commands/test.d.ts +32 -0
- package/build/commands/test.js +203 -0
- package/build/factories/app.js +8 -0
- package/build/factories/bodyparser.js +8 -0
- package/build/factories/core/ace.d.ts +4 -1
- package/build/factories/core/ace.js +11 -0
- package/build/factories/core/ignitor.d.ts +20 -1
- package/build/factories/core/ignitor.js +35 -1
- package/build/factories/core/main.js +8 -0
- package/build/factories/core/test_utils.d.ts +4 -1
- package/build/factories/core/test_utils.js +11 -0
- package/build/factories/encryption.js +8 -0
- package/build/factories/events.js +8 -0
- package/build/factories/hash.js +8 -0
- package/build/factories/http.js +8 -0
- package/build/factories/logger.js +8 -0
- package/build/factories/stubs.d.ts +10 -0
- package/build/factories/stubs.js +21 -0
- package/build/index.d.ts +5 -1
- package/build/index.js +13 -0
- package/build/modules/ace/commands.d.ts +123 -0
- package/build/modules/ace/commands.js +79 -0
- package/build/modules/ace/create_kernel.d.ts +9 -0
- package/build/modules/ace/create_kernel.js +31 -0
- package/build/modules/ace/kernel.d.ts +4 -0
- package/build/modules/ace/kernel.js +12 -0
- package/build/modules/ace/main.d.ts +1 -1
- package/build/modules/ace/main.js +9 -1
- package/build/modules/ace/shell.d.ts +9 -1
- package/build/modules/ace/shell.js +21 -0
- package/build/modules/app.js +8 -0
- package/build/modules/bodyparser/bodyparser_middleware.d.ts +4 -0
- package/build/modules/bodyparser/bodyparser_middleware.js +12 -0
- package/build/modules/bodyparser/main.js +8 -0
- package/build/modules/config.js +8 -0
- package/build/modules/container.js +8 -0
- package/build/modules/encryption.js +8 -0
- package/build/modules/env.js +8 -0
- package/build/modules/events.js +8 -0
- package/build/modules/hash/define_config.d.ts +3 -0
- package/build/modules/hash/define_config.js +20 -0
- package/build/modules/hash/drivers_collection.d.ts +16 -4
- package/build/modules/hash/drivers_collection.js +31 -8
- package/build/modules/hash/main.d.ts +1 -0
- package/build/modules/hash/main.js +9 -0
- package/build/modules/http/main.d.ts +2 -0
- package/build/modules/http/main.js +10 -0
- package/build/modules/http/request_validator.d.ts +44 -0
- package/build/modules/http/request_validator.js +74 -0
- package/build/modules/logger.js +8 -0
- package/build/modules/repl.d.ts +1 -0
- package/build/modules/repl.js +9 -0
- package/build/providers/app_provider.d.ts +31 -2
- package/build/providers/app_provider.js +44 -15
- package/build/providers/hash_provider.d.ts +16 -0
- package/build/providers/hash_provider.js +31 -6
- package/build/providers/http_provider.d.ts +17 -0
- package/build/providers/http_provider.js +26 -1
- package/build/providers/repl_provider.d.ts +13 -0
- package/build/providers/repl_provider.js +37 -0
- package/build/services/ace.js +15 -0
- package/build/services/app.d.ts +8 -0
- package/build/services/app.js +16 -0
- package/build/services/config.js +11 -0
- package/build/services/emitter.js +13 -2
- package/build/services/encryption.js +13 -2
- package/build/services/hash.js +13 -2
- package/build/services/logger.js +13 -2
- package/build/services/repl.d.ts +3 -0
- package/build/services/repl.js +18 -0
- package/build/services/router.js +13 -2
- package/build/services/server.js +13 -2
- package/build/services/test_utils.js +15 -0
- package/build/src/bindings/repl.d.ts +6 -0
- package/build/src/bindings/repl.js +78 -0
- package/build/src/cli_formatters/routes_list.d.ts +63 -0
- package/build/src/cli_formatters/routes_list.js +376 -0
- package/build/src/debug.d.ts +1 -1
- package/build/src/debug.js +8 -0
- package/build/src/exceptions.d.ts +1 -0
- package/build/src/exceptions.js +9 -0
- package/build/src/helpers/is.js +8 -0
- package/build/src/helpers/main.d.ts +2 -0
- package/build/src/helpers/main.js +10 -0
- package/build/src/helpers/parse_binding_reference.d.ts +45 -0
- package/build/src/helpers/parse_binding_reference.js +83 -0
- package/build/src/helpers/string.d.ts +26 -0
- package/build/src/helpers/string.js +15 -0
- package/build/src/helpers/types.d.ts +7 -2
- package/build/src/helpers/types.js +13 -0
- package/build/src/ignitor/ace.d.ts +12 -0
- package/build/src/ignitor/ace.js +50 -1
- package/build/src/ignitor/http.d.ts +9 -2
- package/build/src/ignitor/http.js +67 -0
- package/build/src/ignitor/main.d.ts +29 -1
- package/build/src/ignitor/main.js +56 -0
- package/build/src/ignitor/test.d.ts +10 -0
- package/build/src/ignitor/test.js +25 -0
- package/build/src/internal_helpers.d.ts +12 -5
- package/build/src/internal_helpers.js +35 -7
- package/build/src/test_utils/http.d.ts +10 -2
- package/build/src/test_utils/http.js +19 -0
- package/build/src/test_utils/main.d.ts +21 -3
- package/build/src/test_utils/main.js +27 -1
- package/build/src/types.d.ts +61 -3
- package/build/src/types.js +8 -0
- package/build/src/vinejs/extensions/main.d.ts +1 -0
- package/build/src/vinejs/extensions/main.js +9 -0
- package/build/src/vinejs/extensions/validates_files.d.ts +22 -0
- package/build/src/vinejs/extensions/validates_files.js +76 -0
- package/build/stubs/index.js +8 -0
- package/build/stubs/make/exception/main.stub +10 -0
- package/build/stubs/make/preload_file/main.stub +4 -0
- package/build/stubs/make/service/main.stub +4 -0
- package/build/toolkit/commands/index_commands.d.ts +4 -0
- package/build/toolkit/commands/index_commands.js +13 -5
- package/build/toolkit/main.js +11 -0
- package/build/types/ace.js +8 -0
- package/build/types/app.js +8 -0
- package/build/types/bodyparser.js +8 -0
- package/build/types/container.js +8 -0
- package/build/types/encryption.js +8 -0
- package/build/types/events.js +8 -0
- package/build/types/hash.js +8 -0
- package/build/types/http.js +8 -0
- package/build/types/logger.js +8 -0
- package/build/types/repl.d.ts +1 -0
- package/build/types/repl.js +9 -0
- package/package.json +74 -121
- package/build/legacy/validator.d.ts +0 -1
- package/build/legacy/validator.js +0 -1
- package/build/modules/http.d.ts +0 -1
- package/build/modules/http.js +0 -1
- package/build/src/helpers/string_builder.d.ts +0 -23
- package/build/src/helpers/string_builder.js +0 -86
|
@@ -1,2 +1,11 @@
|
|
|
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
|
+
*/
|
|
1
9
|
export * from '@adonisjs/hash';
|
|
2
10
|
export { defineConfig } from './define_config.js';
|
|
11
|
+
export { default as driversList } from './drivers_collection.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
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/http-server';
|
|
10
|
+
export { RequestValidator } from './request_validator.js';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type VineValidator } from '@vinejs/vine';
|
|
2
|
+
import type { Infer, SchemaTypes, ValidationOptions, ErrorReporterContract, MessagesProviderContact } from '@vinejs/vine/types';
|
|
3
|
+
import { type HttpContext } from '@adonisjs/http-server';
|
|
4
|
+
/**
|
|
5
|
+
* Request validation options with custom data as well
|
|
6
|
+
*/
|
|
7
|
+
type RequestValidationOptions<MetaData extends undefined | Record<string, any>> = ValidationOptions<MetaData> & {
|
|
8
|
+
data?: any;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Request validator is used validate HTTP request data using
|
|
12
|
+
* VineJS validators. You may validate the request body,
|
|
13
|
+
* files, cookies, and headers.
|
|
14
|
+
*/
|
|
15
|
+
export declare class RequestValidator {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(ctx: HttpContext);
|
|
18
|
+
/**
|
|
19
|
+
* The error reporter method returns the error reporter
|
|
20
|
+
* to use for reporting errors.
|
|
21
|
+
*
|
|
22
|
+
* You can use this function to pick a different error reporter
|
|
23
|
+
* for each HTTP request
|
|
24
|
+
*/
|
|
25
|
+
static errorReporter?: (_: HttpContext) => ErrorReporterContract;
|
|
26
|
+
/**
|
|
27
|
+
* The messages provider method returns the messages provider to use
|
|
28
|
+
* finding custom error messages
|
|
29
|
+
*
|
|
30
|
+
* You can use this function to pick a different messages provider for
|
|
31
|
+
* each HTTP request
|
|
32
|
+
*/
|
|
33
|
+
static messagesProvider?: (_: HttpContext) => MessagesProviderContact;
|
|
34
|
+
/**
|
|
35
|
+
* The validate method can be used to validate the request
|
|
36
|
+
* data for the current request using VineJS validators
|
|
37
|
+
*/
|
|
38
|
+
validateUsing<Schema extends SchemaTypes, MetaData extends undefined | Record<string, any>>(validator: VineValidator<Schema, MetaData>, ...[options]: [undefined] extends MetaData ? [options?: RequestValidationOptions<MetaData> | undefined] : [options: RequestValidationOptions<MetaData>]): Promise<Infer<Schema>>;
|
|
39
|
+
}
|
|
40
|
+
declare module '@adonisjs/http-server' {
|
|
41
|
+
interface Request extends RequestValidator {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
import { Request } from '@adonisjs/http-server';
|
|
10
|
+
/**
|
|
11
|
+
* Request validator is used validate HTTP request data using
|
|
12
|
+
* VineJS validators. You may validate the request body,
|
|
13
|
+
* files, cookies, and headers.
|
|
14
|
+
*/
|
|
15
|
+
export class RequestValidator {
|
|
16
|
+
#ctx;
|
|
17
|
+
constructor(ctx) {
|
|
18
|
+
this.#ctx = ctx;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The error reporter method returns the error reporter
|
|
22
|
+
* to use for reporting errors.
|
|
23
|
+
*
|
|
24
|
+
* You can use this function to pick a different error reporter
|
|
25
|
+
* for each HTTP request
|
|
26
|
+
*/
|
|
27
|
+
static errorReporter;
|
|
28
|
+
/**
|
|
29
|
+
* The messages provider method returns the messages provider to use
|
|
30
|
+
* finding custom error messages
|
|
31
|
+
*
|
|
32
|
+
* You can use this function to pick a different messages provider for
|
|
33
|
+
* each HTTP request
|
|
34
|
+
*/
|
|
35
|
+
static messagesProvider;
|
|
36
|
+
/**
|
|
37
|
+
* The validate method can be used to validate the request
|
|
38
|
+
* data for the current request using VineJS validators
|
|
39
|
+
*/
|
|
40
|
+
validateUsing(validator, ...[options]) {
|
|
41
|
+
const validatorOptions = options || {};
|
|
42
|
+
/**
|
|
43
|
+
* Assign request specific error reporter
|
|
44
|
+
*/
|
|
45
|
+
if (RequestValidator.errorReporter) {
|
|
46
|
+
const errorReporter = RequestValidator.errorReporter(this.#ctx);
|
|
47
|
+
validatorOptions.errorReporter = () => errorReporter;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Assign request specific messages provider
|
|
51
|
+
*/
|
|
52
|
+
if (RequestValidator.messagesProvider) {
|
|
53
|
+
validatorOptions.messagesProvider = RequestValidator.messagesProvider(this.#ctx);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Data to validate
|
|
57
|
+
*/
|
|
58
|
+
const data = validatorOptions.data || {
|
|
59
|
+
...this.#ctx.request.all(),
|
|
60
|
+
...this.#ctx.request.allFiles(),
|
|
61
|
+
params: this.#ctx.request.params(),
|
|
62
|
+
headers: this.#ctx.request.headers(),
|
|
63
|
+
cookies: this.#ctx.request.cookiesList(),
|
|
64
|
+
};
|
|
65
|
+
return validator.validate(data, validatorOptions);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The validate method can be used to validate the request
|
|
70
|
+
* data for the current request using VineJS validators
|
|
71
|
+
*/
|
|
72
|
+
Request.macro('validateUsing', function (...args) {
|
|
73
|
+
return new RequestValidator(this.ctx).validateUsing(...args);
|
|
74
|
+
});
|
package/build/modules/logger.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@adonisjs/repl';
|
|
@@ -1,16 +1,45 @@
|
|
|
1
1
|
import type { ApplicationService } from '../src/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The Application Service provider registers all the baseline
|
|
4
|
+
* features required to run the framework.
|
|
5
|
+
*/
|
|
2
6
|
export default class AppServiceProvider {
|
|
3
7
|
protected app: ApplicationService;
|
|
4
8
|
constructor(app: ApplicationService);
|
|
9
|
+
/**
|
|
10
|
+
* Registers test utils with the container
|
|
11
|
+
*/
|
|
5
12
|
protected registerTestUtils(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Registers ace with the container
|
|
15
|
+
*/
|
|
6
16
|
protected registerAce(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Registers the application to the container
|
|
19
|
+
*/
|
|
7
20
|
protected registerApp(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Registers the logger class to resolve the default logger
|
|
23
|
+
*/
|
|
8
24
|
protected registerLogger(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Registers the logger manager to the container
|
|
27
|
+
*/
|
|
9
28
|
protected registerLoggerManager(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Registers the config to the container
|
|
31
|
+
*/
|
|
10
32
|
protected registerConfig(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Registers emitter service to the container
|
|
35
|
+
*/
|
|
11
36
|
protected registerEmitter(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Register the encryption service to the container
|
|
39
|
+
*/
|
|
12
40
|
protected registerEncryption(): void;
|
|
13
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Registers bindings
|
|
43
|
+
*/
|
|
14
44
|
register(): void;
|
|
15
|
-
boot(): Promise<void>;
|
|
16
45
|
}
|
|
@@ -1,52 +1,85 @@
|
|
|
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
|
+
*/
|
|
1
9
|
import { Config } from '../modules/config.js';
|
|
2
|
-
import {
|
|
3
|
-
import { validator } from '../legacy/validator.js';
|
|
10
|
+
import { Logger } from '../modules/logger.js';
|
|
4
11
|
import { Encryption } from '../modules/encryption.js';
|
|
5
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The Application Service provider registers all the baseline
|
|
14
|
+
* features required to run the framework.
|
|
15
|
+
*/
|
|
6
16
|
export default class AppServiceProvider {
|
|
7
17
|
app;
|
|
8
18
|
constructor(app) {
|
|
9
19
|
this.app = app;
|
|
10
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Registers test utils with the container
|
|
23
|
+
*/
|
|
11
24
|
registerTestUtils() {
|
|
12
25
|
this.app.container.singleton('testUtils', async () => {
|
|
13
26
|
const { TestUtils } = await import('../src/test_utils/main.js');
|
|
14
27
|
return new TestUtils(this.app);
|
|
15
28
|
});
|
|
16
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Registers ace with the container
|
|
32
|
+
*/
|
|
17
33
|
registerAce() {
|
|
18
34
|
this.app.container.singleton('ace', async () => {
|
|
19
35
|
const { createAceKernel } = await import('../modules/ace/create_kernel.js');
|
|
20
36
|
return createAceKernel(this.app);
|
|
21
37
|
});
|
|
22
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Registers the application to the container
|
|
41
|
+
*/
|
|
23
42
|
registerApp() {
|
|
24
43
|
this.app.container.singleton('app', () => this.app);
|
|
25
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Registers the logger class to resolve the default logger
|
|
47
|
+
*/
|
|
26
48
|
registerLogger() {
|
|
27
49
|
this.app.container.singleton(Logger, async (resolver) => {
|
|
28
50
|
const loggerManager = await resolver.make('logger');
|
|
29
51
|
return loggerManager.use();
|
|
30
52
|
});
|
|
31
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Registers the logger manager to the container
|
|
56
|
+
*/
|
|
32
57
|
registerLoggerManager() {
|
|
33
|
-
|
|
34
|
-
|
|
58
|
+
this.app.container.singleton('logger', async () => {
|
|
59
|
+
const { LoggerManager } = await import('../modules/logger.js');
|
|
35
60
|
const config = this.app.config.get('logger');
|
|
36
61
|
return new LoggerManager(config);
|
|
37
62
|
});
|
|
38
|
-
this.app.container.alias('logger', LoggerServiceManager);
|
|
39
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Registers the config to the container
|
|
66
|
+
*/
|
|
40
67
|
registerConfig() {
|
|
41
68
|
this.app.container.singleton(Config, () => this.app.config);
|
|
42
69
|
this.app.container.alias('config', Config);
|
|
43
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Registers emitter service to the container
|
|
73
|
+
*/
|
|
44
74
|
registerEmitter() {
|
|
45
|
-
this.app.container.singleton(
|
|
75
|
+
this.app.container.singleton('emitter', async () => {
|
|
76
|
+
const { Emitter } = await import('../modules/events.js');
|
|
46
77
|
return new Emitter(this.app);
|
|
47
78
|
});
|
|
48
|
-
this.app.container.alias('emitter', Emitter);
|
|
49
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Register the encryption service to the container
|
|
82
|
+
*/
|
|
50
83
|
registerEncryption() {
|
|
51
84
|
this.app.container.singleton(Encryption, () => {
|
|
52
85
|
const appKey = this.app.config.get('app.appKey');
|
|
@@ -54,10 +87,9 @@ export default class AppServiceProvider {
|
|
|
54
87
|
});
|
|
55
88
|
this.app.container.alias('encryption', Encryption);
|
|
56
89
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
90
|
+
/**
|
|
91
|
+
* Registers bindings
|
|
92
|
+
*/
|
|
61
93
|
register() {
|
|
62
94
|
this.registerApp();
|
|
63
95
|
this.registerAce();
|
|
@@ -68,7 +100,4 @@ export default class AppServiceProvider {
|
|
|
68
100
|
this.registerEncryption();
|
|
69
101
|
this.registerTestUtils();
|
|
70
102
|
}
|
|
71
|
-
async boot() {
|
|
72
|
-
await this.configureValidator();
|
|
73
|
-
}
|
|
74
103
|
}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import type { ApplicationService } from '../src/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Registers the passwords hasher with the container
|
|
4
|
+
*/
|
|
2
5
|
export default class HashServiceProvider {
|
|
3
6
|
protected app: ApplicationService;
|
|
4
7
|
constructor(app: ApplicationService);
|
|
8
|
+
/**
|
|
9
|
+
* Registering bundled drivers with the driversList collection
|
|
10
|
+
*/
|
|
5
11
|
protected registerHashDrivers(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Registering the hash class to resolve an instance with the
|
|
14
|
+
* default hasher.
|
|
15
|
+
*/
|
|
6
16
|
protected registerHash(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Registers the hash manager with the container
|
|
19
|
+
*/
|
|
7
20
|
protected registerHashManager(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Registers bindings
|
|
23
|
+
*/
|
|
8
24
|
register(): void;
|
|
9
25
|
}
|
|
@@ -1,29 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
import { Argon, Bcrypt, Hash, Scrypt, driversList } from '../modules/hash/main.js';
|
|
10
|
+
/**
|
|
11
|
+
* Registers the passwords hasher with the container
|
|
12
|
+
*/
|
|
3
13
|
export default class HashServiceProvider {
|
|
4
14
|
app;
|
|
5
15
|
constructor(app) {
|
|
6
16
|
this.app = app;
|
|
7
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Registering bundled drivers with the driversList collection
|
|
20
|
+
*/
|
|
8
21
|
registerHashDrivers() {
|
|
9
|
-
|
|
22
|
+
driversList.extend('bcrypt', (config) => new Bcrypt(config));
|
|
23
|
+
driversList.extend('scrypt', (config) => new Scrypt(config));
|
|
24
|
+
driversList.extend('argon2', (config) => new Argon(config));
|
|
10
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Registering the hash class to resolve an instance with the
|
|
28
|
+
* default hasher.
|
|
29
|
+
*/
|
|
11
30
|
registerHash() {
|
|
12
31
|
this.app.container.singleton(Hash, async (resolver) => {
|
|
13
32
|
const hashManager = await resolver.make('hash');
|
|
14
33
|
return hashManager.use();
|
|
15
34
|
});
|
|
16
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Registers the hash manager with the container
|
|
38
|
+
*/
|
|
17
39
|
registerHashManager() {
|
|
18
|
-
this.app.container.singleton(
|
|
40
|
+
this.app.container.singleton('hash', async () => {
|
|
41
|
+
const { HashManager } = await import('../modules/hash/main.js');
|
|
19
42
|
const config = this.app.config.get('hash');
|
|
20
43
|
return new HashManager(config);
|
|
21
44
|
});
|
|
22
|
-
this.app.container.alias('hash', HashManager);
|
|
23
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Registers bindings
|
|
48
|
+
*/
|
|
24
49
|
register() {
|
|
25
|
-
this.registerHashManager();
|
|
26
50
|
this.registerHashDrivers();
|
|
51
|
+
this.registerHashManager();
|
|
27
52
|
this.registerHash();
|
|
28
53
|
}
|
|
29
54
|
}
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import type { ApplicationService } from '../src/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Http Service provider binds the router and the HTTP server to
|
|
4
|
+
* the container.
|
|
5
|
+
*/
|
|
2
6
|
export default class HttpServiceProvider {
|
|
3
7
|
protected app: ApplicationService;
|
|
4
8
|
constructor(app: ApplicationService);
|
|
9
|
+
/**
|
|
10
|
+
* Registers the HTTP server with the container as a singleton
|
|
11
|
+
*/
|
|
5
12
|
protected registerServer(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Registers router with the container as a singleton
|
|
15
|
+
*/
|
|
6
16
|
protected registerRouter(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Self construct bodyparser middleware class, since it needs
|
|
19
|
+
* config that cannot be resolved by the container
|
|
20
|
+
*/
|
|
7
21
|
protected registerBodyParserMiddleware(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Registers bindings
|
|
24
|
+
*/
|
|
8
25
|
register(): void;
|
|
9
26
|
}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
|
|
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
|
+
import { Router, Server } from '../modules/http/main.js';
|
|
2
10
|
import BodyParserMiddleware from '../modules/bodyparser/bodyparser_middleware.js';
|
|
11
|
+
/**
|
|
12
|
+
* Http Service provider binds the router and the HTTP server to
|
|
13
|
+
* the container.
|
|
14
|
+
*/
|
|
3
15
|
export default class HttpServiceProvider {
|
|
4
16
|
app;
|
|
5
17
|
constructor(app) {
|
|
6
18
|
this.app = app;
|
|
7
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Registers the HTTP server with the container as a singleton
|
|
22
|
+
*/
|
|
8
23
|
registerServer() {
|
|
9
24
|
this.app.container.singleton(Server, async (resolver) => {
|
|
10
25
|
const encryption = await resolver.make('encryption');
|
|
@@ -15,6 +30,9 @@ export default class HttpServiceProvider {
|
|
|
15
30
|
});
|
|
16
31
|
this.app.container.alias('server', Server);
|
|
17
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Registers router with the container as a singleton
|
|
35
|
+
*/
|
|
18
36
|
registerRouter() {
|
|
19
37
|
this.app.container.singleton(Router, async (resolver) => {
|
|
20
38
|
const server = await resolver.make('server');
|
|
@@ -22,12 +40,19 @@ export default class HttpServiceProvider {
|
|
|
22
40
|
});
|
|
23
41
|
this.app.container.alias('router', Router);
|
|
24
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Self construct bodyparser middleware class, since it needs
|
|
45
|
+
* config that cannot be resolved by the container
|
|
46
|
+
*/
|
|
25
47
|
registerBodyParserMiddleware() {
|
|
26
48
|
this.app.container.bind(BodyParserMiddleware, () => {
|
|
27
49
|
const config = this.app.config.get('bodyparser');
|
|
28
50
|
return new BodyParserMiddleware(config);
|
|
29
51
|
});
|
|
30
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Registers bindings
|
|
55
|
+
*/
|
|
31
56
|
register() {
|
|
32
57
|
this.registerServer();
|
|
33
58
|
this.registerRouter();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ApplicationService } from '../src/types.js';
|
|
2
|
+
export default class ReplServiceProvider {
|
|
3
|
+
protected app: ApplicationService;
|
|
4
|
+
constructor(app: ApplicationService);
|
|
5
|
+
/**
|
|
6
|
+
* Registers the REPL binding
|
|
7
|
+
*/
|
|
8
|
+
register(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Registering REPL bindings during provider boot
|
|
11
|
+
*/
|
|
12
|
+
boot(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import { join } from 'node:path';
|
|
10
|
+
import { homedir } from 'node:os';
|
|
11
|
+
export default class ReplServiceProvider {
|
|
12
|
+
app;
|
|
13
|
+
constructor(app) {
|
|
14
|
+
this.app = app;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Registers the REPL binding
|
|
18
|
+
*/
|
|
19
|
+
register() {
|
|
20
|
+
this.app.container.singleton('repl', async () => {
|
|
21
|
+
const { Repl } = await import('../modules/repl.js');
|
|
22
|
+
return new Repl({
|
|
23
|
+
historyFilePath: join(homedir(), '.adonisjs_v6_repl_history'),
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Registering REPL bindings during provider boot
|
|
29
|
+
*/
|
|
30
|
+
async boot() {
|
|
31
|
+
if (this.app.getEnvironment() === 'repl') {
|
|
32
|
+
const repl = await this.app.container.make('repl');
|
|
33
|
+
const { defineReplBindings } = await import('../src/bindings/repl.js');
|
|
34
|
+
defineReplBindings(this.app, repl);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
package/build/services/ace.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
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
|
+
*/
|
|
1
9
|
import app from './app.js';
|
|
2
10
|
let ace;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a singleton instance of the ace kernel
|
|
13
|
+
* from the container.
|
|
14
|
+
*
|
|
15
|
+
* ace service is an instance of the "Kernel" class stored inside
|
|
16
|
+
* the "modules/ace/kernel.ts" file
|
|
17
|
+
*/
|
|
3
18
|
await app.booted(async () => {
|
|
4
19
|
ace = await app.container.make('ace');
|
|
5
20
|
});
|
package/build/services/app.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { ApplicationService } from '../src/types.js';
|
|
2
2
|
declare let app: ApplicationService;
|
|
3
|
+
/**
|
|
4
|
+
* Set the application instance the app service should
|
|
5
|
+
* be using. Other services relies on the same app
|
|
6
|
+
* instance as well.
|
|
7
|
+
*
|
|
8
|
+
* app service is an instance of the "Application" exported from
|
|
9
|
+
* the "modules/app.ts" file.
|
|
10
|
+
*/
|
|
3
11
|
export declare function setApp(appService: ApplicationService): void;
|
|
4
12
|
export { app as default };
|
package/build/services/app.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
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
|
+
*/
|
|
1
9
|
let app;
|
|
10
|
+
/**
|
|
11
|
+
* Set the application instance the app service should
|
|
12
|
+
* be using. Other services relies on the same app
|
|
13
|
+
* instance as well.
|
|
14
|
+
*
|
|
15
|
+
* app service is an instance of the "Application" exported from
|
|
16
|
+
* the "modules/app.ts" file.
|
|
17
|
+
*/
|
|
2
18
|
export function setApp(appService) {
|
|
3
19
|
app = appService;
|
|
4
20
|
}
|
package/build/services/config.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
*/
|
|
1
9
|
import app from './app.js';
|
|
2
10
|
let config;
|
|
11
|
+
/**
|
|
12
|
+
* The config service uses the config instance from the app service
|
|
13
|
+
*/
|
|
3
14
|
await app.booted(() => {
|
|
4
15
|
config = app.config;
|
|
5
16
|
});
|
|
@@ -1,7 +1,18 @@
|
|
|
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
|
+
*/
|
|
1
9
|
import app from './app.js';
|
|
2
|
-
import { Emitter } from '../modules/events.js';
|
|
3
10
|
let emitter;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a singleton instance of the emitter class
|
|
13
|
+
* from the container
|
|
14
|
+
*/
|
|
4
15
|
await app.booted(async () => {
|
|
5
|
-
emitter = await app.container.make(
|
|
16
|
+
emitter = await app.container.make('emitter');
|
|
6
17
|
});
|
|
7
18
|
export { emitter as default };
|
|
@@ -1,7 +1,18 @@
|
|
|
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
|
+
*/
|
|
1
9
|
import app from './app.js';
|
|
2
|
-
import { Encryption } from '../modules/encryption.js';
|
|
3
10
|
let encryption;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a singleton instance of the encryption class
|
|
13
|
+
* from the container
|
|
14
|
+
*/
|
|
4
15
|
await app.booted(async () => {
|
|
5
|
-
encryption = await app.container.make(
|
|
16
|
+
encryption = await app.container.make('encryption');
|
|
6
17
|
});
|
|
7
18
|
export { encryption as default };
|