alepha 0.6.7 → 0.6.9

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.
@@ -1 +1,14 @@
1
- export * from '@alepha/server-metrics';
1
+ import * as _alepha_server from '@alepha/server';
2
+
3
+ declare class ServerMetricsProvider {
4
+ private readonly register;
5
+ private cpuUsage;
6
+ private memoryUsage;
7
+ private gcDuration;
8
+ private heapUsage;
9
+ readonly metrics: _alepha_server.RouteDescriptor<_alepha_server.RequestConfigSchema>;
10
+ constructor();
11
+ private collectMetrics;
12
+ }
13
+
14
+ export { ServerMetricsProvider };
package/server/proxy.d.ts CHANGED
@@ -1 +1,34 @@
1
- export * from '@alepha/server-proxy';
1
+ import * as _alepha_core from '@alepha/core';
2
+ import { Async, KIND, OPTIONS, Alepha } from '@alepha/core';
3
+ import { ServerRequest, ServerRouterProvider } from '@alepha/server';
4
+
5
+ type ProxyDescriptorOptions = {
6
+ path: string;
7
+ target: string;
8
+ beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
9
+ afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
10
+ disabled?: boolean;
11
+ };
12
+ interface ProxyDescriptor {
13
+ [KIND]: "PROXY";
14
+ [OPTIONS]: ProxyDescriptorOptions;
15
+ }
16
+ declare const $proxy: {
17
+ (options: ProxyDescriptorOptions): ProxyDescriptor;
18
+ [KIND]: string;
19
+ };
20
+
21
+ declare class ServerProxyProvider {
22
+ protected readonly routerProvider: ServerRouterProvider;
23
+ protected readonly alepha: Alepha;
24
+ readonly configure: _alepha_core.HookDescriptor<"configure">;
25
+ proxy(options: ProxyDescriptorOptions): Promise<void>;
26
+ private getRawRequestBody;
27
+ }
28
+
29
+ declare class ServerProxyModule {
30
+ protected readonly alepha: Alepha;
31
+ constructor();
32
+ }
33
+
34
+ export { $proxy, type ProxyDescriptor, type ProxyDescriptorOptions, ServerProxyModule, ServerProxyProvider };
@@ -1 +1,103 @@
1
- export * from '@alepha/server-static';
1
+ import * as _alepha_core from '@alepha/core';
2
+ import { KIND, OPTIONS, Alepha } from '@alepha/core';
3
+ import { DurationLike, DateTimeProvider } from '@alepha/datetime';
4
+ import { ServerRouterProvider, ServerHandler } from '@alepha/server';
5
+
6
+ declare const KEY = "SERVE";
7
+ interface ServeDescriptorOptions {
8
+ /**
9
+ * Prefix for the served path.
10
+ *
11
+ * @default "/"
12
+ */
13
+ path?: string;
14
+ /**
15
+ * Path to the directory to serve.
16
+ *
17
+ * @default process.cwd()
18
+ */
19
+ root?: string;
20
+ /**
21
+ * If true, descriptor will be ignored.
22
+ *
23
+ * @default false
24
+ */
25
+ disabled?: boolean;
26
+ /**
27
+ * Whether to keep dot files (e.g. `.gitignore`, `.env`) in the served directory.
28
+ *
29
+ * @default true
30
+ */
31
+ ignoreDotEnvFiles?: boolean;
32
+ /**
33
+ * Whether to use the index.html file when the path is a directory.
34
+ *
35
+ * @default true
36
+ */
37
+ indexFallback?: boolean;
38
+ /**
39
+ * Optional name of the descriptor.
40
+ * This is used for logging and debugging purposes.
41
+ *
42
+ * @default Key name.
43
+ */
44
+ name?: string;
45
+ /**
46
+ * Whether to use cache control headers.
47
+ *
48
+ * @default {}
49
+ */
50
+ cacheControl?: Partial<CacheControlOptions> | false;
51
+ }
52
+ interface CacheControlOptions {
53
+ /**
54
+ * Whether to use cache control headers.
55
+ *
56
+ * @default [.js, .css]
57
+ */
58
+ fileTypes: string[];
59
+ /**
60
+ * The maximum age of the cache in seconds.
61
+ *
62
+ * @default 60 * 60 * 24 * 2 // 2 days
63
+ */
64
+ maxAge: DurationLike;
65
+ /**
66
+ * Whether to use immutable cache control headers.
67
+ *
68
+ * @default true
69
+ */
70
+ immutable: boolean;
71
+ }
72
+ interface ServeDescriptor {
73
+ [KIND]: typeof KEY;
74
+ [OPTIONS]: ServeDescriptorOptions;
75
+ list(): string[];
76
+ }
77
+ declare const $serve: {
78
+ (options?: ServeDescriptorOptions): ServeDescriptor;
79
+ [KIND]: string;
80
+ };
81
+
82
+ declare class ServerStaticProvider {
83
+ protected readonly alepha: Alepha;
84
+ protected readonly routerProvider: ServerRouterProvider;
85
+ protected readonly dateTimeProvider: DateTimeProvider;
86
+ protected readonly log: _alepha_core.Logger;
87
+ protected readonly directories: ServeDirectory[];
88
+ protected readonly configure: _alepha_core.HookDescriptor<"configure">;
89
+ list(name: string): string[];
90
+ serve(options: ServeDescriptorOptions): Promise<void>;
91
+ createFileHandler(filepath: string, options: ServeDescriptorOptions): Promise<ServerHandler>;
92
+ protected getCacheControl(filename: string, options: ServeDescriptorOptions): {
93
+ maxAge: number;
94
+ immutable: boolean;
95
+ } | undefined;
96
+ getAllFiles(dir: string, ignoreDotEnvFiles?: boolean): Promise<string[]>;
97
+ }
98
+ interface ServeDirectory {
99
+ options: ServeDescriptorOptions;
100
+ files: string[];
101
+ }
102
+
103
+ export { $serve, type CacheControlOptions, type ServeDescriptor, type ServeDescriptorOptions, type ServeDirectory, ServerStaticProvider };
@@ -1 +1,102 @@
1
- export * from '@alepha/server-swagger';
1
+ import * as _alepha_core from '@alepha/core';
2
+ import { KIND, OPTIONS, Alepha, TObject } from '@alepha/core';
3
+ import { OpenAPIV3 } from 'openapi-types';
4
+ import { ServerActionDescriptorProvider, ServerRouterProvider, ServerRouteAction } from '@alepha/server';
5
+ import { ServerStaticProvider } from '@alepha/server-static';
6
+
7
+ interface SwaggerDescriptorOptions {
8
+ info: OpenAPIV3.InfoObject;
9
+ /**
10
+ * @default: "/docs"
11
+ */
12
+ prefix?: string;
13
+ /**
14
+ * If true, docs will be disabled.
15
+ */
16
+ disabled?: boolean;
17
+ excludeTags?: string[];
18
+ ui?: boolean | SwaggerUiOptions;
19
+ rewrite?: (doc: OpenAPIV3.Document) => void;
20
+ }
21
+ interface SwaggerUiOptions {
22
+ initOAuth?: {
23
+ /**
24
+ * Default clientId.
25
+ */
26
+ clientId?: string;
27
+ /**
28
+ * realm query parameter (for oauth1) added to authorizationUrl and tokenUrl.
29
+ */
30
+ realm?: string;
31
+ /**
32
+ * application name, displayed in authorization popup.
33
+ */
34
+ appName?: string;
35
+ /**
36
+ * scope separator for passing scopes, encoded before calling, default
37
+ * value is a space (encoded value %20).
38
+ *
39
+ * @default ' '
40
+ */
41
+ scopeSeparator?: string;
42
+ /**
43
+ * string array or scope separator (i.e. space) separated string of
44
+ * initially selected oauth scopes
45
+ *
46
+ * @default []
47
+ */
48
+ scopes?: string | string[];
49
+ /**
50
+ * Additional query parameters added to authorizationUrl and tokenUrl.
51
+ * MUST be an object
52
+ */
53
+ additionalQueryStringParams?: {
54
+ [key: string]: any;
55
+ };
56
+ /**
57
+ * Only activated for the accessCode flow. During the authorization_code
58
+ * request to the tokenUrl, pass the Client Password using the HTTP Basic
59
+ * Authentication scheme (Authorization header with Basic
60
+ * base64encode(client_id + client_secret)).
61
+ *
62
+ * @default false
63
+ */
64
+ useBasicAuthenticationWithAccessCodeGrant?: boolean;
65
+ /**
66
+ * Only applies to Authorization Code flows. Proof Key for Code Exchange
67
+ * brings enhanced security for OAuth public clients.
68
+ *
69
+ * @default false
70
+ */
71
+ usePkceWithAuthorizationCodeGrant?: boolean;
72
+ };
73
+ }
74
+ interface SwaggerDescriptor {
75
+ [KIND]: "SWAGGER";
76
+ [OPTIONS]: SwaggerDescriptorOptions;
77
+ json(): OpenAPIV3.Document;
78
+ }
79
+ declare const $swagger: {
80
+ (options: SwaggerDescriptorOptions): SwaggerDescriptor;
81
+ [KIND]: string;
82
+ };
83
+
84
+ declare class ServerSwaggerProvider {
85
+ protected readonly serverActionProvider: ServerActionDescriptorProvider;
86
+ protected readonly serverStaticProvider: ServerStaticProvider;
87
+ protected readonly serverRouterProvider: ServerRouterProvider;
88
+ protected readonly alepha: Alepha;
89
+ protected readonly configure: _alepha_core.HookDescriptor<"configure">;
90
+ protected configureOpenApi(doc: SwaggerDescriptorOptions): any;
91
+ isBodyMultipart(schema: TObject): boolean;
92
+ replacePathParams(url: string): string;
93
+ getResponseSchema(route: ServerRouteAction): {
94
+ type?: string;
95
+ schema?: any;
96
+ status: number;
97
+ } | undefined;
98
+ protected configureSwaggerApi(prefix: string, json: OpenAPIV3.Document): Promise<void>;
99
+ protected configureSwaggerUi(prefix: string, options: SwaggerDescriptorOptions): Promise<void>;
100
+ }
101
+
102
+ export { $swagger, ServerSwaggerProvider, type SwaggerDescriptor, type SwaggerDescriptorOptions, type SwaggerUiOptions };