@niledatabase/server 4.0.0 → 4.0.1-alpha.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.
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -284,12 +284,12 @@ declare class Users extends Config {
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
declare class Api {
|
|
287
|
+
#private;
|
|
287
288
|
config: Config;
|
|
288
289
|
users: Users;
|
|
289
290
|
auth: Auth;
|
|
290
291
|
tenants: Tenants;
|
|
291
292
|
routes: Routes;
|
|
292
|
-
_headers: undefined | Headers;
|
|
293
293
|
handlers: {
|
|
294
294
|
GET: (req: Request) => Promise<void | Response>;
|
|
295
295
|
POST: (req: Request) => Promise<void | Response>;
|
|
@@ -306,7 +306,7 @@ declare class Api {
|
|
|
306
306
|
reset: () => void;
|
|
307
307
|
updateConfig: (config: Config) => void;
|
|
308
308
|
resetHeaders: (headers?: Headers) => void;
|
|
309
|
-
set headers(headers: Headers);
|
|
309
|
+
set headers(headers: Headers | Record<string, string>);
|
|
310
310
|
get headers(): Headers | undefined;
|
|
311
311
|
login: (payload: {
|
|
312
312
|
email: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -284,12 +284,12 @@ declare class Users extends Config {
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
declare class Api {
|
|
287
|
+
#private;
|
|
287
288
|
config: Config;
|
|
288
289
|
users: Users;
|
|
289
290
|
auth: Auth;
|
|
290
291
|
tenants: Tenants;
|
|
291
292
|
routes: Routes;
|
|
292
|
-
_headers: undefined | Headers;
|
|
293
293
|
handlers: {
|
|
294
294
|
GET: (req: Request) => Promise<void | Response>;
|
|
295
295
|
POST: (req: Request) => Promise<void | Response>;
|
|
@@ -306,7 +306,7 @@ declare class Api {
|
|
|
306
306
|
reset: () => void;
|
|
307
307
|
updateConfig: (config: Config) => void;
|
|
308
308
|
resetHeaders: (headers?: Headers) => void;
|
|
309
|
-
set headers(headers: Headers);
|
|
309
|
+
set headers(headers: Headers | Record<string, string>);
|
|
310
310
|
get headers(): Headers | undefined;
|
|
311
311
|
login: (payload: {
|
|
312
312
|
email: string;
|
package/dist/index.js
CHANGED
|
@@ -2352,7 +2352,7 @@ var Api = class {
|
|
|
2352
2352
|
auth;
|
|
2353
2353
|
tenants;
|
|
2354
2354
|
routes;
|
|
2355
|
-
|
|
2355
|
+
#headers;
|
|
2356
2356
|
handlers;
|
|
2357
2357
|
paths;
|
|
2358
2358
|
constructor(config) {
|
|
@@ -2406,9 +2406,9 @@ var Api = class {
|
|
|
2406
2406
|
};
|
|
2407
2407
|
}
|
|
2408
2408
|
reset = () => {
|
|
2409
|
-
this.users = new Users(this.config, this
|
|
2410
|
-
this.tenants = new Tenants(this.config, this
|
|
2411
|
-
this.auth = new Auth(this.config, this
|
|
2409
|
+
this.users = new Users(this.config, this.#headers);
|
|
2410
|
+
this.tenants = new Tenants(this.config, this.#headers);
|
|
2411
|
+
this.auth = new Auth(this.config, this.#headers, {
|
|
2412
2412
|
resetHeaders: this.resetHeaders
|
|
2413
2413
|
});
|
|
2414
2414
|
};
|
|
@@ -2417,15 +2417,35 @@ var Api = class {
|
|
|
2417
2417
|
this.handlers = Handlers(this.routes, config);
|
|
2418
2418
|
};
|
|
2419
2419
|
resetHeaders = (headers) => {
|
|
2420
|
-
this
|
|
2420
|
+
this.#headers = new Headers(headers ?? {});
|
|
2421
2421
|
this.reset();
|
|
2422
2422
|
};
|
|
2423
2423
|
set headers(headers) {
|
|
2424
|
-
|
|
2424
|
+
const updates = [];
|
|
2425
|
+
if (headers instanceof Headers) {
|
|
2426
|
+
headers.forEach((value, key12) => {
|
|
2427
|
+
updates.push([key12.toLowerCase(), value]);
|
|
2428
|
+
});
|
|
2429
|
+
} else {
|
|
2430
|
+
for (const [key12, value] of Object.entries(headers)) {
|
|
2431
|
+
updates.push([key12.toLowerCase(), value]);
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
const merged = {};
|
|
2435
|
+
this.#headers?.forEach((value, key12) => {
|
|
2436
|
+
merged[key12.toLowerCase()] = value;
|
|
2437
|
+
});
|
|
2438
|
+
for (const [key12, value] of updates) {
|
|
2439
|
+
merged[key12] = value;
|
|
2440
|
+
}
|
|
2441
|
+
this.#headers = new Headers();
|
|
2442
|
+
for (const [key12, value] of Object.entries(merged)) {
|
|
2443
|
+
this.#headers.set(key12, value);
|
|
2444
|
+
}
|
|
2425
2445
|
this.reset();
|
|
2426
2446
|
}
|
|
2427
2447
|
get headers() {
|
|
2428
|
-
return this
|
|
2448
|
+
return this.#headers;
|
|
2429
2449
|
}
|
|
2430
2450
|
login = async (payload, config) => {
|
|
2431
2451
|
const [headers, loginRes] = await serverLogin(
|
|
@@ -2444,7 +2464,7 @@ var Api = class {
|
|
|
2444
2464
|
} else if (req instanceof Request) {
|
|
2445
2465
|
return auth(req, this.config);
|
|
2446
2466
|
}
|
|
2447
|
-
return this.auth.getSession(this
|
|
2467
|
+
return this.auth.getSession(this.#headers);
|
|
2448
2468
|
};
|
|
2449
2469
|
};
|
|
2450
2470
|
|