@smounters/imperium 1.0.0 → 1.0.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/README.md +14 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -93,14 +93,7 @@ await app.start({ port: 3000 });
|
|
|
93
93
|
```ts
|
|
94
94
|
import { Application } from "@smounters/imperium/core";
|
|
95
95
|
import { ConfigService, LoggerService } from "@smounters/imperium/services";
|
|
96
|
-
import {
|
|
97
|
-
|
|
98
|
-
const appConfigSchema = z.object({
|
|
99
|
-
APP_PORT: z.coerce.number().default(8000),
|
|
100
|
-
APP_GLOBAL_PREFIX: z.string().default(""),
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
type AppConfig = z.infer<typeof appConfigSchema>;
|
|
96
|
+
import { appConfigSchema, type AppConfig } from "@smounters/imperium/validation";
|
|
104
97
|
|
|
105
98
|
const app = new Application(AppModule, {
|
|
106
99
|
host: "0.0.0.0",
|
|
@@ -124,6 +117,17 @@ await app.start({
|
|
|
124
117
|
app.resolve(LoggerService).info({ event: "app.started", port: config.APP_PORT });
|
|
125
118
|
```
|
|
126
119
|
|
|
120
|
+
If your app needs extra config fields, extend the exported base schema:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { appConfigSchema } from "@smounters/imperium/validation";
|
|
124
|
+
import { z } from "zod";
|
|
125
|
+
|
|
126
|
+
const projectConfigSchema = appConfigSchema.extend({
|
|
127
|
+
REDIS_URL: z.url(),
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
127
131
|
## Multi Providers
|
|
128
132
|
|
|
129
133
|
```ts
|
|
@@ -173,6 +177,8 @@ From `@smounters/imperium/services`:
|
|
|
173
177
|
|
|
174
178
|
- `ZodPipe` from `@smounters/imperium/pipes`
|
|
175
179
|
- validation helpers from `@smounters/imperium/validation`
|
|
180
|
+
- `appConfigSchema`
|
|
181
|
+
- `AppConfig`
|
|
176
182
|
- `booleanSchema`
|
|
177
183
|
- `numberSchema`
|
|
178
184
|
- `nativeEnumSchema`
|