@navios/core 0.2.1 → 0.2.2
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/docs/README.md +6 -0
- package/docs/recipes/prisma.md +60 -0
- package/examples/simple-test/api/index.mts +64 -0
- package/examples/simple-test/config/config.service.mts +14 -0
- package/examples/simple-test/config/configuration.mts +7 -0
- package/examples/simple-test/index.mts +16 -0
- package/examples/simple-test/src/acl/acl-modern.guard.mts +15 -0
- package/examples/simple-test/src/acl/acl.guard.mts +14 -0
- package/examples/simple-test/src/acl/app.guard.mts +27 -0
- package/examples/simple-test/src/acl/one-more.guard.mts +15 -0
- package/examples/simple-test/src/acl/public.attribute.mts +21 -0
- package/examples/simple-test/src/app.module.mts +9 -0
- package/examples/simple-test/src/user/user.controller.mts +72 -0
- package/examples/simple-test/src/user/user.module.mts +14 -0
- package/examples/simple-test/src/user/user.service.mts +14 -0
- package/{dist → lib}/_tsup-dts-rollup.d.mts +71 -50
- package/{dist → lib}/_tsup-dts-rollup.d.ts +71 -50
- package/{dist → lib}/index.d.mts +13 -4
- package/{dist → lib}/index.d.ts +13 -4
- package/{dist → lib}/index.js +270 -490
- package/lib/index.js.map +1 -0
- package/{dist → lib}/index.mjs +140 -353
- package/lib/index.mjs.map +1 -0
- package/package.json +10 -11
- package/project.json +53 -0
- package/src/__tests__/config.service.spec.mts +41 -0
- package/src/config/config-service.interface.mts +1 -1
- package/src/config/config.provider.mts +22 -50
- package/src/config/config.service.mts +25 -8
- package/src/decorators/endpoint.decorator.mts +0 -5
- package/tsconfig.json +16 -0
- package/tsup.config.mts +12 -0
- package/vitest.config.mts +9 -0
|
@@ -1,16 +1,33 @@
|
|
|
1
1
|
import { NaviosException } from '@navios/common'
|
|
2
|
+
import { Injectable, InjectionToken, syncInject } from '@navios/di'
|
|
2
3
|
|
|
3
|
-
import
|
|
4
|
-
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
|
|
6
|
+
import type { ConfigServiceInterface as IConfigService } from './config-service.interface.mjs'
|
|
5
7
|
import type { Path, PathValue } from './types.mjs'
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
import { Logger } from '../logger/index.mjs'
|
|
10
|
+
|
|
11
|
+
export const ConfigServiceOptionsSchema = z.record(z.unknown())
|
|
12
|
+
export type ConfigServiceOptions = z.infer<typeof ConfigServiceOptionsSchema>
|
|
13
|
+
|
|
14
|
+
export const ConfigServiceToken = InjectionToken.create<
|
|
15
|
+
IConfigService,
|
|
16
|
+
typeof ConfigServiceOptionsSchema
|
|
17
|
+
>(Symbol.for('ConfigService'), ConfigServiceOptionsSchema)
|
|
18
|
+
|
|
19
|
+
@Injectable({
|
|
20
|
+
token: ConfigServiceToken,
|
|
21
|
+
})
|
|
22
|
+
export class ConfigService<
|
|
23
|
+
Config extends ConfigServiceOptions = Record<string, unknown>,
|
|
24
|
+
> implements IConfigService<Config>
|
|
9
25
|
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
26
|
+
private readonly logger = syncInject(Logger, {
|
|
27
|
+
context: ConfigService.name,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
constructor(private config: Config = {} as Config) {}
|
|
14
31
|
|
|
15
32
|
getConfig(): Config {
|
|
16
33
|
return this.config
|
|
@@ -78,11 +78,6 @@ export function Endpoint<
|
|
|
78
78
|
) => Promise<z.input<ResponseSchema>>,
|
|
79
79
|
context: ClassMethodDecoratorContext,
|
|
80
80
|
) => {
|
|
81
|
-
if (typeof target !== 'function') {
|
|
82
|
-
throw new Error(
|
|
83
|
-
'[Navios] Endpoint decorator can only be used on functions.',
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
81
|
if (context.kind !== 'method') {
|
|
87
82
|
throw new Error(
|
|
88
83
|
'[Navios] Endpoint decorator can only be used on methods.',
|
package/tsconfig.json
ADDED
package/tsup.config.mts
ADDED