@smounters/imperium 1.0.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +21 -0
  3. package/README.md +227 -0
  4. package/dist/core/app-tokens.d.ts +5 -0
  5. package/dist/core/app-tokens.js +4 -0
  6. package/dist/core/application.d.ts +34 -0
  7. package/dist/core/application.js +252 -0
  8. package/dist/core/config.d.ts +1 -0
  9. package/dist/core/config.js +1 -0
  10. package/dist/core/container.d.ts +76 -0
  11. package/dist/core/container.js +687 -0
  12. package/dist/core/errors.d.ts +31 -0
  13. package/dist/core/errors.js +169 -0
  14. package/dist/core/index.d.ts +5 -0
  15. package/dist/core/index.js +4 -0
  16. package/dist/core/logger.d.ts +7 -0
  17. package/dist/core/logger.js +12 -0
  18. package/dist/core/reflector.d.ts +9 -0
  19. package/dist/core/reflector.js +39 -0
  20. package/dist/core/server.d.ts +10 -0
  21. package/dist/core/server.js +296 -0
  22. package/dist/core/types.d.ts +25 -0
  23. package/dist/core/types.js +1 -0
  24. package/dist/decorators/di.decorators.d.ts +10 -0
  25. package/dist/decorators/di.decorators.js +15 -0
  26. package/dist/decorators/filters.decorators.d.ts +6 -0
  27. package/dist/decorators/filters.decorators.js +16 -0
  28. package/dist/decorators/guards.decorators.d.ts +4 -0
  29. package/dist/decorators/guards.decorators.js +8 -0
  30. package/dist/decorators/http.decorators.d.ts +16 -0
  31. package/dist/decorators/http.decorators.js +60 -0
  32. package/dist/decorators/index.d.ts +8 -0
  33. package/dist/decorators/index.js +8 -0
  34. package/dist/decorators/interceptors.decorators.d.ts +4 -0
  35. package/dist/decorators/interceptors.decorators.js +8 -0
  36. package/dist/decorators/metadata.decorators.d.ts +4 -0
  37. package/dist/decorators/metadata.decorators.js +22 -0
  38. package/dist/decorators/pipes.decorators.d.ts +4 -0
  39. package/dist/decorators/pipes.decorators.js +8 -0
  40. package/dist/decorators/rpc.decorators.d.ts +11 -0
  41. package/dist/decorators/rpc.decorators.js +50 -0
  42. package/dist/http/adapter.d.ts +4 -0
  43. package/dist/http/adapter.js +199 -0
  44. package/dist/http/index.d.ts +3 -0
  45. package/dist/http/index.js +3 -0
  46. package/dist/http/router-builder.d.ts +4 -0
  47. package/dist/http/router-builder.js +30 -0
  48. package/dist/http/utils.d.ts +6 -0
  49. package/dist/http/utils.js +46 -0
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +1 -0
  52. package/dist/pipes/index.d.ts +1 -0
  53. package/dist/pipes/index.js +1 -0
  54. package/dist/pipes/zod.pipe.d.ts +7 -0
  55. package/dist/pipes/zod.pipe.js +8 -0
  56. package/dist/rpc/adapter.d.ts +7 -0
  57. package/dist/rpc/adapter.js +186 -0
  58. package/dist/rpc/index.d.ts +3 -0
  59. package/dist/rpc/index.js +3 -0
  60. package/dist/rpc/router-builder.d.ts +4 -0
  61. package/dist/rpc/router-builder.js +28 -0
  62. package/dist/rpc/utils.d.ts +6 -0
  63. package/dist/rpc/utils.js +46 -0
  64. package/dist/services/config.service.d.ts +10 -0
  65. package/dist/services/config.service.js +41 -0
  66. package/dist/services/index.d.ts +2 -0
  67. package/dist/services/index.js +2 -0
  68. package/dist/services/logger.service.d.ts +30 -0
  69. package/dist/services/logger.service.js +52 -0
  70. package/dist/types.d.ts +167 -0
  71. package/dist/types.js +1 -0
  72. package/dist/validation/app-config.d.ts +30 -0
  73. package/dist/validation/app-config.js +25 -0
  74. package/dist/validation/common.d.ts +8 -0
  75. package/dist/validation/common.js +57 -0
  76. package/dist/validation/index.d.ts +2 -0
  77. package/dist/validation/index.js +2 -0
  78. package/package.json +98 -0
