@bunary/core 0.0.2 → 0.0.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAW/D"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAW/D"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Application environment constants
3
+ */
4
+ export declare const Environment: {
5
+ readonly DEVELOPMENT: "development";
6
+ readonly PRODUCTION: "production";
7
+ readonly TEST: "test";
8
+ };
9
+ export type EnvironmentType = (typeof Environment)[keyof typeof Environment];
10
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC"}
@@ -14,7 +14,10 @@
14
14
  * const secret = env('SECRET'); // Returns string | undefined
15
15
  * ```
16
16
  */
17
- export declare function env<T extends string | number | boolean | undefined>(key: string, defaultValue?: T): T extends undefined ? string | undefined : T;
17
+ export declare function env(key: string): string | undefined;
18
+ export declare function env(key: string, defaultValue: string): string;
19
+ export declare function env(key: string, defaultValue: number): number;
20
+ export declare function env(key: string, defaultValue: boolean): boolean;
18
21
  /**
19
22
  * Check if running in development mode
20
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,EACjE,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,CAAC,GACf,CAAC,SAAS,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,CAAC,CAqB9C;AAED;;GAEG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAE/B;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAEhC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAEhC"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AACrD,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;AAC/D,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;AAC/D,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC;AAuBjE;;GAEG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAE/B;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAEhC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAEhC"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * Foundation module for Bunary - config, environment, and app helpers
4
4
  */
5
5
  export { defineConfig } from "./config";
6
+ export { Environment, type EnvironmentType } from "./constants";
6
7
  export { env, isDev, isProd, isTest } from "./environment";
7
8
  export type { BunaryConfig, AppConfig } from "./types";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC3D,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC3D,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,10 +1,17 @@
1
1
  // @bun
2
+ // src/constants.ts
3
+ var Environment = {
4
+ DEVELOPMENT: "development",
5
+ PRODUCTION: "production",
6
+ TEST: "test"
7
+ };
8
+
2
9
  // src/config.ts
3
10
  function defineConfig(config) {
4
11
  return {
5
12
  app: {
6
13
  name: config.app.name,
7
- env: config.app.env ?? Bun.env.NODE_ENV ?? "development",
14
+ env: config.app.env ?? Bun.env.NODE_ENV ?? Environment.DEVELOPMENT,
8
15
  debug: config.app.debug ?? Bun.env.DEBUG === "true"
9
16
  }
10
17
  };
@@ -16,7 +23,7 @@ function env(key, defaultValue) {
16
23
  return defaultValue;
17
24
  }
18
25
  if (typeof defaultValue === "boolean") {
19
- return value === "true";
26
+ return value === "true" || value === "1" || value === "yes";
20
27
  }
21
28
  if (typeof defaultValue === "number") {
22
29
  const num = Number(value);
@@ -25,18 +32,19 @@ function env(key, defaultValue) {
25
32
  return value;
26
33
  }
27
34
  function isDev() {
28
- return Bun.env.NODE_ENV === "development" || !Bun.env.NODE_ENV;
35
+ return Bun.env.NODE_ENV === Environment.DEVELOPMENT || !Bun.env.NODE_ENV;
29
36
  }
30
37
  function isProd() {
31
- return Bun.env.NODE_ENV === "production";
38
+ return Bun.env.NODE_ENV === Environment.PRODUCTION;
32
39
  }
33
40
  function isTest() {
34
- return Bun.env.NODE_ENV === "test";
41
+ return Bun.env.NODE_ENV === Environment.TEST;
35
42
  }
36
43
  export {
37
44
  isTest,
38
45
  isProd,
39
46
  isDev,
40
47
  env,
41
- defineConfig
48
+ defineConfig,
49
+ Environment
42
50
  };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { EnvironmentType } from "./constants.js";
1
2
  /**
2
3
  * App configuration
3
4
  */
@@ -5,7 +6,7 @@ export interface AppConfig {
5
6
  /** Application name */
6
7
  name: string;
7
8
  /** Environment: development, production, test */
8
- env?: "development" | "production" | "test";
9
+ env?: EnvironmentType;
9
10
  /** Debug mode */
10
11
  debug?: boolean;
11
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,GAAG,CAAC,EAAE,aAAa,GAAG,YAAY,GAAG,MAAM,CAAC;IAC5C,iBAAiB;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,SAAS,CAAC;CAChB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,iBAAiB;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,SAAS,CAAC;CAChB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunary/core",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Foundation module for Bunary - config, environment, and app helpers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",