@wabot-dev/framework 0.1.0-beta.19 → 0.1.0-beta.20

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.
@@ -15,16 +15,16 @@ let Env = class Env {
15
15
  isTesting() {
16
16
  return this.envType === 'testing';
17
17
  }
18
- requireString(varName) {
19
- const value = process.env[varName];
18
+ requireString(varName, options) {
19
+ const value = process.env[varName] ?? options?.default;
20
20
  if (!value)
21
21
  throw new Error(`Env Variable ${varName} is required`);
22
22
  return value;
23
23
  }
24
- requireNumber(varName) {
25
- const strValue = process.env[varName];
26
- if (!strValue)
27
- throw new Error(`Env Variable ${varName} is required`);
24
+ requireNumber(varName, options) {
25
+ const strValue = this.requireString(varName, {
26
+ default: options?.default != null ? String(options.default) : undefined,
27
+ });
28
28
  const value = Number(strValue);
29
29
  if (isNaN(value))
30
30
  throw new Error(`Env Variable ${varName} should have number format`);
@@ -596,8 +596,12 @@ declare class Env {
596
596
  isDevelopment(): boolean;
597
597
  isProduction(): boolean;
598
598
  isTesting(): boolean;
599
- requireString(varName: string): string;
600
- requireNumber(varName: string): number;
599
+ requireString(varName: string, options?: {
600
+ default?: string;
601
+ }): string;
602
+ requireNumber(varName: string, options?: {
603
+ default?: number;
604
+ }): number;
601
605
  }
602
606
 
603
607
  declare class EnvWhatsAppRepository implements IWhatsAppRepository {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.1.0-beta.19",
3
+ "version": "0.1.0-beta.20",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",