@adonisjs/core 6.1.5-2 → 6.1.5-20
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.js +9 -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/edge_provider.d.ts +10 -0
- package/build/providers/edge_provider.js +22 -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 +35 -0
- package/build/providers/vinejs_provider.d.ts +5 -0
- package/build/providers/vinejs_provider.js +13 -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/edge/main.d.ts +7 -0
- package/build/src/bindings/edge/main.js +58 -0
- package/build/src/bindings/edge/types.d.ts +18 -0
- package/build/src/bindings/edge/types.js +9 -0
- package/build/src/bindings/repl.d.ts +6 -0
- package/build/src/bindings/repl.js +78 -0
- package/build/src/bindings/vinejs/main.d.ts +13 -0
- package/build/src/bindings/vinejs/main.js +76 -0
- package/build/src/bindings/vinejs/types.d.ts +12 -0
- package/build/src/bindings/vinejs/types.js +9 -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.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.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/modules/{http.d.ts → http/main.d.ts} +0 -0
- /package/build/stubs/{index.d.ts → main.d.ts} +0 -0
|
@@ -1,29 +1,71 @@
|
|
|
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 { Hash, 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
|
}
|
|
8
|
-
|
|
9
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Lazily registers a hash driver with the driversList collection
|
|
20
|
+
*/
|
|
21
|
+
async registerHashDrivers(driversInUse) {
|
|
22
|
+
if (driversInUse.has('bcrypt')) {
|
|
23
|
+
const { Bcrypt } = await import('../modules/hash/drivers/bcrypt.js');
|
|
24
|
+
driversList.extend('bcrypt', (config) => new Bcrypt(config));
|
|
25
|
+
}
|
|
26
|
+
if (driversInUse.has('scrypt')) {
|
|
27
|
+
const { Scrypt } = await import('../modules/hash/drivers/scrypt.js');
|
|
28
|
+
driversList.extend('scrypt', (config) => new Scrypt(config));
|
|
29
|
+
}
|
|
30
|
+
if (driversInUse.has('argon2')) {
|
|
31
|
+
const { Argon } = await import('../modules/hash/drivers/argon.js');
|
|
32
|
+
driversList.extend('argon2', (config) => new Argon(config));
|
|
33
|
+
}
|
|
10
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Registering the hash class to resolve an instance with the
|
|
37
|
+
* default hasher.
|
|
38
|
+
*/
|
|
11
39
|
registerHash() {
|
|
12
40
|
this.app.container.singleton(Hash, async (resolver) => {
|
|
13
41
|
const hashManager = await resolver.make('hash');
|
|
14
42
|
return hashManager.use();
|
|
15
43
|
});
|
|
16
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Registers the hash manager with the container
|
|
47
|
+
*/
|
|
17
48
|
registerHashManager() {
|
|
18
|
-
this.app.container.singleton(
|
|
49
|
+
this.app.container.singleton('hash', async () => {
|
|
19
50
|
const config = this.app.config.get('hash');
|
|
51
|
+
const { HashManager } = await import('../modules/hash/main.js');
|
|
20
52
|
return new HashManager(config);
|
|
21
53
|
});
|
|
22
|
-
this.app.container.alias('hash', HashManager);
|
|
23
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Registers bindings
|
|
57
|
+
*/
|
|
24
58
|
register() {
|
|
25
59
|
this.registerHashManager();
|
|
26
|
-
this.registerHashDrivers();
|
|
27
60
|
this.registerHash();
|
|
28
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Register drivers based upon hash config
|
|
64
|
+
*/
|
|
65
|
+
boot() {
|
|
66
|
+
this.app.container.resolving('hash', async () => {
|
|
67
|
+
const config = this.app.config.get('hash');
|
|
68
|
+
await this.registerHashDrivers(config.driversInUse);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
29
71
|
}
|
|
@@ -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,35 @@
|
|
|
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
|
+
const repl = await this.app.container.make('repl');
|
|
32
|
+
const { defineReplBindings } = await import('../src/bindings/repl.js');
|
|
33
|
+
defineReplBindings(this.app, repl);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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 '../src/bindings/vinejs/main.js';
|
|
10
|
+
import '../src/bindings/vinejs/types.js';
|
|
11
|
+
import '../modules/http/request_validator.js';
|
|
12
|
+
export default class VineJSServiceProvider {
|
|
13
|
+
}
|
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 };
|
package/build/services/hash.js
CHANGED
|
@@ -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 { HashManager } from '../modules/hash/main.js';
|
|
3
10
|
let hash;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a singleton instance of the Hash manager from the
|
|
13
|
+
* container
|
|
14
|
+
*/
|
|
4
15
|
await app.booted(async () => {
|
|
5
|
-
hash = await app.container.make(
|
|
16
|
+
hash = await app.container.make('hash');
|
|
6
17
|
});
|
|
7
18
|
export { hash as default };
|
package/build/services/logger.js
CHANGED
|
@@ -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 { LoggerManager } from '@adonisjs/logger';
|
|
3
10
|
let logger;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a singleton instance of the logger class
|
|
13
|
+
* from the container
|
|
14
|
+
*/
|
|
4
15
|
await app.booted(async () => {
|
|
5
|
-
logger =
|
|
16
|
+
logger = await app.container.make('logger');
|
|
6
17
|
});
|
|
7
18
|
export { logger as default };
|
|
@@ -0,0 +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
|
+
*/
|
|
9
|
+
import app from './app.js';
|
|
10
|
+
let repl;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a singleton instance of the Repl class from
|
|
13
|
+
* the container
|
|
14
|
+
*/
|
|
15
|
+
await app.booted(async () => {
|
|
16
|
+
repl = await app.container.make('repl');
|
|
17
|
+
});
|
|
18
|
+
export { repl as default };
|
package/build/services/router.js
CHANGED
|
@@ -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 { Router } from '../modules/http.js';
|
|
3
10
|
let router;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a singleton instance of the router class from
|
|
13
|
+
* the container
|
|
14
|
+
*/
|
|
4
15
|
await app.booted(async () => {
|
|
5
|
-
router = await app.container.make(
|
|
16
|
+
router = await app.container.make('router');
|
|
6
17
|
});
|
|
7
18
|
export { router as default };
|
package/build/services/server.js
CHANGED
|
@@ -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 { Server } from '../modules/http.js';
|
|
3
10
|
let server;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a singleton instance of the HTTP server
|
|
13
|
+
* from the container
|
|
14
|
+
*/
|
|
4
15
|
await app.booted(async () => {
|
|
5
|
-
server = await app.container.make(
|
|
16
|
+
server = await app.container.make('server');
|
|
6
17
|
});
|
|
7
18
|
export { server as default };
|
|
@@ -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 testUtils;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a singleton instance of the TestUtils class
|
|
13
|
+
* from the container.
|
|
14
|
+
*
|
|
15
|
+
* testUtils service is an instance of the "TestUtils" exported from
|
|
16
|
+
* the "src/test_utils/main.ts" file.
|
|
17
|
+
*/
|
|
3
18
|
await app.booted(async () => {
|
|
4
19
|
testUtils = await app.container.make('testUtils');
|
|
5
20
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import './types.js';
|
|
2
|
+
import type { ApplicationService } from '../../types.js';
|
|
3
|
+
import { type Router } from '../../../modules/http/main.js';
|
|
4
|
+
/**
|
|
5
|
+
* Bridges AdonisJS with Edge
|
|
6
|
+
*/
|
|
7
|
+
export declare function bridgeEdgeAdonisJS(app: ApplicationService, router: Router): void;
|
|
@@ -0,0 +1,58 @@
|
|
|
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 './types.js';
|
|
11
|
+
import { HttpContext, BriskRoute } from '../../../modules/http/main.js';
|
|
12
|
+
/**
|
|
13
|
+
* Bridges AdonisJS with Edge
|
|
14
|
+
*/
|
|
15
|
+
export function bridgeEdgeAdonisJS(app, router) {
|
|
16
|
+
function edgeConfigResolver(key, defaultValue) {
|
|
17
|
+
return app.config.get(key, defaultValue);
|
|
18
|
+
}
|
|
19
|
+
edgeConfigResolver.has = function (key) {
|
|
20
|
+
return app.config.has(key);
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Mount the default disk
|
|
24
|
+
*/
|
|
25
|
+
edge.mount(app.viewsPath());
|
|
26
|
+
/**
|
|
27
|
+
* Cache templates in production
|
|
28
|
+
*/
|
|
29
|
+
edge.configure({ cache: app.inProduction });
|
|
30
|
+
/**
|
|
31
|
+
* Define Edge global helpers
|
|
32
|
+
*/
|
|
33
|
+
edge.global('route', function (...args) {
|
|
34
|
+
return router.makeUrl(...args);
|
|
35
|
+
});
|
|
36
|
+
edge.global('signedRoute', function (...args) {
|
|
37
|
+
return router.makeSignedUrl(...args);
|
|
38
|
+
});
|
|
39
|
+
edge.global('app', app);
|
|
40
|
+
edge.global('config', edgeConfigResolver);
|
|
41
|
+
/**
|
|
42
|
+
* Creating a isolated instance of edge renderer
|
|
43
|
+
*/
|
|
44
|
+
HttpContext.getter('view', function () {
|
|
45
|
+
return edge.createRenderer().share({
|
|
46
|
+
request: this.request,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Adding brisk route to render templates without an
|
|
51
|
+
* explicit handler
|
|
52
|
+
*/
|
|
53
|
+
BriskRoute.macro('render', function (template, data) {
|
|
54
|
+
return this.setHandler(({ view }) => {
|
|
55
|
+
return view.render(template, data);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Edge } from 'edge.js';
|
|
2
|
+
import type { Route } from '../../../modules/http/main.js';
|
|
3
|
+
declare module '@adonisjs/http-server' {
|
|
4
|
+
interface HttpContext {
|
|
5
|
+
/**
|
|
6
|
+
* Reference to the edge renderer to render templates
|
|
7
|
+
* during an HTTP request
|
|
8
|
+
*/
|
|
9
|
+
view: ReturnType<Edge['createRenderer']>;
|
|
10
|
+
}
|
|
11
|
+
interface BriskRoute {
|
|
12
|
+
/**
|
|
13
|
+
* Render an edge template without defining an
|
|
14
|
+
* explicit route handler
|
|
15
|
+
*/
|
|
16
|
+
render(template: string, data?: Record<string, any>): Route;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
* Resolves a container binding and sets it on the REPL
|
|
11
|
+
* context
|
|
12
|
+
*/
|
|
13
|
+
async function resolveBindingForRepl(app, repl, binding) {
|
|
14
|
+
repl.server.context[binding] = await app.container.make(binding);
|
|
15
|
+
repl.notify(`Loaded "${binding}" service. You can access it using the "${repl.colors.underline(binding)}" variable`);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Registers REPL methods
|
|
19
|
+
*/
|
|
20
|
+
export function defineReplBindings(app, repl) {
|
|
21
|
+
repl.addMethod('importDefault', (_, modulePath) => {
|
|
22
|
+
return app.importDefault(modulePath);
|
|
23
|
+
}, {
|
|
24
|
+
description: 'Returns the default export for a module',
|
|
25
|
+
});
|
|
26
|
+
repl.addMethod('make', (_, service, runtimeValues) => {
|
|
27
|
+
return app.container.make(service, runtimeValues);
|
|
28
|
+
}, {
|
|
29
|
+
description: 'Make class instance using "container.make" method',
|
|
30
|
+
});
|
|
31
|
+
repl.addMethod('loadApp', () => {
|
|
32
|
+
return resolveBindingForRepl(app, repl, 'app');
|
|
33
|
+
}, {
|
|
34
|
+
description: 'Load "app" service in the REPL context',
|
|
35
|
+
});
|
|
36
|
+
repl.addMethod('loadEncryption', () => {
|
|
37
|
+
return resolveBindingForRepl(app, repl, 'encryption');
|
|
38
|
+
}, {
|
|
39
|
+
description: 'Load "encryption" service in the REPL context',
|
|
40
|
+
});
|
|
41
|
+
repl.addMethod('loadHash', () => {
|
|
42
|
+
return resolveBindingForRepl(app, repl, 'hash');
|
|
43
|
+
}, {
|
|
44
|
+
description: 'Load "hash" service in the REPL context',
|
|
45
|
+
});
|
|
46
|
+
repl.addMethod('loadRouter', () => {
|
|
47
|
+
return resolveBindingForRepl(app, repl, 'router');
|
|
48
|
+
}, {
|
|
49
|
+
description: 'Load "router" service in the REPL context',
|
|
50
|
+
});
|
|
51
|
+
repl.addMethod('loadConfig', () => {
|
|
52
|
+
return resolveBindingForRepl(app, repl, 'config');
|
|
53
|
+
}, {
|
|
54
|
+
description: 'Load "config" service in the REPL context',
|
|
55
|
+
});
|
|
56
|
+
repl.addMethod('loadTestUtils', () => {
|
|
57
|
+
return resolveBindingForRepl(app, repl, 'testUtils');
|
|
58
|
+
}, {
|
|
59
|
+
description: 'Load "testUtils" service in the REPL context',
|
|
60
|
+
});
|
|
61
|
+
repl.addMethod('loadHelpers', async () => {
|
|
62
|
+
const { default: isModule } = await import('../helpers/is.js');
|
|
63
|
+
const { default: stringModule } = await import('../helpers/string.js');
|
|
64
|
+
const { base64, cuid, fsReadAll, slash, parseImports } = await import('../helpers/main.js');
|
|
65
|
+
repl.server.context.helpers = {
|
|
66
|
+
string: stringModule,
|
|
67
|
+
is: isModule,
|
|
68
|
+
base64,
|
|
69
|
+
cuid,
|
|
70
|
+
fsReadAll,
|
|
71
|
+
slash,
|
|
72
|
+
parseImports,
|
|
73
|
+
};
|
|
74
|
+
repl.notify(`Loaded "helpers" module. You can access it using the "${repl.colors.underline('helpers')}" variable`);
|
|
75
|
+
}, {
|
|
76
|
+
description: 'Load "helpers" module in the REPL context',
|
|
77
|
+
});
|
|
78
|
+
}
|