@technomoron/api-server-base 2.0.0-beta.22 → 2.0.0-beta.24
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/cjs/api-module.cjs +8 -0
- package/dist/cjs/api-module.d.ts +12 -0
- package/dist/cjs/api-server-base.cjs +573 -615
- package/dist/cjs/api-server-base.d.ts +97 -87
- package/dist/cjs/auth-api/{auth-module.js → auth-module.cjs} +96 -76
- package/dist/cjs/auth-api/auth-module.d.ts +1 -1
- package/dist/cjs/auth-api/{compat-auth-storage.js → compat-auth-storage.cjs} +4 -4
- package/dist/cjs/auth-api/{mem-auth-store.js → mem-auth-store.cjs} +7 -7
- package/dist/cjs/auth-api/{module.js → module.cjs} +1 -1
- package/dist/cjs/auth-api/schemas.cjs +171 -0
- package/dist/cjs/auth-api/schemas.d.ts +21 -0
- package/dist/cjs/auth-api/{sql-auth-store.js → sql-auth-store.cjs} +8 -8
- package/dist/cjs/auth-api/{user-id.js → user-id.cjs} +12 -3
- package/dist/cjs/auth-cookie-options.d.ts +5 -3
- package/dist/cjs/base/client-info.cjs +285 -0
- package/dist/cjs/base/client-info.d.ts +27 -0
- package/dist/cjs/base/error-utils.cjs +50 -0
- package/dist/cjs/base/error-utils.d.ts +16 -0
- package/dist/cjs/base/request-utils.cjs +27 -0
- package/dist/cjs/base/request-utils.d.ts +8 -0
- package/dist/cjs/index.cjs +24 -15
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/limiter/auth-rate-limiter.cjs +35 -0
- package/dist/cjs/limiter/auth-rate-limiter.d.ts +12 -0
- package/dist/cjs/limiter/fixed-window.cjs +41 -0
- package/dist/cjs/limiter/fixed-window.d.ts +11 -0
- package/dist/cjs/oauth/{base.js → base.cjs} +1 -0
- package/dist/cjs/oauth/base.d.ts +8 -1
- package/dist/cjs/oauth/{memory.js → memory.cjs} +7 -4
- package/dist/cjs/oauth/memory.d.ts +1 -1
- package/dist/cjs/oauth/{models.js → models.cjs} +2 -2
- package/dist/cjs/oauth/{sequelize.js → sequelize.cjs} +11 -7
- package/dist/cjs/oauth/sequelize.d.ts +1 -1
- package/dist/cjs/passkey/{base.js → base.cjs} +1 -0
- package/dist/cjs/passkey/base.d.ts +11 -0
- package/dist/cjs/passkey/{memory.js → memory.cjs} +2 -2
- package/dist/cjs/passkey/{models.js → models.cjs} +1 -1
- package/dist/cjs/passkey/{sequelize.js → sequelize.cjs} +3 -3
- package/dist/cjs/passkey/{service.js → service.cjs} +17 -3
- package/dist/cjs/passkey/service.d.ts +1 -1
- package/dist/cjs/{sequelize-utils.js → sequelize-utils.cjs} +4 -5
- package/dist/cjs/token/{base.js → base.cjs} +4 -0
- package/dist/cjs/token/base.d.ts +7 -0
- package/dist/cjs/token/{memory.js → memory.cjs} +15 -20
- package/dist/cjs/token/{sequelize.js → sequelize.cjs} +25 -11
- package/dist/cjs/upload/memory.cjs +92 -0
- package/dist/cjs/upload/memory.d.ts +17 -0
- package/dist/cjs/upload/tus-module.cjs +270 -0
- package/dist/cjs/upload/tus-module.d.ts +38 -0
- package/dist/cjs/upload/types.d.ts +28 -0
- package/dist/cjs/user/{base.js → base.cjs} +1 -0
- package/dist/cjs/user/base.d.ts +9 -0
- package/dist/cjs/user/{memory.js → memory.cjs} +29 -7
- package/dist/cjs/user/{sequelize.js → sequelize.cjs} +33 -8
- package/dist/cjs/user/types.cjs +2 -0
- package/dist/esm/api-module.d.ts +12 -0
- package/dist/esm/api-module.js +8 -0
- package/dist/esm/api-server-base.d.ts +97 -87
- package/dist/esm/api-server-base.js +562 -604
- package/dist/esm/auth-api/auth-module.d.ts +1 -1
- package/dist/esm/auth-api/auth-module.js +92 -72
- package/dist/esm/auth-api/compat-auth-storage.js +3 -3
- package/dist/esm/auth-api/schemas.d.ts +21 -0
- package/dist/esm/auth-api/schemas.js +168 -0
- package/dist/esm/auth-api/user-id.js +12 -3
- package/dist/esm/auth-cookie-options.d.ts +5 -3
- package/dist/esm/base/client-info.d.ts +27 -0
- package/dist/esm/base/client-info.js +282 -0
- package/dist/esm/base/error-utils.d.ts +16 -0
- package/dist/esm/base/error-utils.js +44 -0
- package/dist/esm/base/request-utils.d.ts +8 -0
- package/dist/esm/base/request-utils.js +23 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/limiter/auth-rate-limiter.d.ts +12 -0
- package/dist/esm/limiter/auth-rate-limiter.js +32 -0
- package/dist/esm/limiter/fixed-window.d.ts +11 -0
- package/dist/esm/limiter/fixed-window.js +37 -0
- package/dist/esm/oauth/base.d.ts +8 -1
- package/dist/esm/oauth/base.js +1 -0
- package/dist/esm/oauth/memory.d.ts +1 -1
- package/dist/esm/oauth/memory.js +5 -2
- package/dist/esm/oauth/sequelize.d.ts +1 -1
- package/dist/esm/oauth/sequelize.js +6 -2
- package/dist/esm/passkey/base.d.ts +11 -0
- package/dist/esm/passkey/base.js +1 -0
- package/dist/esm/passkey/service.d.ts +1 -1
- package/dist/esm/passkey/service.js +17 -3
- package/dist/esm/sequelize-utils.js +4 -5
- package/dist/esm/token/base.d.ts +7 -0
- package/dist/esm/token/base.js +4 -0
- package/dist/esm/token/memory.js +14 -19
- package/dist/esm/token/sequelize.js +22 -8
- package/dist/esm/upload/memory.d.ts +17 -0
- package/dist/esm/upload/memory.js +86 -0
- package/dist/esm/upload/tus-module.d.ts +38 -0
- package/dist/esm/upload/tus-module.js +266 -0
- package/dist/esm/upload/types.d.ts +28 -0
- package/dist/esm/upload/types.js +1 -0
- package/dist/esm/user/base.d.ts +9 -0
- package/dist/esm/user/base.js +1 -0
- package/dist/esm/user/memory.js +27 -5
- package/dist/esm/user/sequelize.js +30 -5
- package/docs/swagger/openapi.json +1 -1
- package/package.json +18 -17
- package/README.txt +0 -216
- /package/dist/cjs/auth-api/{storage.js → storage.cjs} +0 -0
- /package/dist/cjs/auth-api/{types.js → types.cjs} +0 -0
- /package/dist/cjs/{auth-cookie-options.js → auth-cookie-options.cjs} +0 -0
- /package/dist/cjs/oauth/{types.js → types.cjs} +0 -0
- /package/dist/cjs/passkey/{config.js → config.cjs} +0 -0
- /package/dist/cjs/passkey/{types.js → types.cjs} +0 -0
- /package/dist/cjs/token/{types.js → types.cjs} +0 -0
- /package/dist/cjs/{user/types.js → upload/types.cjs} +0 -0
|
@@ -4,27 +4,64 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { type FastifyInstance, type FastifyReply, type FastifyRequest } from 'fastify';
|
|
8
8
|
import { ApiModule } from './api-module.js';
|
|
9
|
+
import { type ClientInfo } from './base/client-info.js';
|
|
9
10
|
import { TokenStore, type JwtDecodeResult, type JwtSignPayload, type JwtSignResult, type JwtVerifyResult } from './token/base.js';
|
|
10
|
-
import type { ApiAuthClass, ApiAuthType, ApiKey } from './api-module.js';
|
|
11
|
+
import type { ApiAuthClass, ApiAuthType, ApiHandler, ApiKey } from './api-module.js';
|
|
11
12
|
import type { AuthProviderModule } from './auth-api/module.js';
|
|
12
13
|
import type { AuthAdapter, AuthIdentifier } from './auth-api/types.js';
|
|
13
|
-
import type { OAuthStore } from './oauth/base.js';
|
|
14
14
|
import type { AuthCodeData, AuthCodeRequest, OAuthClient } from './oauth/types.js';
|
|
15
|
-
import type { PasskeyService } from './passkey/service.js';
|
|
16
15
|
import type { PasskeyChallenge, PasskeyChallengeParams, StoredPasskeyCredential, PasskeyVerificationParams, PasskeyVerificationResult } from './passkey/types.js';
|
|
17
16
|
import type { Token } from './token/types.js';
|
|
18
|
-
import type { UserStore } from './user/base.js';
|
|
19
17
|
import type { JwtPayload, SignOptions, VerifyOptions } from 'jsonwebtoken';
|
|
20
|
-
export type { Application, Request, Response, NextFunction, Router } from 'express';
|
|
21
|
-
export type { Multer } from 'multer';
|
|
22
18
|
export type { JwtPayload, SignOptions, VerifyOptions } from 'jsonwebtoken';
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
export type { ClientAgentProfile, ClientInfo } from './base/client-info.js';
|
|
20
|
+
export interface ApiCookieOptions {
|
|
21
|
+
httpOnly?: boolean;
|
|
22
|
+
secure?: boolean;
|
|
23
|
+
sameSite?: 'lax' | 'strict' | 'none';
|
|
24
|
+
domain?: string;
|
|
25
|
+
path?: string;
|
|
26
|
+
maxAge?: number;
|
|
27
|
+
expires?: Date;
|
|
28
|
+
}
|
|
29
|
+
export interface ApiUploadedFile {
|
|
30
|
+
fieldname: string;
|
|
31
|
+
originalname: string;
|
|
32
|
+
encoding: string;
|
|
33
|
+
mimetype: string;
|
|
34
|
+
size?: number;
|
|
35
|
+
buffer?: Buffer;
|
|
36
|
+
filepath?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ExtendedReq {
|
|
39
|
+
method: string;
|
|
40
|
+
url: string;
|
|
41
|
+
originalUrl?: string;
|
|
42
|
+
headers: Record<string, string | string[] | undefined>;
|
|
43
|
+
query: Record<string, unknown>;
|
|
44
|
+
body: unknown;
|
|
45
|
+
params: Record<string, unknown>;
|
|
46
|
+
cookies?: Record<string, string>;
|
|
47
|
+
ip?: string;
|
|
48
|
+
ips?: string[];
|
|
49
|
+
socket?: {
|
|
50
|
+
remoteAddress?: string;
|
|
27
51
|
};
|
|
52
|
+
protocol?: string;
|
|
53
|
+
file?: ApiUploadedFile;
|
|
54
|
+
files?: ApiUploadedFile[] | Record<string, ApiUploadedFile[]>;
|
|
55
|
+
apiReq?: ApiRequest;
|
|
56
|
+
}
|
|
57
|
+
export interface ApiResponse {
|
|
58
|
+
locals: Record<string, unknown>;
|
|
59
|
+
headersSent: boolean;
|
|
60
|
+
status: (code: number) => ApiResponse;
|
|
61
|
+
json: (payload: unknown) => void;
|
|
62
|
+
send: (payload: unknown) => void;
|
|
63
|
+
cookie: (name: string, value: string, options?: ApiCookieOptions) => void;
|
|
64
|
+
clearCookie: (name: string, options?: ApiCookieOptions) => void;
|
|
28
65
|
}
|
|
29
66
|
export interface ApiTokenData extends JwtPayload, Partial<Token> {
|
|
30
67
|
uid: unknown;
|
|
@@ -35,12 +72,11 @@ export type ApiAuthMethod = 'bearer' | 'cookie' | 'param' | 'apikey' | null;
|
|
|
35
72
|
export interface ApiRequest {
|
|
36
73
|
server: ApiServer;
|
|
37
74
|
req: ExtendedReq;
|
|
38
|
-
res:
|
|
75
|
+
res: ApiResponse;
|
|
39
76
|
tokenData?: ApiTokenData | null;
|
|
40
77
|
token?: string;
|
|
41
78
|
authToken?: Token | null;
|
|
42
79
|
apiKey?: ApiKey | null;
|
|
43
|
-
/** How this request was authenticated. null when unauthenticated. */
|
|
44
80
|
authMethod?: ApiAuthMethod;
|
|
45
81
|
clientInfo?: ClientInfo;
|
|
46
82
|
realUid?: AuthIdentifier | null;
|
|
@@ -50,32 +86,13 @@ export interface ApiRequest {
|
|
|
50
86
|
getRealUid: () => AuthIdentifier | null;
|
|
51
87
|
isImpersonating: () => boolean;
|
|
52
88
|
}
|
|
53
|
-
export
|
|
54
|
-
apiReq?: ApiRequest;
|
|
55
|
-
}
|
|
89
|
+
export type ExpressApiRequest = ExtendedReq;
|
|
56
90
|
export interface ExpressApiLocals {
|
|
57
91
|
apiReq?: ApiRequest;
|
|
58
92
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
os: string;
|
|
63
|
-
device: string;
|
|
64
|
-
}
|
|
65
|
-
export interface ClientInfo extends ClientAgentProfile {
|
|
66
|
-
ip: string | null;
|
|
67
|
-
ipchain: string[];
|
|
68
|
-
}
|
|
69
|
-
export interface ApiServerAuthStores {
|
|
70
|
-
userStore: UserStore<unknown, unknown>;
|
|
71
|
-
tokenStore: TokenStore;
|
|
72
|
-
passkeyService?: PasskeyService;
|
|
73
|
-
oauthStore?: OAuthStore;
|
|
74
|
-
canImpersonate?: (params: {
|
|
75
|
-
realUserId: AuthIdentifier;
|
|
76
|
-
effectiveUserId: AuthIdentifier;
|
|
77
|
-
}) => boolean | Promise<boolean>;
|
|
78
|
-
}
|
|
93
|
+
type CompatNext = (error?: unknown) => void;
|
|
94
|
+
type CompatRequestHandler = (req: ExtendedReq, res: ApiResponse, next: CompatNext) => unknown;
|
|
95
|
+
type CompatErrorHandler = (err: unknown, req: ExtendedReq, res: ApiResponse, next: CompatNext) => unknown;
|
|
79
96
|
export { ApiModule } from './api-module.js';
|
|
80
97
|
export type { ApiHandler, ApiAuthType, ApiAuthClass, ApiRoute, ApiKey } from './api-module.js';
|
|
81
98
|
export interface ApiErrorParams {
|
|
@@ -103,32 +120,14 @@ export interface ApiServerConf {
|
|
|
103
120
|
swaggerPath?: string;
|
|
104
121
|
accessSecret: string;
|
|
105
122
|
refreshSecret: string;
|
|
106
|
-
/** Cookie domain for auth cookies. Prefer leaving empty for localhost/development. */
|
|
107
123
|
cookieDomain: string;
|
|
108
|
-
/** Cookie path for auth cookies. */
|
|
109
124
|
cookiePath?: string;
|
|
110
|
-
/** Cookie SameSite attribute for auth cookies. */
|
|
111
125
|
cookieSameSite?: 'lax' | 'strict' | 'none';
|
|
112
|
-
/**
|
|
113
|
-
* Cookie Secure attribute for auth cookies.
|
|
114
|
-
* - true: always secure
|
|
115
|
-
* - false: never secure
|
|
116
|
-
* - 'auto': secure when request is HTTPS (or forwarded as HTTPS)
|
|
117
|
-
*/
|
|
118
126
|
cookieSecure?: boolean | 'auto';
|
|
119
|
-
/** Cookie HttpOnly attribute for auth cookies. */
|
|
120
127
|
cookieHttpOnly?: boolean;
|
|
121
|
-
/** Prefix used for API keys in Authorization Bearer tokens. */
|
|
122
128
|
apiKeyPrefix: string;
|
|
123
|
-
/**
|
|
124
|
-
* Enable API key authentication on non-apikey routes (e.g. 'yes', 'strict', 'maybe').
|
|
125
|
-
* When false (default), API key lookups only run on routes with authType 'apikey'.
|
|
126
|
-
* Set to true if you need API keys to authenticate on JWT routes as well.
|
|
127
|
-
*/
|
|
128
129
|
apiKeyEnabled: boolean;
|
|
129
|
-
/** Optional request field name used to read auth tokens when Bearer is missing. */
|
|
130
130
|
tokenParam: string;
|
|
131
|
-
/** Where to read `tokenParam` from. */
|
|
132
131
|
tokenParamLocation: 'body' | 'query' | 'body-query';
|
|
133
132
|
accessCookie: string;
|
|
134
133
|
refreshCookie: string;
|
|
@@ -143,60 +142,51 @@ export interface ApiServerConf {
|
|
|
143
142
|
apiVersion: string;
|
|
144
143
|
minClientVersion: string;
|
|
145
144
|
tokenStore?: TokenStore;
|
|
146
|
-
authStores?: ApiServerAuthStores;
|
|
147
145
|
onStartError?: (error: Error) => void;
|
|
146
|
+
/**
|
|
147
|
+
* Controls trust in proxy headers (X-Forwarded-For, Forwarded, X-Real-IP).
|
|
148
|
+
* - `true` (default): trust all forwarded headers
|
|
149
|
+
* - `false`: only use the socket address, ignore forwarded headers
|
|
150
|
+
* - number: trust that many rightmost forwarded entries (e.g., 1 = one reverse proxy)
|
|
151
|
+
*/
|
|
152
|
+
trustProxy: boolean | number;
|
|
148
153
|
}
|
|
154
|
+
/** Core Fastify-based API server with module mounting and auth integration hooks. */
|
|
149
155
|
export declare class ApiServer {
|
|
150
|
-
app:
|
|
156
|
+
readonly app: ((req: import('node:http').IncomingMessage, res: import('node:http').ServerResponse) => void) & {
|
|
157
|
+
listen: (...args: unknown[]) => import('node:http').Server;
|
|
158
|
+
};
|
|
159
|
+
readonly fastify: FastifyInstance;
|
|
151
160
|
readonly config: ApiServerConf;
|
|
152
161
|
readonly startedAt: number;
|
|
153
162
|
private readonly apiBasePath;
|
|
154
|
-
private readonly apiRouter;
|
|
155
163
|
private finalized;
|
|
156
164
|
private storageAdapter;
|
|
157
165
|
private moduleAdapter;
|
|
158
|
-
private serverAuthAdapter;
|
|
159
|
-
private apiNotFoundHandler;
|
|
160
166
|
private apiErrorHandlerInstalled;
|
|
161
167
|
private tokenStoreAdapter;
|
|
162
|
-
private userStoreAdapter;
|
|
163
|
-
private passkeyServiceAdapter;
|
|
164
|
-
private oauthStoreAdapter;
|
|
165
|
-
private canImpersonateAdapter;
|
|
166
168
|
private readonly jwtHelper;
|
|
169
|
+
private compatGlobalErrorHandler;
|
|
170
|
+
private readonly readyPromise;
|
|
167
171
|
private currReqDeprecationWarned;
|
|
168
|
-
/**
|
|
169
|
-
* @deprecated ApiServer does not track a global "current request". This value is always null.
|
|
170
|
-
* Use the per-request ApiRequest passed to handlers, or `req.apiReq` / `res.locals.apiReq`
|
|
171
|
-
* when mounting raw Express endpoints.
|
|
172
|
-
*/
|
|
173
172
|
get currReq(): ApiRequest | null;
|
|
174
173
|
set currReq(_value: ApiRequest | null);
|
|
175
174
|
constructor(config?: Partial<ApiServerConf>);
|
|
175
|
+
private setupRuntime;
|
|
176
|
+
private readRawBody;
|
|
177
|
+
private parseRawBody;
|
|
176
178
|
private assertNotFinalized;
|
|
177
|
-
private toApiRouterPath;
|
|
178
179
|
finalize(): this;
|
|
179
180
|
authStorage<UserRow, SafeUser>(storage: AuthAdapter<UserRow, SafeUser>): this;
|
|
180
|
-
/**
|
|
181
|
-
* @deprecated Use {@link ApiServer.authStorage} instead.
|
|
182
|
-
*/
|
|
183
181
|
useAuthStorage<UserRow, SafeUser>(storage: AuthAdapter<UserRow, SafeUser>): this;
|
|
184
182
|
authModule<UserRow>(module: AuthProviderModule<UserRow>): this;
|
|
185
|
-
/**
|
|
186
|
-
* @deprecated Use {@link ApiServer.authModule} instead.
|
|
187
|
-
*/
|
|
188
183
|
useAuthModule<UserRow>(module: AuthProviderModule<UserRow>): this;
|
|
189
184
|
getAuthStorage<UserRow = unknown, SafeUser = unknown>(): AuthAdapter<UserRow, SafeUser>;
|
|
190
185
|
getAuthModule<UserRow = unknown>(): AuthProviderModule<UserRow>;
|
|
191
186
|
setTokenStore(store: TokenStore): this;
|
|
192
187
|
getTokenStore(): TokenStore | null;
|
|
193
|
-
private ensureUserStore;
|
|
194
|
-
private ensureTokenStore;
|
|
195
|
-
private ensurePasskeyService;
|
|
196
188
|
listUserCredentials(userId: AuthIdentifier): Promise<StoredPasskeyCredential[]>;
|
|
197
189
|
deletePasskeyCredential(credentialId: Buffer | string): Promise<boolean>;
|
|
198
|
-
private ensureOAuthStore;
|
|
199
|
-
private getServerAuthAdapter;
|
|
200
190
|
getUser(identifier: AuthIdentifier): Promise<unknown | null>;
|
|
201
191
|
getUserPasswordHash(user: unknown): string;
|
|
202
192
|
getUserId(user: unknown): AuthIdentifier;
|
|
@@ -236,17 +226,29 @@ export declare class ApiServer {
|
|
|
236
226
|
}): Promise<boolean>;
|
|
237
227
|
guessExceptionText(error: unknown, defMsg?: string): string;
|
|
238
228
|
protected authorize(apiReq: ApiRequest, requiredClass: ApiAuthClass): Promise<void>;
|
|
239
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Authenticate and authorise an incoming Fastify request outside of the
|
|
231
|
+
* standard `defineRoutes` pipeline (e.g. TUS upload routes that need full
|
|
232
|
+
* control over their own response format).
|
|
233
|
+
*
|
|
234
|
+
* Throws `ApiError` on auth failure — callers should catch it and respond
|
|
235
|
+
* with the appropriate HTTP status code.
|
|
236
|
+
*/
|
|
237
|
+
resolveRequest(request: FastifyRequest, reply: FastifyReply, auth: {
|
|
238
|
+
type: ApiAuthType;
|
|
239
|
+
req?: ApiAuthClass;
|
|
240
|
+
}): Promise<ApiRequest>;
|
|
240
241
|
private installStaticDirs;
|
|
241
242
|
private installPingHandler;
|
|
242
243
|
private loadSwaggerSpec;
|
|
244
|
+
private readPackageVersion;
|
|
243
245
|
private installSwaggerHandler;
|
|
244
246
|
private normalizeApiBasePath;
|
|
245
247
|
private installApiNotFoundHandler;
|
|
246
248
|
private installApiErrorHandler;
|
|
247
|
-
private describeMissingEndpoint;
|
|
248
249
|
start(): this;
|
|
249
250
|
private internalServerErrorMessage;
|
|
251
|
+
private logUnhandledError;
|
|
250
252
|
private verifyJWT;
|
|
251
253
|
private jwtCookieOptions;
|
|
252
254
|
private setAccessCookie;
|
|
@@ -261,16 +263,24 @@ export declare class ApiServer {
|
|
|
261
263
|
private normalizeAuthIdentifier;
|
|
262
264
|
private extractTokenUserId;
|
|
263
265
|
private resolveRealUserId;
|
|
264
|
-
|
|
265
|
-
useExpress(...handlers: Array<RequestHandler | ErrorRequestHandler>): this;
|
|
266
|
+
private toExtendedReq;
|
|
266
267
|
private createApiRequest;
|
|
268
|
+
useExpress(path: string, ...handlers: Array<CompatRequestHandler | CompatErrorHandler>): this;
|
|
269
|
+
useExpress(...handlers: Array<CompatRequestHandler | CompatErrorHandler>): this;
|
|
270
|
+
private runCompatHandlers;
|
|
271
|
+
private runCompatErrorHandlers;
|
|
267
272
|
expressAuth(auth: {
|
|
268
273
|
type: ApiAuthType;
|
|
269
274
|
req: ApiAuthClass;
|
|
270
|
-
}):
|
|
271
|
-
expressErrorHandler():
|
|
272
|
-
private
|
|
275
|
+
}): CompatRequestHandler;
|
|
276
|
+
expressErrorHandler(): CompatErrorHandler;
|
|
277
|
+
private handleRequest;
|
|
278
|
+
protected handle_request(handler: ApiHandler, auth: {
|
|
279
|
+
type: ApiAuthType;
|
|
280
|
+
req: ApiAuthClass;
|
|
281
|
+
}): (req: ExtendedReq, res: ApiResponse, next: (error?: unknown) => void) => Promise<void>;
|
|
273
282
|
api<T extends ApiModule<unknown>>(module: T): this;
|
|
283
|
+
private joinRoutePath;
|
|
274
284
|
dumpRequest(apiReq: ApiRequest): void;
|
|
275
285
|
private formatDebugValue;
|
|
276
286
|
dumpResponse(apiReq: ApiRequest, payload: unknown, status: number): void;
|