@opra/core 1.0.0-beta.2 → 1.0.0-beta.4
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/cjs/{http/impl/asset-cache.js → asset-cache.js} +6 -0
- package/cjs/execution-context.js +3 -14
- package/cjs/index.js +3 -25
- package/cjs/platform-adapter.js +3 -3
- package/cjs/{helpers/service-base.js → service-base.js} +9 -4
- package/esm/{http/impl/asset-cache.js → asset-cache.js} +6 -0
- package/esm/execution-context.js +2 -13
- package/esm/index.js +3 -24
- package/esm/platform-adapter.js +2 -2
- package/esm/{helpers/service-base.js → service-base.js} +9 -4
- package/package.json +5 -39
- package/types/{http/impl/asset-cache.d.ts → asset-cache.d.ts} +1 -0
- package/types/execution-context.d.ts +4 -8
- package/types/index.d.cts +3 -23
- package/types/index.d.ts +3 -23
- package/types/interfaces/logger.interface.d.ts +1 -1
- package/types/platform-adapter.d.ts +3 -3
- package/types/service-base.d.ts +11 -0
- package/cjs/augmentation/http-controller.augmentation.js +0 -25
- package/cjs/http/express-adapter.js +0 -155
- package/cjs/http/http-adapter.js +0 -24
- package/cjs/http/http-context.js +0 -104
- package/cjs/http/http-handler.js +0 -609
- package/cjs/http/impl/http-incoming.host.js +0 -112
- package/cjs/http/impl/http-outgoing.host.js +0 -207
- package/cjs/http/impl/multipart-reader.js +0 -196
- package/cjs/http/impl/node-incoming-message.host.js +0 -109
- package/cjs/http/impl/node-outgoing-message.host.js +0 -195
- package/cjs/http/interfaces/http-incoming.interface.js +0 -25
- package/cjs/http/interfaces/http-outgoing.interface.js +0 -22
- package/cjs/http/interfaces/node-incoming-message.interface.js +0 -64
- package/cjs/http/interfaces/node-outgoing-message.interface.js +0 -15
- package/cjs/http/utils/body-reader.js +0 -216
- package/cjs/http/utils/common.js +0 -67
- package/cjs/http/utils/concat-readable.js +0 -19
- package/cjs/http/utils/convert-to-headers.js +0 -64
- package/cjs/http/utils/convert-to-raw-headers.js +0 -23
- package/cjs/http/utils/match-known-fields.js +0 -49
- package/cjs/http/utils/wrap-exception.js +0 -33
- package/cjs/type-guards.js +0 -22
- package/esm/augmentation/http-controller.augmentation.js +0 -23
- package/esm/http/express-adapter.js +0 -150
- package/esm/http/http-adapter.js +0 -20
- package/esm/http/http-context.js +0 -99
- package/esm/http/http-handler.js +0 -604
- package/esm/http/impl/http-incoming.host.js +0 -107
- package/esm/http/impl/http-outgoing.host.js +0 -202
- package/esm/http/impl/multipart-reader.js +0 -191
- package/esm/http/impl/node-incoming-message.host.js +0 -105
- package/esm/http/impl/node-outgoing-message.host.js +0 -191
- package/esm/http/interfaces/http-incoming.interface.js +0 -22
- package/esm/http/interfaces/http-outgoing.interface.js +0 -19
- package/esm/http/interfaces/node-incoming-message.interface.js +0 -61
- package/esm/http/interfaces/node-outgoing-message.interface.js +0 -12
- package/esm/http/utils/body-reader.js +0 -211
- package/esm/http/utils/common.js +0 -61
- package/esm/http/utils/concat-readable.js +0 -16
- package/esm/http/utils/convert-to-headers.js +0 -60
- package/esm/http/utils/convert-to-raw-headers.js +0 -20
- package/esm/http/utils/match-known-fields.js +0 -45
- package/esm/http/utils/wrap-exception.js +0 -30
- package/esm/type-guards.js +0 -16
- package/types/augmentation/http-controller.augmentation.d.ts +0 -20
- package/types/helpers/service-base.d.ts +0 -10
- package/types/http/express-adapter.d.ts +0 -13
- package/types/http/http-adapter.d.ts +0 -54
- package/types/http/http-context.d.ts +0 -44
- package/types/http/http-handler.d.ts +0 -75
- package/types/http/impl/http-incoming.host.d.ts +0 -22
- package/types/http/impl/http-outgoing.host.d.ts +0 -17
- package/types/http/impl/multipart-reader.d.ts +0 -46
- package/types/http/impl/node-incoming-message.host.d.ts +0 -45
- package/types/http/impl/node-outgoing-message.host.d.ts +0 -49
- package/types/http/interfaces/http-incoming.interface.d.ts +0 -192
- package/types/http/interfaces/http-outgoing.interface.d.ts +0 -144
- package/types/http/interfaces/node-incoming-message.interface.d.ts +0 -36
- package/types/http/interfaces/node-outgoing-message.interface.d.ts +0 -27
- package/types/http/utils/body-reader.d.ts +0 -38
- package/types/http/utils/common.d.ts +0 -17
- package/types/http/utils/concat-readable.d.ts +0 -2
- package/types/http/utils/convert-to-headers.d.ts +0 -2
- package/types/http/utils/convert-to-raw-headers.d.ts +0 -2
- package/types/http/utils/match-known-fields.d.ts +0 -6
- package/types/http/utils/wrap-exception.d.ts +0 -2
- package/types/type-guards.d.ts +0 -8
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { HttpHeaderCodes } from '@opra/common';
|
|
2
|
-
export const NO_DUPLICATES_FIELD = 0;
|
|
3
|
-
export const COMMA_DELIMITED_FIELD = 1;
|
|
4
|
-
export const SEMICOLON_DELIMITED_FIELD = 2;
|
|
5
|
-
export const ARRAY_FIELD = 3;
|
|
6
|
-
const ARRAY_HEADERS = ['set-cookie'];
|
|
7
|
-
const NO_DUPLICATES_HEADERS = [
|
|
8
|
-
'age',
|
|
9
|
-
'from',
|
|
10
|
-
'etag',
|
|
11
|
-
'server',
|
|
12
|
-
'referer',
|
|
13
|
-
'referrer',
|
|
14
|
-
'expires',
|
|
15
|
-
'location',
|
|
16
|
-
'user-agent',
|
|
17
|
-
'retry-after',
|
|
18
|
-
'content-type',
|
|
19
|
-
'content-length',
|
|
20
|
-
'max-forwards',
|
|
21
|
-
'last-modified',
|
|
22
|
-
'authorization',
|
|
23
|
-
'proxy-authorization',
|
|
24
|
-
'if-modified-since',
|
|
25
|
-
'if-unmodified-since',
|
|
26
|
-
];
|
|
27
|
-
const SEMICOLON_DELIMITED_HEADERS = ['cookie'];
|
|
28
|
-
const KNOWN_FIELDS = Object.values(HttpHeaderCodes).reduce((o, k) => {
|
|
29
|
-
const n = k.toLowerCase();
|
|
30
|
-
o[n] = [
|
|
31
|
-
k,
|
|
32
|
-
NO_DUPLICATES_HEADERS.includes(n)
|
|
33
|
-
? NO_DUPLICATES_FIELD
|
|
34
|
-
: ARRAY_HEADERS.includes(n)
|
|
35
|
-
? ARRAY_FIELD
|
|
36
|
-
: SEMICOLON_DELIMITED_HEADERS.includes(n)
|
|
37
|
-
? SEMICOLON_DELIMITED_FIELD
|
|
38
|
-
: COMMA_DELIMITED_FIELD,
|
|
39
|
-
];
|
|
40
|
-
return o;
|
|
41
|
-
}, {});
|
|
42
|
-
export function matchKnownFields(field) {
|
|
43
|
-
const x = KNOWN_FIELDS[field.toLowerCase()];
|
|
44
|
-
return x ? x : [field, COMMA_DELIMITED_FIELD];
|
|
45
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { BadRequestError, FailedDependencyError, ForbiddenError, InternalServerError, MethodNotAllowedError, NotAcceptableError, NotFoundError, OpraHttpError, UnauthorizedError, UnprocessableEntityError, } from '@opra/common';
|
|
2
|
-
export function wrapException(error) {
|
|
3
|
-
if (error instanceof OpraHttpError)
|
|
4
|
-
return error;
|
|
5
|
-
let status = 500;
|
|
6
|
-
if (typeof error.status === 'number')
|
|
7
|
-
status = error.status;
|
|
8
|
-
else if (typeof error.getStatus === 'function')
|
|
9
|
-
status = error.getStatus();
|
|
10
|
-
switch (status) {
|
|
11
|
-
case 400:
|
|
12
|
-
return new BadRequestError(error);
|
|
13
|
-
case 401:
|
|
14
|
-
return new UnauthorizedError(error);
|
|
15
|
-
case 403:
|
|
16
|
-
return new ForbiddenError(error);
|
|
17
|
-
case 404:
|
|
18
|
-
return new NotFoundError(error);
|
|
19
|
-
case 405:
|
|
20
|
-
return new MethodNotAllowedError(error);
|
|
21
|
-
case 406:
|
|
22
|
-
return new NotAcceptableError(error);
|
|
23
|
-
case 422:
|
|
24
|
-
return new UnprocessableEntityError(error);
|
|
25
|
-
case 424:
|
|
26
|
-
return new FailedDependencyError(error);
|
|
27
|
-
default:
|
|
28
|
-
return new InternalServerError(error);
|
|
29
|
-
}
|
|
30
|
-
}
|
package/esm/type-guards.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { isReadable, isStream } from '@opra/common';
|
|
2
|
-
export function isNodeIncomingMessage(v) {
|
|
3
|
-
return v && typeof v.method === 'string' && Array.isArray(v.rawHeaders) && isReadable(v);
|
|
4
|
-
}
|
|
5
|
-
export function isHttpIncoming(v) {
|
|
6
|
-
return (isNodeIncomingMessage(v) &&
|
|
7
|
-
typeof v.header === 'function' &&
|
|
8
|
-
typeof v.acceptsLanguages === 'function' &&
|
|
9
|
-
typeof v.readBody === 'function');
|
|
10
|
-
}
|
|
11
|
-
export function isNodeOutgoingMessage(v) {
|
|
12
|
-
return v && typeof v.getHeaders === 'function' && isStream(v);
|
|
13
|
-
}
|
|
14
|
-
export function isHttpOutgoing(v) {
|
|
15
|
-
return isNodeOutgoingMessage(v) && typeof v.clearCookie === 'function' && typeof v.cookie === 'function';
|
|
16
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { HttpContext } from '../http/http-context';
|
|
2
|
-
declare module '@opra/common' {
|
|
3
|
-
interface HttpControllerStatic {
|
|
4
|
-
OnInit(): PropertyDecorator;
|
|
5
|
-
OnShutdown(): PropertyDecorator;
|
|
6
|
-
}
|
|
7
|
-
interface HttpController {
|
|
8
|
-
onInit?: (resource: HttpController) => void;
|
|
9
|
-
onShutdown?: (resource: HttpController) => void | Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
namespace HttpController {
|
|
12
|
-
interface InitArguments {
|
|
13
|
-
onInit?: (resource: HttpController) => void;
|
|
14
|
-
onShutdown?: (resource: HttpController) => void | Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
namespace HttpOperation {
|
|
18
|
-
type Context = HttpContext;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Nullish } from 'ts-gems';
|
|
2
|
-
import type { HttpContext } from '../http/http-context';
|
|
3
|
-
export declare abstract class ServiceBase {
|
|
4
|
-
protected _context: HttpContext;
|
|
5
|
-
get context(): HttpContext;
|
|
6
|
-
for<C extends HttpContext, P extends Partial<this>>(context: C, overwriteProperties?: Nullish<P>, overwriteContext?: Partial<C>): this & Required<P>;
|
|
7
|
-
}
|
|
8
|
-
export declare namespace ServiceBase {
|
|
9
|
-
const extendSymbol: unique symbol;
|
|
10
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ApiDocument, HttpController } from '@opra/common';
|
|
2
|
-
import { type Application } from 'express';
|
|
3
|
-
import { HttpAdapter } from './http-adapter.js';
|
|
4
|
-
export declare class ExpressAdapter extends HttpAdapter {
|
|
5
|
-
readonly app: Application;
|
|
6
|
-
protected _controllerInstances: Map<HttpController, any>;
|
|
7
|
-
constructor(app: Application, document: ApiDocument, options?: HttpAdapter.Options);
|
|
8
|
-
get platform(): string;
|
|
9
|
-
close(): Promise<void>;
|
|
10
|
-
getControllerInstance<T>(controllerPath: string): T | undefined;
|
|
11
|
-
protected _initRouter(basePath?: string): void;
|
|
12
|
-
protected _createControllers(controller: HttpController): void;
|
|
13
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ApiDocument, HttpApi, OpraSchema } from '@opra/common';
|
|
2
|
-
import { PlatformAdapter } from '../platform-adapter.js';
|
|
3
|
-
import { HttpContext } from './http-context.js';
|
|
4
|
-
import { HttpHandler } from './http-handler.js';
|
|
5
|
-
export declare namespace HttpAdapter {
|
|
6
|
-
type NextCallback = () => Promise<void>;
|
|
7
|
-
/**
|
|
8
|
-
* @type InterceptorFunction
|
|
9
|
-
*/
|
|
10
|
-
type InterceptorFunction = IHttpInterceptor['intercept'];
|
|
11
|
-
/**
|
|
12
|
-
* @interface IHttpInterceptor
|
|
13
|
-
*/
|
|
14
|
-
type IHttpInterceptor = {
|
|
15
|
-
intercept(context: HttpContext, next: NextCallback): Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
interface Options extends PlatformAdapter.Options {
|
|
18
|
-
basePath?: string;
|
|
19
|
-
interceptors?: (InterceptorFunction | IHttpInterceptor)[];
|
|
20
|
-
}
|
|
21
|
-
type EventFunction = (context: HttpContext) => void | Promise<void>;
|
|
22
|
-
interface Events {
|
|
23
|
-
createContext: EventFunction;
|
|
24
|
-
error: EventFunction;
|
|
25
|
-
request: EventFunction;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export interface HttpAdapter {
|
|
29
|
-
addListener<Event extends keyof HttpAdapter.Events>(event: Event, listener: HttpAdapter.Events[Event]): this;
|
|
30
|
-
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
31
|
-
on<Event extends keyof HttpAdapter.Events>(event: Event, listener: HttpAdapter.Events[Event]): this;
|
|
32
|
-
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
33
|
-
once<Event extends keyof HttpAdapter.Events>(event: Event, listener: HttpAdapter.Events[Event]): this;
|
|
34
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
35
|
-
removeListener<Event extends keyof HttpAdapter.Events>(event: Event, listener: HttpAdapter.Events[Event]): this;
|
|
36
|
-
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
37
|
-
off<Event extends keyof HttpAdapter.Events>(event: Event, listener: HttpAdapter.Events[Event]): this;
|
|
38
|
-
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
39
|
-
prependListener<Event extends keyof HttpAdapter.Events>(event: Event, listener: HttpAdapter.Events[Event]): this;
|
|
40
|
-
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
41
|
-
prependOnceListener<Event extends keyof HttpAdapter.Events>(event: Event, listener: HttpAdapter.Events[Event]): this;
|
|
42
|
-
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
* @class HttpAdapter
|
|
47
|
-
*/
|
|
48
|
-
export declare abstract class HttpAdapter extends PlatformAdapter {
|
|
49
|
-
readonly handler: HttpHandler;
|
|
50
|
-
readonly protocol: OpraSchema.Protocol;
|
|
51
|
-
interceptors: (HttpAdapter.InterceptorFunction | HttpAdapter.IHttpInterceptor)[];
|
|
52
|
-
protected constructor(document: ApiDocument, options?: HttpAdapter.Options);
|
|
53
|
-
get api(): HttpApi;
|
|
54
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { HttpController, HttpMediaType, HttpOperation, OpraSchema } from '@opra/common';
|
|
2
|
-
import { ExecutionContext } from '../execution-context.js';
|
|
3
|
-
import type { HttpAdapter } from './http-adapter';
|
|
4
|
-
import { MultipartReader } from './impl/multipart-reader.js';
|
|
5
|
-
import type { HttpIncoming } from './interfaces/http-incoming.interface.js';
|
|
6
|
-
import type { HttpOutgoing } from './interfaces/http-outgoing.interface.js';
|
|
7
|
-
export declare namespace HttpContext {
|
|
8
|
-
interface Initiator extends Omit<ExecutionContext.Initiator, 'document' | 'protocol'> {
|
|
9
|
-
adapter: HttpAdapter;
|
|
10
|
-
request: HttpIncoming;
|
|
11
|
-
response: HttpOutgoing;
|
|
12
|
-
controller?: HttpController;
|
|
13
|
-
controllerInstance?: any;
|
|
14
|
-
operation?: HttpOperation;
|
|
15
|
-
operationHandler?: Function;
|
|
16
|
-
cookies?: Record<string, any>;
|
|
17
|
-
headers?: Record<string, any>;
|
|
18
|
-
pathParams?: Record<string, any>;
|
|
19
|
-
queryParams?: Record<string, any>;
|
|
20
|
-
mediaType?: HttpMediaType;
|
|
21
|
-
body?: any;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export declare class HttpContext extends ExecutionContext {
|
|
25
|
-
protected _body?: any;
|
|
26
|
-
protected _multipartReader?: MultipartReader;
|
|
27
|
-
readonly protocol: OpraSchema.Protocol;
|
|
28
|
-
readonly adapter: HttpAdapter;
|
|
29
|
-
readonly controller?: HttpController;
|
|
30
|
-
readonly controllerInstance?: any;
|
|
31
|
-
readonly operation?: HttpOperation;
|
|
32
|
-
readonly operationHandler?: Function;
|
|
33
|
-
readonly request: HttpIncoming;
|
|
34
|
-
readonly response: HttpOutgoing;
|
|
35
|
-
readonly mediaType?: HttpMediaType;
|
|
36
|
-
readonly cookies: Record<string, any>;
|
|
37
|
-
readonly headers: Record<string, any>;
|
|
38
|
-
readonly pathParams: Record<string, any>;
|
|
39
|
-
readonly queryParams: Record<string, any>;
|
|
40
|
-
constructor(init: HttpContext.Initiator);
|
|
41
|
-
get isMultipart(): boolean;
|
|
42
|
-
getMultipartReader(): Promise<MultipartReader>;
|
|
43
|
-
getBody<T>(): Promise<T>;
|
|
44
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { HttpOperationResponse, OpraException, OpraHttpError } from '@opra/common';
|
|
2
|
-
import { kAssetCache } from '../constants.js';
|
|
3
|
-
import type { HttpAdapter } from './http-adapter.js';
|
|
4
|
-
import { HttpContext } from './http-context.js';
|
|
5
|
-
import { AssetCache } from './impl/asset-cache.js';
|
|
6
|
-
/**
|
|
7
|
-
* @namespace
|
|
8
|
-
*/
|
|
9
|
-
export declare namespace HttpHandler {
|
|
10
|
-
/**
|
|
11
|
-
* @interface ResponseArgs
|
|
12
|
-
*/
|
|
13
|
-
interface ResponseArgs {
|
|
14
|
-
statusCode: number;
|
|
15
|
-
contentType?: string;
|
|
16
|
-
operationResponse?: HttpOperationResponse;
|
|
17
|
-
body?: any;
|
|
18
|
-
projection?: string[] | '*';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @class HttpHandler
|
|
23
|
-
*/
|
|
24
|
-
export declare class HttpHandler {
|
|
25
|
-
readonly adapter: HttpAdapter;
|
|
26
|
-
protected [kAssetCache]: AssetCache;
|
|
27
|
-
onError?: (context: HttpContext, error: OpraException) => void | Promise<void>;
|
|
28
|
-
constructor(adapter: HttpAdapter);
|
|
29
|
-
/**
|
|
30
|
-
* Main http request handler
|
|
31
|
-
* @param context
|
|
32
|
-
* @protected
|
|
33
|
-
*/
|
|
34
|
-
handleRequest(context: HttpContext): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param context
|
|
38
|
-
*/
|
|
39
|
-
parseRequest(context: HttpContext): Promise<void>;
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @param context
|
|
43
|
-
* @protected
|
|
44
|
-
*/
|
|
45
|
-
protected _parseParameters(context: HttpContext): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* @param context
|
|
49
|
-
* @protected
|
|
50
|
-
*/
|
|
51
|
-
protected _parseContentType(context: HttpContext): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
* @param context
|
|
55
|
-
* @protected
|
|
56
|
-
*/
|
|
57
|
-
protected _executeRequest(context: HttpContext): Promise<any>;
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
* @param context
|
|
61
|
-
* @param responseValue
|
|
62
|
-
* @protected
|
|
63
|
-
*/
|
|
64
|
-
sendResponse(context: HttpContext, responseValue?: any): Promise<void>;
|
|
65
|
-
protected _sendErrorResponse(context: HttpContext): Promise<void>;
|
|
66
|
-
sendDocumentSchema(context: HttpContext): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
* @param context
|
|
70
|
-
* @param body
|
|
71
|
-
* @protected
|
|
72
|
-
*/
|
|
73
|
-
protected _determineResponseArgs(context: HttpContext, body: any): HttpHandler.ResponseArgs;
|
|
74
|
-
protected _wrapExceptions(exceptions: any[]): OpraHttpError[];
|
|
75
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import parseRange from 'range-parser';
|
|
2
|
-
import type { HttpIncoming } from '../interfaces/http-incoming.interface.js';
|
|
3
|
-
import { BodyReader } from '../utils/body-reader.js';
|
|
4
|
-
export interface HttpIncomingHost extends HttpIncoming {
|
|
5
|
-
}
|
|
6
|
-
export declare class HttpIncomingHost implements HttpIncoming {
|
|
7
|
-
body?: any;
|
|
8
|
-
get protocol(): string;
|
|
9
|
-
get secure(): boolean;
|
|
10
|
-
get hostname(): string | undefined;
|
|
11
|
-
get fresh(): boolean;
|
|
12
|
-
get xhr(): boolean;
|
|
13
|
-
header(name: string): any;
|
|
14
|
-
get(name: string): any;
|
|
15
|
-
accepts(...types: any): any;
|
|
16
|
-
acceptsCharsets(...charsets: any): any;
|
|
17
|
-
acceptsEncodings(...encoding: any): any;
|
|
18
|
-
acceptsLanguages(...lang: any): any;
|
|
19
|
-
is(type: string | string[], ...otherTypes: string[]): string | false | null;
|
|
20
|
-
range(size: number, options: any): parseRange.Ranges | parseRange.Result | undefined;
|
|
21
|
-
readBody(options: BodyReader.Options): Promise<string | Buffer | undefined>;
|
|
22
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CookieOptions, HttpOutgoing } from '../interfaces/http-outgoing.interface.js';
|
|
2
|
-
export interface HttpOutgoingHost extends HttpOutgoing {
|
|
3
|
-
}
|
|
4
|
-
export declare class HttpOutgoingHost {
|
|
5
|
-
attachment(filename?: string): this;
|
|
6
|
-
contentType(type: any): this;
|
|
7
|
-
setHeader(field: string | Record<string, any>, val?: any): this;
|
|
8
|
-
clearCookie(name: string, options: CookieOptions): this;
|
|
9
|
-
cookie(name: string, value: any, options?: CookieOptions): this;
|
|
10
|
-
status(code: number): this;
|
|
11
|
-
sendStatus(statusCode: number): this;
|
|
12
|
-
links(links: Record<string, string>): this;
|
|
13
|
-
location(url: string): this;
|
|
14
|
-
redirect(arg0: string | number, arg1?: string): void;
|
|
15
|
-
send(body: any): this;
|
|
16
|
-
vary(field: string): this;
|
|
17
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { HttpMediaType } from '@opra/common';
|
|
2
|
-
import busboy from 'busboy';
|
|
3
|
-
import { EventEmitter } from 'events';
|
|
4
|
-
import type { StrictOmit } from 'ts-gems';
|
|
5
|
-
import { HttpContext } from '../http-context.js';
|
|
6
|
-
export declare namespace MultipartReader {
|
|
7
|
-
interface Options extends StrictOmit<busboy.BusboyConfig, 'headers'> {
|
|
8
|
-
tempDirectory?: string;
|
|
9
|
-
}
|
|
10
|
-
interface FieldInfo {
|
|
11
|
-
kind: 'field';
|
|
12
|
-
field: string;
|
|
13
|
-
value?: any;
|
|
14
|
-
mimeType?: string;
|
|
15
|
-
encoding?: string;
|
|
16
|
-
}
|
|
17
|
-
interface FileInfo {
|
|
18
|
-
kind: 'file';
|
|
19
|
-
field: string;
|
|
20
|
-
filename: string;
|
|
21
|
-
storedPath: string;
|
|
22
|
-
mimeType?: string;
|
|
23
|
-
encoding?: string;
|
|
24
|
-
}
|
|
25
|
-
type Item = FieldInfo | FileInfo;
|
|
26
|
-
}
|
|
27
|
-
export declare class MultipartReader extends EventEmitter {
|
|
28
|
-
protected context: HttpContext;
|
|
29
|
-
protected mediaType?: HttpMediaType | undefined;
|
|
30
|
-
protected _started: boolean;
|
|
31
|
-
protected _finished: boolean;
|
|
32
|
-
protected _cancelled: boolean;
|
|
33
|
-
protected _form: busboy.Busboy;
|
|
34
|
-
protected _items: MultipartReader.Item[];
|
|
35
|
-
protected _stack: MultipartReader.Item[];
|
|
36
|
-
protected tempDirectory: string;
|
|
37
|
-
constructor(context: HttpContext, options?: MultipartReader.Options, mediaType?: HttpMediaType | undefined);
|
|
38
|
-
get items(): MultipartReader.Item[];
|
|
39
|
-
getNext(): Promise<MultipartReader.Item | undefined>;
|
|
40
|
-
getAll(): Promise<MultipartReader.Item[]>;
|
|
41
|
-
getAll_(): Promise<MultipartReader.Item[]>;
|
|
42
|
-
cancel(): void;
|
|
43
|
-
resume(): void;
|
|
44
|
-
pause(): void;
|
|
45
|
-
purge(): Promise<PromiseSettledResult<any>[]>;
|
|
46
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type HTTPParserJS } from '@browsery/http-parser';
|
|
2
|
-
import type { IncomingHttpHeaders } from 'http';
|
|
3
|
-
import { Duplex, Readable } from 'stream';
|
|
4
|
-
import type { NodeIncomingMessage } from '../interfaces/node-incoming-message.interface.js';
|
|
5
|
-
export declare const CRLF: Buffer;
|
|
6
|
-
export declare const kHeaders: unique symbol;
|
|
7
|
-
export declare const kHeadersDistinct: unique symbol;
|
|
8
|
-
export declare const kTrailers: unique symbol;
|
|
9
|
-
export declare const kTrailersDistinct: unique symbol;
|
|
10
|
-
export declare const kHttpParser: unique symbol;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @class NodeIncomingMessageHost
|
|
14
|
-
*/
|
|
15
|
-
export declare class NodeIncomingMessageHost extends Duplex implements NodeIncomingMessage {
|
|
16
|
-
protected [kHeaders]?: IncomingHttpHeaders;
|
|
17
|
-
protected [kHeadersDistinct]?: NodeJS.Dict<string[]>;
|
|
18
|
-
protected [kTrailers]?: NodeJS.Dict<string>;
|
|
19
|
-
protected [kTrailersDistinct]?: NodeJS.Dict<string[]>;
|
|
20
|
-
protected [kHttpParser]: HTTPParserJS | undefined;
|
|
21
|
-
protected _readStream?: Readable;
|
|
22
|
-
httpVersionMajor: number;
|
|
23
|
-
httpVersionMinor: number;
|
|
24
|
-
method: string;
|
|
25
|
-
url: string;
|
|
26
|
-
rawHeaders: string[];
|
|
27
|
-
rawTrailers: string[];
|
|
28
|
-
params?: Record<string, any>;
|
|
29
|
-
cookies?: Record<string, any>;
|
|
30
|
-
body?: Buffer;
|
|
31
|
-
complete: boolean;
|
|
32
|
-
ip?: string;
|
|
33
|
-
ips?: string[];
|
|
34
|
-
joinDuplicateHeaders: boolean;
|
|
35
|
-
constructor(init?: NodeIncomingMessage.Initiator);
|
|
36
|
-
get httpVersion(): string;
|
|
37
|
-
get headers(): IncomingHttpHeaders;
|
|
38
|
-
set headers(headers: IncomingHttpHeaders);
|
|
39
|
-
get headersDistinct(): NodeJS.Dict<string[]>;
|
|
40
|
-
get trailers(): NodeJS.Dict<string>;
|
|
41
|
-
set trailers(trailers: NodeJS.Dict<string>);
|
|
42
|
-
get trailersDistinct(): NodeJS.Dict<string[]>;
|
|
43
|
-
_read(size: number): void;
|
|
44
|
-
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
45
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { OutgoingHttpHeaders } from 'http';
|
|
2
|
-
import { Duplex } from 'stream';
|
|
3
|
-
import type { NodeIncomingMessage } from '../interfaces/node-incoming-message.interface.js';
|
|
4
|
-
import type { NodeOutgoingMessage } from '../interfaces/node-outgoing-message.interface.js';
|
|
5
|
-
export declare const kOutHeaders: unique symbol;
|
|
6
|
-
export declare const kOutTrailers: unique symbol;
|
|
7
|
-
declare global {
|
|
8
|
-
interface Headers {
|
|
9
|
-
keys(): IterableIterator<string>;
|
|
10
|
-
entries(): IterableIterator<[string, any]>;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @class NodeOutgoingMessageHost
|
|
16
|
-
*/
|
|
17
|
-
export declare class NodeOutgoingMessageHost extends Duplex implements NodeOutgoingMessage {
|
|
18
|
-
protected [kOutHeaders]?: Record<string, any>;
|
|
19
|
-
protected [kOutTrailers]?: Record<string, any>;
|
|
20
|
-
protected _headersSent: boolean;
|
|
21
|
-
protected _httpVersionMajor?: number;
|
|
22
|
-
protected _httpVersionMinor?: number;
|
|
23
|
-
finished: boolean;
|
|
24
|
-
req: NodeIncomingMessage;
|
|
25
|
-
statusCode: number;
|
|
26
|
-
statusMessage: string;
|
|
27
|
-
chunkedEncoding: boolean;
|
|
28
|
-
sendDate: boolean;
|
|
29
|
-
strictContentLength: boolean;
|
|
30
|
-
body?: any;
|
|
31
|
-
constructor(init?: NodeOutgoingMessage.Initiator);
|
|
32
|
-
get httpVersionMajor(): number | undefined;
|
|
33
|
-
get httpVersionMinor(): number | undefined;
|
|
34
|
-
get headersSent(): boolean;
|
|
35
|
-
appendHeader(name: string, value: number | string | readonly string[]): this;
|
|
36
|
-
addTrailers(headers: OutgoingHttpHeaders | [string, string][] | readonly [string, string][]): void;
|
|
37
|
-
flushHeaders(): void;
|
|
38
|
-
setHeader(name: string, value: number | string | readonly string[]): this;
|
|
39
|
-
setHeaders(headers: Headers | Map<string, any> | Record<string, any>): this;
|
|
40
|
-
getHeader(name: string): any;
|
|
41
|
-
getHeaderNames(): string[];
|
|
42
|
-
getRawHeaderNames(): string[];
|
|
43
|
-
getHeaders(): OutgoingHttpHeaders;
|
|
44
|
-
hasHeader(name: string): boolean;
|
|
45
|
-
removeHeader(name: string): void;
|
|
46
|
-
end(cb?: () => void): this;
|
|
47
|
-
end(chunk: any, cb?: () => void): this;
|
|
48
|
-
end(chunk: any, encoding: BufferEncoding, cb?: () => void): this;
|
|
49
|
-
}
|