laplace-api 4.0.0 → 4.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.
@@ -1,9 +1,9 @@
1
- import * as dotenv from 'dotenv';
2
- import * as envalid from 'envalid';
1
+ import * as dotenv from "dotenv";
2
+ import * as envalid from "envalid";
3
3
  const { str } = envalid;
4
4
 
5
5
  export interface LaplaceConfigurationInterface {
6
- baseURL: string;
6
+ baseURL?: string;
7
7
  apiKey: string;
8
8
  }
9
9
 
@@ -11,18 +11,28 @@ export class LaplaceConfiguration implements LaplaceConfigurationInterface {
11
11
  baseURL: string;
12
12
  apiKey: string;
13
13
 
14
- constructor({ baseURL, apiKey }: LaplaceConfigurationInterface) {
15
- this.baseURL = baseURL;
14
+ constructor({
15
+ baseURL = "https://api.finfree.app",
16
+ apiKey,
17
+ }: LaplaceConfigurationInterface) {
18
+ this.baseURL = baseURL || "https://api.finfree.app";
16
19
  this.apiKey = apiKey;
17
20
  }
18
21
 
19
22
  validate(): null | Error {
20
- // Add validation logic if needed
23
+ if (!this.apiKey) {
24
+ return new Error("API key is required");
25
+ }
26
+
27
+ // Remove baseURL validation since it's now optional
21
28
  return null;
22
29
  }
23
30
 
24
31
  applyDefaults(): null | Error {
25
- // Apply default values if needed
32
+ if (!this.baseURL) {
33
+ this.baseURL = "https://api.finfree.app";
34
+ }
35
+
26
36
  return null;
27
37
  }
28
38
  }
@@ -41,14 +51,17 @@ function validationFuncRegular(config: LaplaceConfiguration): null | Error {
41
51
  return config.validate();
42
52
  }
43
53
 
44
- export function loadGlobal(filename?: string, validationFunc: ValidationFunc = validationFuncRegular): LaplaceConfiguration {
54
+ export function loadGlobal(
55
+ filename?: string,
56
+ validationFunc: ValidationFunc = validationFuncRegular
57
+ ): LaplaceConfiguration {
45
58
  const envLoadResult = loadEnvironment(filename);
46
59
  if (envLoadResult.error) {
47
60
  throw envLoadResult.error;
48
61
  }
49
62
 
50
63
  const env = envalid.cleanEnv(process.env, {
51
- BASE_URL: str(),
64
+ BASE_URL: str({ default: "https://api.finfree.app" }),
52
65
  API_KEY: str(),
53
66
  });
54
67
 
@@ -70,4 +83,4 @@ export function loadGlobal(filename?: string, validationFunc: ValidationFunc = v
70
83
  }
71
84
 
72
85
  return config;
73
- }
86
+ }
@@ -1,2 +1,2 @@
1
- BASE_URL=https://api.finfree.app
2
- API_KEY=api-6fa6cefb-16df-4a19-8351-54f83c6bbe2f
1
+ BASE_URL=http://localhost:8010
2
+ API_KEY=test-api-key