@cuboapp/api-backend 1.0.19 → 1.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +5 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuboapp/api-backend",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
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,7 +19,9 @@ 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')
22
+ this.auth = await this.request<{ variables: Record<string, any> }>('/auth/me?with=variables', {
23
+ withAuth: true
24
+ })
23
25
 
24
26
  if (!this.auth) {
25
27
  throw { code: 403, text: 'Авторизация Cubo-Backend не пройдена' }
@@ -38,14 +40,14 @@ export class CuboBackendApi<T extends CuboApiEntitiesMap<T>> {
38
40
  }
39
41
  }
40
42
 
41
- public async request<T>(url: string, opts?: RequestInit & { debug?: boolean; withoutAuth?: boolean; withoutContentType?: boolean }) {
43
+ public async request<T>(url: string, opts?: RequestInit & { debug?: boolean; withAuth?: boolean; withoutContentType?: boolean }) {
42
44
  const baseUrl = this.options?.api?.base_url || 'https://api.cubo.sh'
43
45
 
44
46
  const headers: Record<string, any> = {
45
47
  ...(opts?.headers || {})
46
48
  }
47
49
 
48
- if (!opts?.withoutAuth) {
50
+ if (!opts?.withAuth) {
49
51
  Object.assign(headers, this.options.api?.headers || {})
50
52
  }
51
53