alepha 0.7.7 → 0.8.1
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/LICENSE +21 -21
- package/README.md +7 -34
- package/batch.cjs +8 -0
- package/batch.d.ts +147 -0
- package/batch.js +1 -0
- package/cache/redis.d.ts +13 -18
- package/cache.d.ts +183 -119
- package/command.cjs +8 -0
- package/command.d.ts +152 -0
- package/command.js +1 -0
- package/core.d.ts +846 -838
- package/datetime.d.ts +78 -78
- package/file.cjs +8 -0
- package/file.d.ts +46 -0
- package/file.js +1 -0
- package/lock/redis.d.ts +10 -12
- package/lock.d.ts +73 -80
- package/package.json +86 -34
- package/postgres.d.ts +348 -170
- package/queue/redis.d.ts +13 -13
- package/queue.d.ts +107 -18
- package/react/auth.d.ts +22 -16
- package/react/head.d.ts +10 -4
- package/react.d.ts +206 -49
- package/redis.d.ts +23 -27
- package/retry.d.ts +75 -54
- package/router.cjs +8 -0
- package/router.d.ts +45 -0
- package/router.js +1 -0
- package/scheduler.d.ts +15 -16
- package/security.d.ts +229 -40
- package/server/cache.d.ts +7 -8
- package/server/compress.cjs +8 -0
- package/server/compress.d.ts +26 -0
- package/server/compress.js +1 -0
- package/server/cookies.d.ts +249 -18
- package/server/cors.d.ts +7 -3
- package/server/health.d.ts +21 -24
- package/server/helmet.cjs +8 -0
- package/server/helmet.d.ts +70 -0
- package/server/helmet.js +1 -0
- package/server/links.d.ts +87 -93
- package/server/metrics.cjs +8 -0
- package/server/metrics.d.ts +35 -0
- package/server/metrics.js +1 -0
- package/server/multipart.cjs +8 -0
- package/server/multipart.d.ts +46 -0
- package/server/multipart.js +1 -0
- package/server/proxy.d.ts +11 -11
- package/server/static.d.ts +70 -55
- package/server/swagger.d.ts +55 -54
- package/server.d.ts +273 -123
- package/topic/redis.d.ts +22 -23
- package/topic.d.ts +26 -19
- package/vite.d.ts +59 -36
package/server/links.d.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { ActionDescriptor, ActionDescriptorHelper, ApiLink, ApiLinksResponse, ClientRequestOptions, FetchResponse, HttpClient, RequestConfigSchema, ServerActionDescriptorProvider, ServerHandler, ServerRemote, ServerRequestConfigEntry } from "@alepha/server";
|
|
7
|
-
import * as _alepha_retry27 from "@alepha/retry";
|
|
8
|
-
import { ProxyDescriptorOptions, ProxyDescriptorProvider } from "@alepha/server-proxy";
|
|
9
|
-
import { ServiceAccountDescriptor, UserAccountToken } from "@alepha/security";
|
|
10
|
-
import * as _sinclair_typebox1 from "@sinclair/typebox";
|
|
1
|
+
import { Alepha, HookDescriptor, KIND, Logger, Module, OPTIONS, TAny, TArray, TObject, TOptional, TRecord, TString } from "alepha";
|
|
2
|
+
import { ActionDescriptor, ActionDescriptorHelper, ApiLink, ApiLinksResponse, ClientRequestOptions, FetchResponse, HttpClient, RequestConfigSchema, RouteDescriptor, ServerActionDescriptorProvider, ServerHandler, ServerRemote, ServerRequestConfigEntry } from "alepha/server";
|
|
3
|
+
import { RetryDescriptor } from "alepha/retry";
|
|
4
|
+
import { ProxyDescriptorOptions, ProxyDescriptorProvider } from "alepha/server/proxy";
|
|
5
|
+
import { ServiceAccountDescriptor, UserAccountToken } from "alepha/security";
|
|
11
6
|
|
|
12
7
|
//#region src/providers/LinkProvider.d.ts
|
|
13
8
|
declare class LinkProvider {
|
|
14
9
|
readonly URL_LINKS = "/api/_links";
|
|
15
|
-
protected readonly log:
|
|
10
|
+
protected readonly log: Logger;
|
|
16
11
|
protected readonly alepha: Alepha;
|
|
17
12
|
protected readonly httpClient: HttpClient;
|
|
18
13
|
links?: Array<HttpClientLink>;
|
|
@@ -20,20 +15,24 @@ declare class LinkProvider {
|
|
|
20
15
|
getLinks(force?: boolean): Promise<HttpClientLink[]>;
|
|
21
16
|
client<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
|
|
22
17
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
* Resolve a link by its name and call it.
|
|
19
|
+
* - If link is local, it will call the local handler.
|
|
20
|
+
* - If link is remote, it will make a fetch request to the remote server.
|
|
21
|
+
*/
|
|
27
22
|
follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
|
|
28
23
|
protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
|
|
29
24
|
can(name: string): boolean;
|
|
30
25
|
protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
|
|
31
26
|
}
|
|
27
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
32
28
|
interface HttpClientLink extends ApiLink {
|
|
33
29
|
secured?: boolean;
|
|
34
30
|
prefix?: string;
|
|
31
|
+
// -- server only --
|
|
32
|
+
// only for remote actions
|
|
35
33
|
host?: string;
|
|
36
34
|
service?: string;
|
|
35
|
+
// used only for local actions, not for remote actions
|
|
37
36
|
schema?: RequestConfigSchema;
|
|
38
37
|
handler?: ServerHandler;
|
|
39
38
|
}
|
|
@@ -47,71 +46,74 @@ type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor ? K
|
|
|
47
46
|
} : never };
|
|
48
47
|
//#endregion
|
|
49
48
|
//#region src/descriptors/$client.d.ts
|
|
49
|
+
/**
|
|
50
|
+
* Create a new client.
|
|
51
|
+
*/
|
|
50
52
|
declare const $client: <T extends object>(scope?: ClientScope) => HttpVirtualClient<T>;
|
|
51
53
|
//#endregion
|
|
52
54
|
//#region src/descriptors/$remote.d.ts
|
|
53
55
|
declare const KEY = "REMOTE";
|
|
56
|
+
/**
|
|
57
|
+
* $remote is a descriptor that allows you to define remote service access.
|
|
58
|
+
*
|
|
59
|
+
* Use it only when you have 2 or more services that need to communicate with each other.
|
|
60
|
+
*
|
|
61
|
+
* All remote services can be exposed as actions, ... or not.
|
|
62
|
+
*
|
|
63
|
+
* You can add a service account if you want to use a security layer.
|
|
64
|
+
*/
|
|
65
|
+
declare const $remote: {
|
|
66
|
+
(options: RemoteDescriptorOptions): RemoteDescriptor;
|
|
67
|
+
[KIND]: string;
|
|
68
|
+
};
|
|
54
69
|
interface RemoteDescriptorOptions {
|
|
55
70
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
* The URL of the remote service.
|
|
72
|
+
* You can use a function to generate the URL dynamically.
|
|
73
|
+
* You probably should use $inject(env) to get the URL from the environment.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { $remote } from "alepha/server";
|
|
78
|
+
* import { $inject, t } from "alepha";
|
|
79
|
+
*
|
|
80
|
+
* class App {
|
|
81
|
+
* env = $inject(t.object({
|
|
82
|
+
* REMOTE_URL: t.string({default: "http://localhost:3000"}),
|
|
83
|
+
* }));
|
|
84
|
+
* remote = $remote({
|
|
85
|
+
* url: this.env.REMOTE_URL,
|
|
86
|
+
* });
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
75
90
|
url: string | (() => string);
|
|
76
91
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
* The name of the remote service.
|
|
93
|
+
*
|
|
94
|
+
* @default Member of the class containing the remote service.
|
|
95
|
+
*/
|
|
81
96
|
name?: string;
|
|
82
97
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
98
|
+
* If true, all methods of the remote service will be exposed as actions in this context.
|
|
99
|
+
* > Note: Proxy will never use the service account, it just... proxies the request.
|
|
100
|
+
*/
|
|
86
101
|
proxy?: boolean | Partial<ProxyDescriptorOptions & {
|
|
87
102
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
103
|
+
* If true, the remote service won't be available internally, only through the proxy.
|
|
104
|
+
*/
|
|
90
105
|
noInternal: boolean;
|
|
91
106
|
}>;
|
|
92
107
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
108
|
+
* For communication between the server and the remote service with a security layer.
|
|
109
|
+
* This will be used for internal communication and will not be exposed to the client.
|
|
110
|
+
*/
|
|
96
111
|
serviceAccount?: ServiceAccountDescriptor;
|
|
97
112
|
}
|
|
98
113
|
interface RemoteDescriptor {
|
|
99
114
|
[KIND]: typeof KEY;
|
|
100
115
|
[OPTIONS]: RemoteDescriptorOptions;
|
|
101
116
|
}
|
|
102
|
-
/**
|
|
103
|
-
* $remote is a descriptor that allows you to define a remote service access.
|
|
104
|
-
*
|
|
105
|
-
* Use it only when you have 2 or more services that need to communicate with each other.
|
|
106
|
-
*
|
|
107
|
-
* All remote services can be exposed as actions, ... or not.
|
|
108
|
-
*
|
|
109
|
-
* You can add a service account if you want to use a security layer.
|
|
110
|
-
*/
|
|
111
|
-
declare const $remote: {
|
|
112
|
-
(options: RemoteDescriptorOptions): RemoteDescriptor;
|
|
113
|
-
[KIND]: string;
|
|
114
|
-
};
|
|
115
117
|
//#endregion
|
|
116
118
|
//#region src/providers/RemoteDescriptorProvider.d.ts
|
|
117
119
|
declare class RemoteDescriptorProvider {
|
|
@@ -122,26 +124,17 @@ declare class RemoteDescriptorProvider {
|
|
|
122
124
|
protected readonly client: LinkProvider;
|
|
123
125
|
protected readonly proxyProvider: ProxyDescriptorProvider;
|
|
124
126
|
protected readonly remotes: Array<ServerRemote>;
|
|
125
|
-
protected readonly log:
|
|
127
|
+
protected readonly log: Logger;
|
|
126
128
|
getRemotes(): ServerRemote[];
|
|
127
|
-
readonly configure:
|
|
128
|
-
readonly start:
|
|
129
|
+
readonly configure: HookDescriptor<"configure">;
|
|
130
|
+
readonly start: HookDescriptor<"start">;
|
|
129
131
|
registerRemote(value: RemoteDescriptor, key: string): Promise<void>;
|
|
130
|
-
protected readonly fetchLinks:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
links: {
|
|
137
|
-
method?: string | undefined;
|
|
138
|
-
group?: string | undefined;
|
|
139
|
-
requestBodyType?: string | undefined;
|
|
140
|
-
service?: string | undefined;
|
|
141
|
-
name: string;
|
|
142
|
-
path: string;
|
|
143
|
-
}[];
|
|
144
|
-
}>>;
|
|
132
|
+
protected readonly fetchLinks: RetryDescriptor<(opts: FetchLinksOptions) => Promise<ApiLinksResponse>>;
|
|
133
|
+
}
|
|
134
|
+
interface FetchLinksOptions {
|
|
135
|
+
service: string;
|
|
136
|
+
url: string;
|
|
137
|
+
authorization?: string;
|
|
145
138
|
}
|
|
146
139
|
//#endregion
|
|
147
140
|
//#region src/providers/ServerLinksProvider.d.ts
|
|
@@ -151,25 +144,25 @@ declare class ServerLinksProvider {
|
|
|
151
144
|
protected readonly helper: ActionDescriptorHelper;
|
|
152
145
|
protected readonly remoteProvider: RemoteDescriptorProvider;
|
|
153
146
|
protected readonly serverActionDescriptorProvider: ServerActionDescriptorProvider;
|
|
154
|
-
readonly onRoute:
|
|
155
|
-
readonly links:
|
|
156
|
-
response:
|
|
157
|
-
prefix:
|
|
158
|
-
links:
|
|
159
|
-
name:
|
|
160
|
-
path:
|
|
161
|
-
method:
|
|
162
|
-
group:
|
|
163
|
-
requestBodyType:
|
|
164
|
-
service:
|
|
147
|
+
readonly onRoute: HookDescriptor<"server:onRoute">;
|
|
148
|
+
readonly links: RouteDescriptor<{
|
|
149
|
+
response: TObject<{
|
|
150
|
+
prefix: TOptional<TString>;
|
|
151
|
+
links: TArray<TObject<{
|
|
152
|
+
name: TString;
|
|
153
|
+
path: TString;
|
|
154
|
+
method: TOptional<TString>;
|
|
155
|
+
group: TOptional<TString>;
|
|
156
|
+
requestBodyType: TOptional<TString>;
|
|
157
|
+
service: TOptional<TString>;
|
|
165
158
|
}>>;
|
|
166
159
|
}>;
|
|
167
160
|
}>;
|
|
168
|
-
readonly schema:
|
|
169
|
-
params:
|
|
170
|
-
name:
|
|
161
|
+
readonly schema: RouteDescriptor<{
|
|
162
|
+
params: TObject<{
|
|
163
|
+
name: TString;
|
|
171
164
|
}>;
|
|
172
|
-
response:
|
|
165
|
+
response: TRecord<TString, TAny>;
|
|
173
166
|
}>;
|
|
174
167
|
getLinks(options: GetLinksOptions): Promise<ApiLinksResponse>;
|
|
175
168
|
}
|
|
@@ -179,10 +172,11 @@ interface GetLinksOptions {
|
|
|
179
172
|
}
|
|
180
173
|
//#endregion
|
|
181
174
|
//#region src/index.d.ts
|
|
175
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
182
176
|
declare class AlephaServerLinks implements Module {
|
|
183
177
|
readonly name = "alepha.server.links";
|
|
184
178
|
readonly $services: (alepha: Alepha) => void;
|
|
185
179
|
}
|
|
186
180
|
//#endregion
|
|
187
|
-
export { $client, $remote, AlephaServerLinks, ClientScope, GetLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider };
|
|
181
|
+
export { $client, $remote, AlephaServerLinks, ClientScope, FetchLinksOptions, GetLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider };
|
|
188
182
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var m = require('@alepha/server-metrics');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
4
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () { return m[k]; }
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RouteDescriptor } from "alepha/server";
|
|
2
|
+
import { Alepha, HookDescriptor, Module } from "alepha";
|
|
3
|
+
import { Registry } from "prom-client";
|
|
4
|
+
|
|
5
|
+
//#region src/providers/ServerMetricsProvider.d.ts
|
|
6
|
+
interface ServerMetricsProviderOptions {
|
|
7
|
+
prefix?: string;
|
|
8
|
+
gcDurationBuckets?: number[];
|
|
9
|
+
eventLoopMonitoringPrecision?: number;
|
|
10
|
+
labels?: object;
|
|
11
|
+
}
|
|
12
|
+
declare class ServerMetricsProvider {
|
|
13
|
+
protected readonly register: Registry;
|
|
14
|
+
protected readonly alepha: Alepha;
|
|
15
|
+
readonly options: ServerMetricsProviderOptions;
|
|
16
|
+
readonly metrics: RouteDescriptor;
|
|
17
|
+
protected readonly onStart: HookDescriptor<"start">;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/index.d.ts
|
|
21
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
22
|
+
/**
|
|
23
|
+
* This module provides prometheus metrics for the Alepha server.
|
|
24
|
+
* Metrics are exposed at the `/metrics` endpoint.
|
|
25
|
+
*
|
|
26
|
+
* @see {@link ServerMetricsProvider}
|
|
27
|
+
* @module alepha.server.metrics
|
|
28
|
+
*/
|
|
29
|
+
declare class AlephaServerMetrics implements Module {
|
|
30
|
+
readonly name = "alepha.server.metrics";
|
|
31
|
+
readonly $services: (alepha: Alepha) => void;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { AlephaServerMetrics, ServerMetricsProvider, ServerMetricsProviderOptions };
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/server-metrics'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var m = require('@alepha/server-multipart');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
4
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () { return m[k]; }
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ActionDescriptorHelper, ServerRoute } from "alepha/server";
|
|
2
|
+
import { Alepha, FileLike, HookDescriptor, Module } from "alepha";
|
|
3
|
+
import { BusboyConfig } from "@fastify/busboy";
|
|
4
|
+
import { IncomingMessage } from "node:http";
|
|
5
|
+
|
|
6
|
+
//#region src/providers/ServerMultipartProvider.d.ts
|
|
7
|
+
declare class ServerMultipartProvider {
|
|
8
|
+
protected readonly helper: ActionDescriptorHelper;
|
|
9
|
+
protected readonly alepha: Alepha;
|
|
10
|
+
readonly onRequest: HookDescriptor<"server:onRequest">;
|
|
11
|
+
readonly onSend: HookDescriptor<"server:onResponse">;
|
|
12
|
+
handleMultipartBodyFromNode(route: ServerRoute, stream: IncomingMessage): Promise<{
|
|
13
|
+
body: Record<string, any>;
|
|
14
|
+
cleanup: () => Promise<void>;
|
|
15
|
+
}>;
|
|
16
|
+
parseMultipart(req: IncomingMessage, config?: Omit<BusboyConfig, "headers">): Promise<MultipartResult>;
|
|
17
|
+
}
|
|
18
|
+
interface MultipartResult {
|
|
19
|
+
fields: Record<string, string | string[]>;
|
|
20
|
+
files: Record<string, HybridFile>;
|
|
21
|
+
}
|
|
22
|
+
interface HybridFile extends FileLike {
|
|
23
|
+
cleanup(): Promise<void>;
|
|
24
|
+
_state: {
|
|
25
|
+
cleanup: boolean;
|
|
26
|
+
size: number;
|
|
27
|
+
tmpPath: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/index.d.ts
|
|
32
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
33
|
+
/**
|
|
34
|
+
* This module provides support for handling multipart/form-data requests.
|
|
35
|
+
* It allows to parse body data containing t.file().
|
|
36
|
+
*
|
|
37
|
+
* @see {@link ServerMultipartProvider}
|
|
38
|
+
* @module alepha.server.multipart
|
|
39
|
+
*/
|
|
40
|
+
declare class AlephaServerMultipart implements Module {
|
|
41
|
+
readonly name = "alepha.server.multipart";
|
|
42
|
+
readonly $services: (alepha: Alepha) => void;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { AlephaServerMultipart, ServerMultipartProvider };
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/server-multipart'
|
package/server/proxy.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { ServerHandler, ServerRequest, ServerRouterProvider } from "@alepha/server";
|
|
1
|
+
import { Alepha, Async, HookDescriptor, KIND, Logger, Module, OPTIONS } from "alepha";
|
|
2
|
+
import { ServerHandler, ServerRequest, ServerRouterProvider } from "alepha/server";
|
|
4
3
|
|
|
5
4
|
//#region src/descriptors/$proxy.d.ts
|
|
5
|
+
declare const $proxy: {
|
|
6
|
+
(options: ProxyDescriptorOptions): ProxyDescriptor;
|
|
7
|
+
[KIND]: string;
|
|
8
|
+
};
|
|
6
9
|
type ProxyDescriptorOptions = {
|
|
7
10
|
path: string;
|
|
8
|
-
target: string;
|
|
11
|
+
target: string | (() => string);
|
|
9
12
|
disabled?: boolean;
|
|
10
13
|
beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
|
|
11
14
|
afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
|
|
@@ -15,23 +18,20 @@ interface ProxyDescriptor {
|
|
|
15
18
|
[KIND]: "PROXY";
|
|
16
19
|
[OPTIONS]: ProxyDescriptorOptions;
|
|
17
20
|
}
|
|
18
|
-
declare const $proxy: {
|
|
19
|
-
(options: ProxyDescriptorOptions): ProxyDescriptor;
|
|
20
|
-
[KIND]: string;
|
|
21
|
-
};
|
|
22
21
|
//#endregion
|
|
23
22
|
//#region src/providers/ProxyDescriptorProvider.d.ts
|
|
24
23
|
declare class ProxyDescriptorProvider {
|
|
25
|
-
protected readonly log:
|
|
24
|
+
protected readonly log: Logger;
|
|
26
25
|
protected readonly routerProvider: ServerRouterProvider;
|
|
27
26
|
protected readonly alepha: Alepha;
|
|
28
|
-
readonly configure:
|
|
29
|
-
createProxyHandler(options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
|
|
27
|
+
readonly configure: HookDescriptor<"configure">;
|
|
28
|
+
createProxyHandler(target: string, options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
|
|
30
29
|
proxy(options: ProxyDescriptorOptions): Promise<void>;
|
|
31
30
|
private getRawRequestBody;
|
|
32
31
|
}
|
|
33
32
|
//#endregion
|
|
34
33
|
//#region src/index.d.ts
|
|
34
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
35
35
|
declare class AlephaServerProxy implements Module {
|
|
36
36
|
readonly name = "alepha.server.proxy";
|
|
37
37
|
readonly $services: (alepha: Alepha) => void;
|
package/server/static.d.ts
CHANGED
|
@@ -1,78 +1,84 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { DateTimeProvider, DurationLike } from "
|
|
4
|
-
import { ServerHandler, ServerRouterProvider } from "@alepha/server";
|
|
1
|
+
import { Alepha, HookDescriptor, KIND, Logger, OPTIONS } from "alepha";
|
|
2
|
+
import { ServerHandler, ServerRouterProvider } from "alepha/server";
|
|
3
|
+
import { DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
5
4
|
|
|
6
5
|
//#region src/descriptors/$serve.d.ts
|
|
7
6
|
declare const KEY = "SERVE";
|
|
7
|
+
/**
|
|
8
|
+
* Create a new static file handler.
|
|
9
|
+
*/
|
|
10
|
+
declare const $serve: {
|
|
11
|
+
(options?: ServeDescriptorOptions): ServeDescriptor;
|
|
12
|
+
[KIND]: string;
|
|
13
|
+
};
|
|
8
14
|
interface ServeDescriptorOptions {
|
|
9
15
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
* Prefix for the served path.
|
|
17
|
+
*
|
|
18
|
+
* @default "/"
|
|
19
|
+
*/
|
|
14
20
|
path?: string;
|
|
15
21
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
* Path to the directory to serve.
|
|
23
|
+
*
|
|
24
|
+
* @default process.cwd()
|
|
25
|
+
*/
|
|
20
26
|
root?: string;
|
|
21
27
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
* If true, descriptor will be ignored.
|
|
29
|
+
*
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
26
32
|
disabled?: boolean;
|
|
27
33
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
* Whether to keep dot files (e.g. `.gitignore`, `.env`) in the served directory.
|
|
35
|
+
*
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
32
38
|
ignoreDotEnvFiles?: boolean;
|
|
33
39
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
* Whether to use the index.html file when the path is a directory.
|
|
41
|
+
*
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
38
44
|
indexFallback?: boolean;
|
|
39
45
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
* Force all requests "not found" to be served with the index.html file.
|
|
47
|
+
* This is useful for single-page applications (SPAs) that use client-side only routing.
|
|
48
|
+
*/
|
|
43
49
|
historyApiFallback?: boolean;
|
|
44
50
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
* Optional name of the descriptor.
|
|
52
|
+
* This is used for logging and debugging purposes.
|
|
53
|
+
*
|
|
54
|
+
* @default Key name.
|
|
55
|
+
*/
|
|
50
56
|
name?: string;
|
|
51
57
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
* Whether to use cache control headers.
|
|
59
|
+
*
|
|
60
|
+
* @default {}
|
|
61
|
+
*/
|
|
56
62
|
cacheControl?: Partial<CacheControlOptions> | false;
|
|
57
63
|
}
|
|
58
64
|
interface CacheControlOptions {
|
|
59
65
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
* Whether to use cache control headers.
|
|
67
|
+
*
|
|
68
|
+
* @default [.js, .css]
|
|
69
|
+
*/
|
|
64
70
|
fileTypes: string[];
|
|
65
71
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
* The maximum age of the cache in seconds.
|
|
73
|
+
*
|
|
74
|
+
* @default 60 * 60 * 24 * 2 // 2 days
|
|
75
|
+
*/
|
|
70
76
|
maxAge: DurationLike;
|
|
71
77
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
* Whether to use immutable cache control headers.
|
|
79
|
+
*
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
76
82
|
immutable: boolean;
|
|
77
83
|
}
|
|
78
84
|
interface ServeDescriptor {
|
|
@@ -80,19 +86,15 @@ interface ServeDescriptor {
|
|
|
80
86
|
[OPTIONS]: ServeDescriptorOptions;
|
|
81
87
|
list(): string[];
|
|
82
88
|
}
|
|
83
|
-
declare const $serve: {
|
|
84
|
-
(options?: ServeDescriptorOptions): ServeDescriptor;
|
|
85
|
-
[KIND]: string;
|
|
86
|
-
};
|
|
87
89
|
//#endregion
|
|
88
90
|
//#region src/providers/ServerStaticProvider.d.ts
|
|
89
91
|
declare class ServerStaticProvider {
|
|
90
92
|
protected readonly alepha: Alepha;
|
|
91
93
|
protected readonly routerProvider: ServerRouterProvider;
|
|
92
94
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
93
|
-
protected readonly log:
|
|
95
|
+
protected readonly log: Logger;
|
|
94
96
|
protected readonly directories: ServeDirectory[];
|
|
95
|
-
protected readonly configure:
|
|
97
|
+
protected readonly configure: HookDescriptor<"configure">;
|
|
96
98
|
list(name: string): string[];
|
|
97
99
|
serve(options: ServeDescriptorOptions): Promise<void>;
|
|
98
100
|
createFileHandler(filepath: string, options: ServeDescriptorOptions): Promise<ServerHandler>;
|
|
@@ -108,5 +110,18 @@ interface ServeDirectory {
|
|
|
108
110
|
files: string[];
|
|
109
111
|
}
|
|
110
112
|
//#endregion
|
|
111
|
-
|
|
113
|
+
//#region src/index.d.ts
|
|
114
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
115
|
+
/**
|
|
116
|
+
* Create static file server with `$static()`.
|
|
117
|
+
*
|
|
118
|
+
* @see {@link ServerStaticProvider}
|
|
119
|
+
* @module alepha.server.static
|
|
120
|
+
*/
|
|
121
|
+
declare class AlephaServerStatic {
|
|
122
|
+
readonly name = "alepha.server.static";
|
|
123
|
+
readonly $services: (alepha: Alepha) => void;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
export { $serve, AlephaServerStatic, CacheControlOptions, ServeDescriptor, ServeDescriptorOptions, ServeDirectory, ServerStaticProvider };
|
|
112
127
|
//# sourceMappingURL=index.d.ts.map
|