@cuboapp/api-backend 1.0.22 → 1.0.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuboapp/api-backend",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "Backend Api for CuboApp",
5
5
  "main": "src/index.ts",
6
6
  "repository": "git@github.com:cuboapp/api-backend.git",
package/src/index.ts CHANGED
@@ -19,20 +19,22 @@ export class CuboBackendApi<T extends CuboApiEntitiesMap<T>> {
19
19
 
20
20
  async init() {
21
21
  try {
22
- this.auth = await this.request<{ variables: Record<string, any> }>('/auth/me?with=variables', {
23
- withAuth: true
24
- })
22
+ if (this.options.api !== undefined) {
23
+ this.auth = await this.request<{ variables: Record<string, any> }>('/auth/me?with=variables', {
24
+ withAuth: true
25
+ })
25
26
 
26
- if (!this.auth) {
27
- throw { code: 403, text: 'Авторизация Cubo-Backend не пройдена' }
28
- }
27
+ if (!this.auth) {
28
+ throw { code: 403, text: 'Авторизация Cubo-Backend не пройдена' }
29
+ }
29
30
 
30
- if (this.auth.variables?.db !== undefined) {
31
- this.options.db = this.options.db || {}
31
+ if (this.auth.variables?.db !== undefined) {
32
+ this.options.db = this.options.db || {}
32
33
 
33
- this.options.db.options = {
34
- ...(this.options.db.options || {}),
35
- ...(this.auth.variables?.db || {})
34
+ this.options.db.options = {
35
+ ...(this.options.db.options || {}),
36
+ ...(this.auth.variables?.db || {})
37
+ }
36
38
  }
37
39
  }
38
40
  } catch (e) {
@@ -10,7 +10,7 @@ export * from './basic'
10
10
  export * from './db'
11
11
 
12
12
  export type CuboBackendApiOptions<T extends CuboApiEntitiesMap<T>> = {
13
- api: {
13
+ api?: {
14
14
  base_url?: string
15
15
  headers: Partial<Record<`cubo-${CuboAuthTokenType}`, string>> & Record<string, any>
16
16
  }