@adonisjs/core 6.1.5-2 → 6.1.5-21
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 +30 -3
- package/build/commands/configure.js +103 -25
- package/build/commands/eject.d.ts +4 -0
- package/build/commands/eject.js +16 -8
- package/build/commands/generate_key.d.ts +4 -0
- package/build/commands/generate_key.js +15 -8
- package/build/commands/inspect_rcfile.d.ts +9 -0
- package/build/commands/inspect_rcfile.js +36 -0
- package/build/commands/list/routes.d.ts +23 -0
- package/build/commands/list/routes.js +29 -13
- package/build/commands/main.d.ts +4 -0
- package/build/commands/make/command.d.ts +7 -1
- package/build/commands/make/command.js +20 -7
- package/build/commands/make/controller.d.ts +10 -1
- package/build/commands/make/controller.js +35 -14
- package/build/commands/make/event.d.ts +7 -1
- package/build/commands/make/event.js +20 -8
- package/build/commands/make/exception.d.ts +14 -0
- package/build/commands/make/exception.js +37 -0
- package/build/commands/make/listener.d.ts +8 -1
- package/build/commands/make/listener.js +28 -12
- package/build/commands/make/middleware.d.ts +8 -1
- package/build/commands/make/middleware.js +21 -8
- package/build/commands/make/preload.d.ts +22 -0
- package/build/commands/make/preload.js +99 -0
- package/build/commands/make/provider.d.ts +7 -1
- package/build/commands/make/provider.js +28 -8
- package/build/commands/make/service.d.ts +14 -0
- package/build/commands/make/service.js +37 -0
- package/build/commands/make/test.d.ts +10 -1
- package/build/commands/make/test.js +46 -10
- package/build/commands/make/validator.d.ts +14 -0
- package/build/commands/make/validator.js +37 -0
- package/build/commands/make/view.d.ts +14 -0
- package/build/commands/make/view.js +37 -0
- 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 +23 -1
- package/build/index.d.ts +6 -2
- package/build/index.js +14 -1
- package/build/modules/ace/codemods.d.ts +54 -0
- package/build/modules/ace/codemods.js +133 -0
- package/build/modules/ace/commands.d.ts +48 -0
- package/build/modules/ace/commands.js +54 -0
- package/build/modules/ace/create_kernel.d.ts +9 -0
- package/build/modules/ace/create_kernel.js +32 -1
- package/build/modules/ace/kernel.d.ts +4 -0
- package/build/modules/ace/kernel.js +12 -0
- package/build/modules/ace/main.js +8 -0
- 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 +4 -0
- package/build/modules/hash/define_config.js +23 -0
- package/build/modules/hash/drivers/argon.d.ts +1 -0
- package/build/modules/hash/drivers/argon.js +9 -0
- package/build/modules/hash/drivers/bcrypt.d.ts +1 -0
- package/build/modules/hash/drivers/bcrypt.js +9 -0
- package/build/modules/hash/drivers/scrypt.d.ts +1 -0
- package/build/modules/hash/drivers/scrypt.js +9 -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 +34 -0
- package/build/modules/http/request_validator.js +66 -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/edge_provider.d.ts +31 -0
- package/build/providers/edge_provider.js +69 -0
- package/build/providers/hash_provider.d.ts +22 -2
- package/build/providers/hash_provider.js +49 -7
- 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 +98 -0
- package/build/providers/vinejs_provider.d.ts +33 -0
- package/build/providers/vinejs_provider.js +84 -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/cli_formatters/routes_list.d.ts +24 -1
- package/build/src/cli_formatters/routes_list.js +118 -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 +1 -1
- package/build/src/helpers/main.js +9 -1
- package/build/src/helpers/parse_binding_reference.d.ts +40 -0
- package/build/src/helpers/parse_binding_reference.js +60 -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 +114 -16
- 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 +65 -4
- package/build/src/types.js +8 -0
- package/build/stubs/main.js +10 -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/stubs/make/validator/main.stub +5 -0
- package/build/stubs/make/view/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.d.ts +7 -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 +83 -121
- package/build/commands/make/_base.d.ts +0 -6
- package/build/commands/make/_base.js +0 -19
- 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
- package/build/stubs/index.js +0 -2
- /package/build/stubs/{index.d.ts → main.d.ts} +0 -0
package/build/modules/config.js
CHANGED
package/build/modules/env.js
CHANGED
package/build/modules/events.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { HashDriversList } from '../../src/types.js';
|
|
2
2
|
import type { ManagerDriverFactory } from '../../types/hash.js';
|
|
3
|
+
/**
|
|
4
|
+
* Define config for the hash service.
|
|
5
|
+
*/
|
|
3
6
|
export declare function defineConfig<KnownHashers extends Record<string, {
|
|
4
7
|
[K in keyof HashDriversList]: {
|
|
5
8
|
driver: K;
|
|
@@ -9,6 +12,7 @@ export declare function defineConfig<KnownHashers extends Record<string, {
|
|
|
9
12
|
list: KnownHashers;
|
|
10
13
|
}): {
|
|
11
14
|
default?: keyof KnownHashers;
|
|
15
|
+
driversInUse: Set<keyof HashDriversList>;
|
|
12
16
|
list: {
|
|
13
17
|
[K in keyof KnownHashers]: ManagerDriverFactory;
|
|
14
18
|
};
|
|
@@ -1,18 +1,41 @@
|
|
|
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 { InvalidArgumentsException } from '@poppinss/utils';
|
|
2
10
|
import driversCollection from './drivers_collection.js';
|
|
11
|
+
/**
|
|
12
|
+
* Define config for the hash service.
|
|
13
|
+
*/
|
|
3
14
|
export function defineConfig(config) {
|
|
15
|
+
/**
|
|
16
|
+
* Hashers list should always be provided
|
|
17
|
+
*/
|
|
4
18
|
if (!config.list) {
|
|
5
19
|
throw new InvalidArgumentsException('Missing "list" property in hash config');
|
|
6
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* The default hasher should be mentioned in the list
|
|
23
|
+
*/
|
|
7
24
|
if (config.default && !config.list[config.default]) {
|
|
8
25
|
throw new InvalidArgumentsException(`Missing "list.${String(config.default)}" in hash config. It is referenced by the "default" property`);
|
|
9
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Converting list config to a collection that hash manager can use
|
|
29
|
+
*/
|
|
30
|
+
const driversInUse = new Set();
|
|
10
31
|
const managerHashers = Object.keys(config.list).reduce((result, disk) => {
|
|
11
32
|
const hasherConfig = config.list[disk];
|
|
33
|
+
driversInUse.add(hasherConfig.driver);
|
|
12
34
|
result[disk] = () => driversCollection.create(hasherConfig.driver, hasherConfig);
|
|
13
35
|
return result;
|
|
14
36
|
}, {});
|
|
15
37
|
return {
|
|
38
|
+
driversInUse,
|
|
16
39
|
default: config.default,
|
|
17
40
|
list: managerHashers,
|
|
18
41
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@adonisjs/hash/drivers/argon';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@adonisjs/hash/drivers/bcrypt';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@adonisjs/hash/drivers/scrypt';
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import { Argon, Bcrypt, Scrypt } from './main.js';
|
|
2
1
|
import type { HashDriversList } from '../../src/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A global collection of Hash drivers
|
|
4
|
+
*/
|
|
3
5
|
declare class HashDriversCollection {
|
|
6
|
+
/**
|
|
7
|
+
* List of registered drivers
|
|
8
|
+
*/
|
|
4
9
|
list: Partial<HashDriversList>;
|
|
10
|
+
/**
|
|
11
|
+
* Extend drivers collection and add a custom
|
|
12
|
+
* driver to it.
|
|
13
|
+
*/
|
|
5
14
|
extend<Name extends keyof HashDriversList>(driverName: Name, factoryCallback: HashDriversList[Name]): this;
|
|
6
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Creates the driver instance with config
|
|
17
|
+
*/
|
|
18
|
+
create<Name extends keyof HashDriversList>(name: Name, config: Parameters<HashDriversList[Name]>[0]): import("@adonisjs/hash/drivers/bcrypt").Bcrypt | import("@adonisjs/hash/drivers/argon").Argon | import("@adonisjs/hash/drivers/scrypt").Scrypt;
|
|
7
19
|
}
|
|
8
|
-
declare const
|
|
9
|
-
export default
|
|
20
|
+
declare const _default: HashDriversCollection;
|
|
21
|
+
export default _default;
|
|
@@ -1,15 +1,39 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* This class exists in the core, because it maintains a list of
|
|
11
|
+
* globally available drivers applicable to the hash manager
|
|
12
|
+
* instance registered with the container.
|
|
13
|
+
*
|
|
14
|
+
* In other words, these drivers are not needed by the hash module
|
|
15
|
+
* regular usage and specific to AdonisJS container flow.
|
|
16
|
+
*/
|
|
2
17
|
import { RuntimeException } from '@poppinss/utils';
|
|
18
|
+
/**
|
|
19
|
+
* A global collection of Hash drivers
|
|
20
|
+
*/
|
|
3
21
|
class HashDriversCollection {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
22
|
+
/**
|
|
23
|
+
* List of registered drivers
|
|
24
|
+
*/
|
|
25
|
+
list = {};
|
|
26
|
+
/**
|
|
27
|
+
* Extend drivers collection and add a custom
|
|
28
|
+
* driver to it.
|
|
29
|
+
*/
|
|
9
30
|
extend(driverName, factoryCallback) {
|
|
10
31
|
this.list[driverName] = factoryCallback;
|
|
11
32
|
return this;
|
|
12
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates the driver instance with config
|
|
36
|
+
*/
|
|
13
37
|
create(name, config) {
|
|
14
38
|
const driverFactory = this.list[name];
|
|
15
39
|
if (!driverFactory) {
|
|
@@ -18,5 +42,4 @@ class HashDriversCollection {
|
|
|
18
42
|
return driverFactory(config);
|
|
19
43
|
}
|
|
20
44
|
}
|
|
21
|
-
|
|
22
|
-
export default hashDriversCollection;
|
|
45
|
+
export default new HashDriversCollection();
|
|
@@ -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,34 @@
|
|
|
1
|
+
import type { VineValidator } from '@vinejs/vine';
|
|
2
|
+
import type { Infer, SchemaTypes, ErrorReporterContract, MessagesProviderContact } from '@vinejs/vine/types';
|
|
3
|
+
import type { HttpContext } from './main.js';
|
|
4
|
+
import type { RequestValidationOptions } from '../../types/http.js';
|
|
5
|
+
/**
|
|
6
|
+
* Request validator is used validate HTTP request data using
|
|
7
|
+
* VineJS validators. You may validate the request body,
|
|
8
|
+
* files, cookies, and headers.
|
|
9
|
+
*/
|
|
10
|
+
export declare class RequestValidator {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(ctx: HttpContext);
|
|
13
|
+
/**
|
|
14
|
+
* The error reporter method returns the error reporter
|
|
15
|
+
* to use for reporting errors.
|
|
16
|
+
*
|
|
17
|
+
* You can use this function to pick a different error reporter
|
|
18
|
+
* for each HTTP request
|
|
19
|
+
*/
|
|
20
|
+
static errorReporter?: (_: HttpContext) => ErrorReporterContract;
|
|
21
|
+
/**
|
|
22
|
+
* The messages provider method returns the messages provider to use
|
|
23
|
+
* finding custom error messages
|
|
24
|
+
*
|
|
25
|
+
* You can use this function to pick a different messages provider for
|
|
26
|
+
* each HTTP request
|
|
27
|
+
*/
|
|
28
|
+
static messagesProvider?: (_: HttpContext) => MessagesProviderContact;
|
|
29
|
+
/**
|
|
30
|
+
* The validate method can be used to validate the request
|
|
31
|
+
* data for the current request using VineJS validators
|
|
32
|
+
*/
|
|
33
|
+
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>>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* Request validator is used validate HTTP request data using
|
|
11
|
+
* VineJS validators. You may validate the request body,
|
|
12
|
+
* files, cookies, and headers.
|
|
13
|
+
*/
|
|
14
|
+
export class RequestValidator {
|
|
15
|
+
#ctx;
|
|
16
|
+
constructor(ctx) {
|
|
17
|
+
this.#ctx = ctx;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The error reporter method returns the error reporter
|
|
21
|
+
* to use for reporting errors.
|
|
22
|
+
*
|
|
23
|
+
* You can use this function to pick a different error reporter
|
|
24
|
+
* for each HTTP request
|
|
25
|
+
*/
|
|
26
|
+
static errorReporter;
|
|
27
|
+
/**
|
|
28
|
+
* The messages provider method returns the messages provider to use
|
|
29
|
+
* finding custom error messages
|
|
30
|
+
*
|
|
31
|
+
* You can use this function to pick a different messages provider for
|
|
32
|
+
* each HTTP request
|
|
33
|
+
*/
|
|
34
|
+
static messagesProvider;
|
|
35
|
+
/**
|
|
36
|
+
* The validate method can be used to validate the request
|
|
37
|
+
* data for the current request using VineJS validators
|
|
38
|
+
*/
|
|
39
|
+
validateUsing(validator, ...[options]) {
|
|
40
|
+
const validatorOptions = options || {};
|
|
41
|
+
/**
|
|
42
|
+
* Assign request specific error reporter
|
|
43
|
+
*/
|
|
44
|
+
if (RequestValidator.errorReporter) {
|
|
45
|
+
const errorReporter = RequestValidator.errorReporter(this.#ctx);
|
|
46
|
+
validatorOptions.errorReporter = () => errorReporter;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Assign request specific messages provider
|
|
50
|
+
*/
|
|
51
|
+
if (RequestValidator.messagesProvider) {
|
|
52
|
+
validatorOptions.messagesProvider = RequestValidator.messagesProvider(this.#ctx);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Data to validate
|
|
56
|
+
*/
|
|
57
|
+
const data = validatorOptions.data || {
|
|
58
|
+
...this.#ctx.request.all(),
|
|
59
|
+
...this.#ctx.request.allFiles(),
|
|
60
|
+
params: this.#ctx.request.params(),
|
|
61
|
+
headers: this.#ctx.request.headers(),
|
|
62
|
+
cookies: this.#ctx.request.cookiesList(),
|
|
63
|
+
};
|
|
64
|
+
return validator.validate(data, validatorOptions);
|
|
65
|
+
}
|
|
66
|
+
}
|
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
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Edge } from 'edge.js';
|
|
2
|
+
import type { ApplicationService } from '../src/types.js';
|
|
3
|
+
import { type Route } from '../modules/http/main.js';
|
|
4
|
+
declare module '@adonisjs/core/http' {
|
|
5
|
+
interface HttpContext {
|
|
6
|
+
/**
|
|
7
|
+
* Reference to the edge renderer to render templates
|
|
8
|
+
* during an HTTP request
|
|
9
|
+
*/
|
|
10
|
+
view: ReturnType<Edge['createRenderer']>;
|
|
11
|
+
}
|
|
12
|
+
interface BriskRoute {
|
|
13
|
+
/**
|
|
14
|
+
* Render an edge template without defining an
|
|
15
|
+
* explicit route handler
|
|
16
|
+
*/
|
|
17
|
+
render(template: string, data?: Record<string, any>): Route;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The Edge service provider configures Edge to work within
|
|
22
|
+
* an AdonisJS application environment
|
|
23
|
+
*/
|
|
24
|
+
export default class EdgeServiceProvider {
|
|
25
|
+
protected app: ApplicationService;
|
|
26
|
+
constructor(app: ApplicationService);
|
|
27
|
+
/**
|
|
28
|
+
* Bridge AdonisJS and Edge
|
|
29
|
+
*/
|
|
30
|
+
boot(): Promise<void>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 edge from 'edge.js';
|
|
10
|
+
import { BriskRoute, HttpContext } from '../modules/http/main.js';
|
|
11
|
+
/**
|
|
12
|
+
* The Edge service provider configures Edge to work within
|
|
13
|
+
* an AdonisJS application environment
|
|
14
|
+
*/
|
|
15
|
+
export default class EdgeServiceProvider {
|
|
16
|
+
app;
|
|
17
|
+
constructor(app) {
|
|
18
|
+
this.app = app;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Bridge AdonisJS and Edge
|
|
22
|
+
*/
|
|
23
|
+
async boot() {
|
|
24
|
+
const app = this.app;
|
|
25
|
+
const router = await this.app.container.make('router');
|
|
26
|
+
function edgeConfigResolver(key, defaultValue) {
|
|
27
|
+
return app.config.get(key, defaultValue);
|
|
28
|
+
}
|
|
29
|
+
edgeConfigResolver.has = function (key) {
|
|
30
|
+
return app.config.has(key);
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Mount the default disk
|
|
34
|
+
*/
|
|
35
|
+
edge.mount(app.viewsPath());
|
|
36
|
+
/**
|
|
37
|
+
* Cache templates in production
|
|
38
|
+
*/
|
|
39
|
+
edge.configure({ cache: app.inProduction });
|
|
40
|
+
/**
|
|
41
|
+
* Define Edge global helpers
|
|
42
|
+
*/
|
|
43
|
+
edge.global('route', function (...args) {
|
|
44
|
+
return router.makeUrl(...args);
|
|
45
|
+
});
|
|
46
|
+
edge.global('signedRoute', function (...args) {
|
|
47
|
+
return router.makeSignedUrl(...args);
|
|
48
|
+
});
|
|
49
|
+
edge.global('app', app);
|
|
50
|
+
edge.global('config', edgeConfigResolver);
|
|
51
|
+
/**
|
|
52
|
+
* Creating a isolated instance of edge renderer
|
|
53
|
+
*/
|
|
54
|
+
HttpContext.getter('view', function () {
|
|
55
|
+
return edge.createRenderer().share({
|
|
56
|
+
request: this.request,
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Adding brisk route to render templates without an
|
|
61
|
+
* explicit handler
|
|
62
|
+
*/
|
|
63
|
+
BriskRoute.macro('render', function (template, data) {
|
|
64
|
+
return this.setHandler(({ view }) => {
|
|
65
|
+
return view.render(template, data);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|