alepha 0.7.7 → 0.8.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/batch.cjs +8 -0
- package/batch.d.ts +114 -0
- package/batch.js +1 -0
- package/cache/redis.d.ts +15 -18
- package/cache.d.ts +115 -119
- package/command.cjs +8 -0
- package/command.d.ts +154 -0
- package/command.js +1 -0
- package/core.d.ts +798 -794
- package/datetime.d.ts +76 -76
- package/lock/redis.d.ts +12 -12
- package/lock.d.ts +70 -75
- package/package.json +72 -34
- package/postgres.d.ts +202 -156
- package/queue/redis.d.ts +15 -13
- package/queue.d.ts +16 -13
- package/react/auth.d.ts +15 -10
- package/react/head.d.ts +9 -3
- package/react.d.ts +59 -36
- package/redis.d.ts +20 -27
- package/retry.d.ts +74 -54
- package/scheduler.d.ts +14 -12
- package/security.d.ts +38 -28
- package/server/cache.d.ts +7 -5
- package/server/compress.cjs +8 -0
- package/server/compress.d.ts +26 -0
- package/server/compress.js +1 -0
- package/server/cookies.d.ts +68 -14
- package/server/cors.d.ts +7 -3
- package/server/health.d.ts +24 -24
- package/server/helmet.cjs +8 -0
- package/server/helmet.d.ts +72 -0
- package/server/helmet.js +1 -0
- package/server/links.d.ts +79 -88
- package/server/metrics.cjs +8 -0
- package/server/metrics.d.ts +37 -0
- package/server/metrics.js +1 -0
- package/server/multipart.cjs +8 -0
- package/server/multipart.d.ts +48 -0
- package/server/multipart.js +1 -0
- package/server/proxy.d.ts +7 -7
- package/server/static.d.ts +63 -51
- package/server/swagger.d.ts +50 -50
- package/server.d.ts +114 -117
- package/topic/redis.d.ts +24 -23
- package/topic.d.ts +9 -3
- package/vite.d.ts +8 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Alepha, HookDescriptor, Module } from "alepha";
|
|
2
|
+
|
|
3
|
+
//#region src/providers/ServerHelmetProvider.d.ts
|
|
4
|
+
type CspDirective = string | string[];
|
|
5
|
+
interface CspOptions {
|
|
6
|
+
directives: {
|
|
7
|
+
"default-src"?: CspDirective;
|
|
8
|
+
"script-src"?: CspDirective;
|
|
9
|
+
"style-src"?: CspDirective;
|
|
10
|
+
"img-src"?: CspDirective;
|
|
11
|
+
"connect-src"?: CspDirective;
|
|
12
|
+
"font-src"?: CspDirective;
|
|
13
|
+
"object-src"?: CspDirective;
|
|
14
|
+
"media-src"?: CspDirective;
|
|
15
|
+
"frame-src"?: CspDirective;
|
|
16
|
+
sandbox?: CspDirective | boolean;
|
|
17
|
+
"report-uri"?: string;
|
|
18
|
+
"child-src"?: CspDirective;
|
|
19
|
+
"form-action"?: CspDirective;
|
|
20
|
+
"frame-ancestors"?: CspDirective;
|
|
21
|
+
"plugin-types"?: CspDirective;
|
|
22
|
+
"base-uri"?: CspDirective;
|
|
23
|
+
[key: string]: CspDirective | undefined | boolean;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
interface HstsOptions {
|
|
27
|
+
maxAge?: number;
|
|
28
|
+
includeSubDomains?: boolean;
|
|
29
|
+
preload?: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface HelmetOptions {
|
|
32
|
+
isSecure?: boolean;
|
|
33
|
+
strictTransportSecurity?: HstsOptions | false;
|
|
34
|
+
xContentTypeOptions?: false;
|
|
35
|
+
xFrameOptions?: "DENY" | "SAMEORIGIN" | false;
|
|
36
|
+
xXssProtection?: false;
|
|
37
|
+
contentSecurityPolicy?: CspOptions | false;
|
|
38
|
+
referrerPolicy?: "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url" | false;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Provides a configurable way to apply essential HTTP security headers
|
|
42
|
+
* to every server response, without external dependencies.
|
|
43
|
+
*/
|
|
44
|
+
declare class ServerHelmetProvider {
|
|
45
|
+
protected readonly alepha: Alepha;
|
|
46
|
+
/**
|
|
47
|
+
* The configuration options. These can be overridden during
|
|
48
|
+
* the application's configuration phase using `alepha.configure()`.
|
|
49
|
+
*/
|
|
50
|
+
options: HelmetOptions;
|
|
51
|
+
private buildHeaders;
|
|
52
|
+
protected readonly onResponse: HookDescriptor<"server:onResponse">;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/index.d.ts
|
|
56
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
57
|
+
/**
|
|
58
|
+
* Alepha Server Helmet Module
|
|
59
|
+
*
|
|
60
|
+
* Automatically adds important HTTP security headers to every response
|
|
61
|
+
* to help protect your application from common web vulnerabilities.
|
|
62
|
+
*
|
|
63
|
+
* @see {@link ServerHelmetProvider}
|
|
64
|
+
* @module alepha.server.helmet
|
|
65
|
+
*/
|
|
66
|
+
declare class AlephaServerHelmet implements Module {
|
|
67
|
+
readonly name = "alepha.server.helmet";
|
|
68
|
+
readonly $services: (alepha: Alepha) => void;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { AlephaServerHelmet, CspOptions, HelmetOptions, HstsOptions, ServerHelmetProvider };
|
|
72
|
+
//# sourceMappingURL=index.d.ts.map
|
package/server/helmet.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/server-helmet'
|
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
|
}
|
|
@@ -53,46 +52,46 @@ declare const $client: <T extends object>(scope?: ClientScope) => HttpVirtualCli
|
|
|
53
52
|
declare const KEY = "REMOTE";
|
|
54
53
|
interface RemoteDescriptorOptions {
|
|
55
54
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
55
|
+
* The URL of the remote service.
|
|
56
|
+
* You can use a function to generate the URL dynamically.
|
|
57
|
+
* You probably should use $inject(env) to get the URL from the environment.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { $remote } from "alepha/server";
|
|
62
|
+
* import { $inject, t } from "alepha";
|
|
63
|
+
*
|
|
64
|
+
* class App {
|
|
65
|
+
* env = $inject(t.object({
|
|
66
|
+
* REMOTE_URL: t.string({default: "http://localhost:3000"}),
|
|
67
|
+
* }));
|
|
68
|
+
* remote = $remote({
|
|
69
|
+
* url: this.env.REMOTE_URL,
|
|
70
|
+
* });
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
75
74
|
url: string | (() => string);
|
|
76
75
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
* The name of the remote service.
|
|
77
|
+
*
|
|
78
|
+
* @default Member of the class containing the remote service.
|
|
79
|
+
*/
|
|
81
80
|
name?: string;
|
|
82
81
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
* If true, all methods of the remote service will be exposed as actions in this context.
|
|
83
|
+
* > Note: Proxy will never use the service account, it just... proxies the request.
|
|
84
|
+
*/
|
|
86
85
|
proxy?: boolean | Partial<ProxyDescriptorOptions & {
|
|
87
86
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
* If true, the remote service won't be available internally, only through the proxy.
|
|
88
|
+
*/
|
|
90
89
|
noInternal: boolean;
|
|
91
90
|
}>;
|
|
92
91
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
* For communication between the server and the remote service with a security layer.
|
|
93
|
+
* This will be used for internal communication and will not be exposed to the client.
|
|
94
|
+
*/
|
|
96
95
|
serviceAccount?: ServiceAccountDescriptor;
|
|
97
96
|
}
|
|
98
97
|
interface RemoteDescriptor {
|
|
@@ -100,14 +99,14 @@ interface RemoteDescriptor {
|
|
|
100
99
|
[OPTIONS]: RemoteDescriptorOptions;
|
|
101
100
|
}
|
|
102
101
|
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
* $remote is a descriptor that allows you to define a remote service access.
|
|
103
|
+
*
|
|
104
|
+
* Use it only when you have 2 or more services that need to communicate with each other.
|
|
105
|
+
*
|
|
106
|
+
* All remote services can be exposed as actions, ... or not.
|
|
107
|
+
*
|
|
108
|
+
* You can add a service account if you want to use a security layer.
|
|
109
|
+
*/
|
|
111
110
|
declare const $remote: {
|
|
112
111
|
(options: RemoteDescriptorOptions): RemoteDescriptor;
|
|
113
112
|
[KIND]: string;
|
|
@@ -122,26 +121,17 @@ declare class RemoteDescriptorProvider {
|
|
|
122
121
|
protected readonly client: LinkProvider;
|
|
123
122
|
protected readonly proxyProvider: ProxyDescriptorProvider;
|
|
124
123
|
protected readonly remotes: Array<ServerRemote>;
|
|
125
|
-
protected readonly log:
|
|
124
|
+
protected readonly log: Logger;
|
|
126
125
|
getRemotes(): ServerRemote[];
|
|
127
|
-
readonly configure:
|
|
128
|
-
readonly start:
|
|
126
|
+
readonly configure: HookDescriptor<"configure">;
|
|
127
|
+
readonly start: HookDescriptor<"start">;
|
|
129
128
|
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
|
-
}>>;
|
|
129
|
+
protected readonly fetchLinks: RetryDescriptor<(opts: FetchLinksOptions) => Promise<ApiLinksResponse>>;
|
|
130
|
+
}
|
|
131
|
+
interface FetchLinksOptions {
|
|
132
|
+
service: string;
|
|
133
|
+
url: string;
|
|
134
|
+
authorization?: string;
|
|
145
135
|
}
|
|
146
136
|
//#endregion
|
|
147
137
|
//#region src/providers/ServerLinksProvider.d.ts
|
|
@@ -151,25 +141,25 @@ declare class ServerLinksProvider {
|
|
|
151
141
|
protected readonly helper: ActionDescriptorHelper;
|
|
152
142
|
protected readonly remoteProvider: RemoteDescriptorProvider;
|
|
153
143
|
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:
|
|
144
|
+
readonly onRoute: HookDescriptor<"server:onRoute">;
|
|
145
|
+
readonly links: RouteDescriptor<{
|
|
146
|
+
response: TObject<{
|
|
147
|
+
prefix: TOptional<TString>;
|
|
148
|
+
links: TArray<TObject<{
|
|
149
|
+
name: TString;
|
|
150
|
+
path: TString;
|
|
151
|
+
method: TOptional<TString>;
|
|
152
|
+
group: TOptional<TString>;
|
|
153
|
+
requestBodyType: TOptional<TString>;
|
|
154
|
+
service: TOptional<TString>;
|
|
165
155
|
}>>;
|
|
166
156
|
}>;
|
|
167
157
|
}>;
|
|
168
|
-
readonly schema:
|
|
169
|
-
params:
|
|
170
|
-
name:
|
|
158
|
+
readonly schema: RouteDescriptor<{
|
|
159
|
+
params: TObject<{
|
|
160
|
+
name: TString;
|
|
171
161
|
}>;
|
|
172
|
-
response:
|
|
162
|
+
response: TRecord<TString, TAny>;
|
|
173
163
|
}>;
|
|
174
164
|
getLinks(options: GetLinksOptions): Promise<ApiLinksResponse>;
|
|
175
165
|
}
|
|
@@ -179,10 +169,11 @@ interface GetLinksOptions {
|
|
|
179
169
|
}
|
|
180
170
|
//#endregion
|
|
181
171
|
//#region src/index.d.ts
|
|
172
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
182
173
|
declare class AlephaServerLinks implements Module {
|
|
183
174
|
readonly name = "alepha.server.links";
|
|
184
175
|
readonly $services: (alepha: Alepha) => void;
|
|
185
176
|
}
|
|
186
177
|
//#endregion
|
|
187
|
-
export { $client, $remote, AlephaServerLinks, ClientScope, GetLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider };
|
|
178
|
+
export { $client, $remote, AlephaServerLinks, ClientScope, FetchLinksOptions, GetLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider };
|
|
188
179
|
//# 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,37 @@
|
|
|
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
|
+
* Alepha Server Metrics Module
|
|
24
|
+
*
|
|
25
|
+
* This module provides prometheus metrics for the Alepha server.
|
|
26
|
+
* Metrics are exposed at the `/metrics` endpoint.
|
|
27
|
+
*
|
|
28
|
+
* @see {@link ServerMetricsProvider}
|
|
29
|
+
* @module alepha.server.metrics
|
|
30
|
+
*/
|
|
31
|
+
declare class AlephaServerMetrics implements Module {
|
|
32
|
+
readonly name = "alepha.server.metrics";
|
|
33
|
+
readonly $services: (alepha: Alepha) => void;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { AlephaServerMetrics, ServerMetricsProvider, ServerMetricsProviderOptions };
|
|
37
|
+
//# 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,48 @@
|
|
|
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
|
+
* Alepha Server Multipart Module
|
|
35
|
+
*
|
|
36
|
+
* This module provides support for handling multipart/form-data requests.
|
|
37
|
+
* It allows to parse body data containing t.file().
|
|
38
|
+
*
|
|
39
|
+
* @see {@link ServerMultipartProvider}
|
|
40
|
+
* @module alepha.server.multipart
|
|
41
|
+
*/
|
|
42
|
+
declare class AlephaServerMultipart implements Module {
|
|
43
|
+
readonly name = "alepha.server.multipart";
|
|
44
|
+
readonly $services: (alepha: Alepha) => void;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { AlephaServerMultipart, ServerMultipartProvider };
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/server-multipart'
|
package/server/proxy.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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
|
|
6
5
|
type ProxyDescriptorOptions = {
|
|
7
6
|
path: string;
|
|
8
|
-
target: string;
|
|
7
|
+
target: string | (() => string);
|
|
9
8
|
disabled?: boolean;
|
|
10
9
|
beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
|
|
11
10
|
afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
|
|
@@ -22,16 +21,17 @@ declare const $proxy: {
|
|
|
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,77 @@
|
|
|
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";
|
|
8
7
|
interface ServeDescriptorOptions {
|
|
9
8
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
* Prefix for the served path.
|
|
10
|
+
*
|
|
11
|
+
* @default "/"
|
|
12
|
+
*/
|
|
14
13
|
path?: string;
|
|
15
14
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
* Path to the directory to serve.
|
|
16
|
+
*
|
|
17
|
+
* @default process.cwd()
|
|
18
|
+
*/
|
|
20
19
|
root?: string;
|
|
21
20
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
* If true, descriptor will be ignored.
|
|
22
|
+
*
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
26
25
|
disabled?: boolean;
|
|
27
26
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
* Whether to keep dot files (e.g. `.gitignore`, `.env`) in the served directory.
|
|
28
|
+
*
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
32
31
|
ignoreDotEnvFiles?: boolean;
|
|
33
32
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
* Whether to use the index.html file when the path is a directory.
|
|
34
|
+
*
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
38
37
|
indexFallback?: boolean;
|
|
39
38
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
* Force all requests "not found" to be served with the index.html file.
|
|
40
|
+
* This is useful for single-page applications (SPAs) that use client-side only routing.
|
|
41
|
+
*/
|
|
43
42
|
historyApiFallback?: boolean;
|
|
44
43
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
* Optional name of the descriptor.
|
|
45
|
+
* This is used for logging and debugging purposes.
|
|
46
|
+
*
|
|
47
|
+
* @default Key name.
|
|
48
|
+
*/
|
|
50
49
|
name?: string;
|
|
51
50
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
* Whether to use cache control headers.
|
|
52
|
+
*
|
|
53
|
+
* @default {}
|
|
54
|
+
*/
|
|
56
55
|
cacheControl?: Partial<CacheControlOptions> | false;
|
|
57
56
|
}
|
|
58
57
|
interface CacheControlOptions {
|
|
59
58
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
* Whether to use cache control headers.
|
|
60
|
+
*
|
|
61
|
+
* @default [.js, .css]
|
|
62
|
+
*/
|
|
64
63
|
fileTypes: string[];
|
|
65
64
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
* The maximum age of the cache in seconds.
|
|
66
|
+
*
|
|
67
|
+
* @default 60 * 60 * 24 * 2 // 2 days
|
|
68
|
+
*/
|
|
70
69
|
maxAge: DurationLike;
|
|
71
70
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
* Whether to use immutable cache control headers.
|
|
72
|
+
*
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
76
75
|
immutable: boolean;
|
|
77
76
|
}
|
|
78
77
|
interface ServeDescriptor {
|
|
@@ -90,9 +89,9 @@ declare class ServerStaticProvider {
|
|
|
90
89
|
protected readonly alepha: Alepha;
|
|
91
90
|
protected readonly routerProvider: ServerRouterProvider;
|
|
92
91
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
93
|
-
protected readonly log:
|
|
92
|
+
protected readonly log: Logger;
|
|
94
93
|
protected readonly directories: ServeDirectory[];
|
|
95
|
-
protected readonly configure:
|
|
94
|
+
protected readonly configure: HookDescriptor<"configure">;
|
|
96
95
|
list(name: string): string[];
|
|
97
96
|
serve(options: ServeDescriptorOptions): Promise<void>;
|
|
98
97
|
createFileHandler(filepath: string, options: ServeDescriptorOptions): Promise<ServerHandler>;
|
|
@@ -108,5 +107,18 @@ interface ServeDirectory {
|
|
|
108
107
|
files: string[];
|
|
109
108
|
}
|
|
110
109
|
//#endregion
|
|
111
|
-
|
|
110
|
+
//#region src/index.d.ts
|
|
111
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
112
|
+
/**
|
|
113
|
+
* Alepha Server Static Module
|
|
114
|
+
*
|
|
115
|
+
* @see {@link ServerStaticProvider}
|
|
116
|
+
* @module alepha.server.static
|
|
117
|
+
*/
|
|
118
|
+
declare class AlephaServerStatic {
|
|
119
|
+
readonly name = "alepha.server.static";
|
|
120
|
+
readonly $services: (alepha: Alepha) => void;
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { $serve, AlephaServerStatic, CacheControlOptions, ServeDescriptor, ServeDescriptorOptions, ServeDirectory, ServerStaticProvider };
|
|
112
124
|
//# sourceMappingURL=index.d.ts.map
|