@@ -0,0 +1,57 @@
1
+ import { z } from "zod";
2
+ const TRUE_VALUES = new Set(["true", "1", "yes", "on"]);
3
+ const FALSE_VALUES = new Set(["false", "0", "no", "off"]);
4
+ export const booleanSchema = () => z.preprocess((v) => {
5
+ if (typeof v === "boolean") {
6
+ return v;
7
+ }
8
+ if (typeof v === "string") {
9
+ const normalized = v.toLowerCase().trim();
10
+ if (TRUE_VALUES.has(normalized))
11
+ return true;
12
+ if (FALSE_VALUES.has(normalized))
13
+ return false;
14
+ }
15
+ return v;
16
+ }, z.boolean());
17
+ export const numberSchema = () => z.preprocess((v) => {
18
+ if (typeof v === "number") {
19
+ return Number.isNaN(v) ? v : v;
20
+ }
21
+ if (typeof v === "string") {
22
+ const normalized = v.trim();
23
+ if (!normalized)
24
+ return v;
25
+ const n = Number(normalized);
26
+ if (!Number.isNaN(n))
27
+ return n;
28
+ }
29
+ return v;
30
+ }, z.number());
31
+ export const nativeEnumSchema = (enumType, normalize) => z.preprocess((v) => (typeof v === "string" ? (normalize ? normalize(v) : v) : v), z.nativeEnum(enumType));
32
+ export const stringArraySchema = (itemSchema) => z.preprocess((v) => {
33
+ if (Array.isArray(v)) {
34
+ return v;
35
+ }
36
+ if (typeof v !== "string") {
37
+ return v;
38
+ }
39
+ const value = v.trim();
40
+ if (!value) {
41
+ return [];
42
+ }
43
+ try {
44
+ const parsed = JSON.parse(value);
45
+ if (Array.isArray(parsed)) {
46
+ return parsed;
47
+ }
48
+ }
49
+ catch {
50
+ // Ignore JSON parse errors and fallback to CSV parsing.
51
+ }
52
+ return value
53
+ .split(/[;,]/)
54
+ .map((item) => item.trim())
55
+ .filter(Boolean);
56
+ }, z.array(itemSchema));
57
+ export const enumArraySchema = (enumType, normalize) => stringArraySchema(nativeEnumSchema(enumType, normalize));
@@ -0,0 +1,2 @@
1
+ export * from "./app-config";
2
+ export * from "./common";
@@ -0,0 +1,2 @@
1
+ export * from "./app-config";
2
+ export * from "./common";
package/package.json ADDED
@@ -0,0 +1,98 @@
1
+ {
2
+ "name": "@smounters/imperium",
3
+ "version": "1.0.0",
4
+ "description": "NestJS-like modular DI container with unified HTTP + Connect RPC server for TypeScript",
5
+ "keywords": [
6
+ "di",
7
+ "dependency-injection",
8
+ "fastify",
9
+ "connectrpc",
10
+ "typescript"
11
+ ],
12
+ "license": "MIT",
13
+ "type": "module",
14
+ "exports": {
15
+ "./core": {
16
+ "types": "./dist/core/index.d.ts",
17
+ "import": "./dist/core/index.js"
18
+ },
19
+ "./decorators": {
20
+ "types": "./dist/decorators/index.d.ts",
21
+ "import": "./dist/decorators/index.js"
22
+ },
23
+ "./pipes": {
24
+ "types": "./dist/pipes/index.d.ts",
25
+ "import": "./dist/pipes/index.js"
26
+ },
27
+ "./services": {
28
+ "types": "./dist/services/index.d.ts",
29
+ "import": "./dist/services/index.js"
30
+ },
31
+ "./validation": {
32
+ "types": "./dist/validation/index.d.ts",
33
+ "import": "./dist/validation/index.js"
34
+ }
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "README.md",
39
+ "LICENSE",
40
+ "CHANGELOG.md"
41
+ ],
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/smounters/imperium.git"
48
+ },
49
+ "bugs": {
50
+ "url": "https://github.com/smounters/imperium/issues"
51
+ },
52
+ "homepage": "https://smounters.github.io/imperium/",
53
+ "engines": {
54
+ "node": ">=20.0.0"
55
+ },
56
+ "peerDependencies": {
57
+ "@connectrpc/connect": "^2.1.1",
58
+ "@connectrpc/connect-fastify": "^2.1.1",
59
+ "@fastify/cors": "^11.2.0",
60
+ "fastify": "^5.7.4",
61
+ "tsyringe": "^4.10.0",
62
+ "reflect-metadata": "^0.2.2",
63
+ "tslog": "^4.10.2",
64
+ "typescript": "^5.9.3",
65
+ "zod": "^4.3.6"
66
+ },
67
+ "devDependencies": {
68
+ "@types/node": "^24.5.2",
69
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
70
+ "@typescript-eslint/parser": "^8.56.0",
71
+ "@connectrpc/connect": "^2.1.1",
72
+ "@connectrpc/connect-fastify": "^2.1.1",
73
+ "@fastify/cors": "^11.2.0",
74
+ "eslint": "^10.0.0",
75
+ "eslint-config-prettier": "^10.1.8",
76
+ "fastify": "^5.7.4",
77
+ "prettier": "^3.8.1",
78
+ "reflect-metadata": "^0.2.2",
79
+ "tslog": "^4.10.2",
80
+ "tsyringe": "^4.10.0",
81
+ "typescript": "^5.9.3",
82
+ "vitepress": "^1.6.4",
83
+ "zod": "^4.3.6"
84
+ },
85
+ "dependencies": {},
86
+ "scripts": {
87
+ "build": "pnpm exec tsc -p tsconfig.json",
88
+ "typecheck": "pnpm exec tsc -p tsconfig.json --noEmit",
89
+ "lint": "eslint \"src/**/*.{ts,tsx}\"",
90
+ "lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
91
+ "format": "prettier . --write",
92
+ "format:check": "prettier . --check",
93
+ "clean": "rm -rf dist",
94
+ "docs:dev": "pnpm exec vitepress dev docs",
95
+ "docs:build": "pnpm exec vitepress build docs",
96
+ "docs:preview": "pnpm exec vitepress preview docs"
97
+ }
98
+ }