@wrelik/config 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @wrelik/config
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ad849e3: Initial release of all wrelik-kit packages.
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@wrelik/config",
3
+ "version": "0.1.0",
4
+ "main": "./dist/index.js",
5
+ "types": "./dist/index.d.ts",
6
+ "dependencies": {
7
+ "dotenv": "^16.4.1",
8
+ "zod": "^3.22.4"
9
+ },
10
+ "devDependencies": {
11
+ "tsup": "^8.0.1",
12
+ "vitest": "^1.2.2",
13
+ "@wrelik/eslint-config": "0.1.0",
14
+ "@wrelik/tsconfig": "0.1.0"
15
+ },
16
+ "scripts": {
17
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
18
+ "lint": "eslint src/",
19
+ "test": "vitest run --passWithNoTests"
20
+ }
21
+ }
package/src/index.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import dotenv from 'dotenv';
3
+ import path from 'path';
4
+
5
+ // Load .env from project root
6
+ dotenv.config({ path: path.resolve(process.cwd(), '.env') });
7
+
8
+ export function createEnv<T extends z.ZodRawShape>(schema: T) {
9
+ const envSchema = z.object(schema);
10
+ const result = envSchema.safeParse(process.env);
11
+
12
+ if (!result.success) {
13
+ console.error('❌ Invalid environment variables:', result.error.format());
14
+ throw new Error('Invalid environment variables');
15
+ }
16
+
17
+ return result.data;
18
+ }
19
+
20
+ // Common schemas
21
+ export const commonSchema = {
22
+ NODE_ENV: z.enum(['development', 'test', 'production']).default('development'),
23
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "@wrelik/tsconfig/node.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist"
5
+ },
6
+ "include": ["src"]
7
+ }