@elysiumjs/styx 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/commands/make_command.ts +167 -0
- package/src/commands/make_controller.ts +272 -0
- package/src/commands/make_job.ts +178 -0
- package/src/commands/make_middleware.ts +138 -0
- package/src/commands/make_model.ts +195 -0
- package/src/commands/make_repository.ts +220 -0
- package/src/commands/make_service.ts +196 -0
- package/src/commands/make_validator.ts +142 -0
- package/src/commands/migration_generate.ts +69 -0
- package/src/commands/migration_run.ts +145 -0
- package/src/config.ts +99 -0
- package/src/utils.ts +23 -0
- package/stubs/validator.stub +30 -0
package/stubs/validator.stub
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Context } from '@elysiumjs/core';
|
|
2
|
+
|
|
1
3
|
import { t } from 'elysia';
|
|
2
4
|
|
|
3
5
|
export class {name} {
|
|
@@ -34,6 +36,34 @@ export class {name} {
|
|
|
34
36
|
* })
|
|
35
37
|
*/
|
|
36
38
|
public static readonly schema = t.Object({});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Whether the request should be authorized before validation.
|
|
42
|
+
*
|
|
43
|
+
* If the request is not authorized, the validation will be skipped.
|
|
44
|
+
*
|
|
45
|
+
* @param ctx The request context.
|
|
46
|
+
* @returns Whether the request is authorized.
|
|
47
|
+
*/
|
|
48
|
+
public static async authorize(ctx: Context<{request_name}>): Promise<boolean> {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Processes custom validation logic.
|
|
54
|
+
*
|
|
55
|
+
* This method is called after the validation schema is checked against the input data.
|
|
56
|
+
* So it's safe to assume that the schema is valid.
|
|
57
|
+
*
|
|
58
|
+
* You can use this method to perform any custom validation logic on the request body or
|
|
59
|
+
* query parameters.
|
|
60
|
+
*
|
|
61
|
+
* @param ctx The request context.
|
|
62
|
+
* @returns Whether the input data is valid.
|
|
63
|
+
*/
|
|
64
|
+
public static async validate(ctx: Context<{request_name}>): Promise<boolean> {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
37
67
|
}
|
|
38
68
|
|
|
39
69
|
export type {request_name} = typeof {name}.schema.static;
|