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.
Files changed (55) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +7 -34
  3. package/batch.cjs +8 -0
  4. package/batch.d.ts +147 -0
  5. package/batch.js +1 -0
  6. package/cache/redis.d.ts +13 -18
  7. package/cache.d.ts +183 -119
  8. package/command.cjs +8 -0
  9. package/command.d.ts +152 -0
  10. package/command.js +1 -0
  11. package/core.d.ts +846 -838
  12. package/datetime.d.ts +78 -78
  13. package/file.cjs +8 -0
  14. package/file.d.ts +46 -0
  15. package/file.js +1 -0
  16. package/lock/redis.d.ts +10 -12
  17. package/lock.d.ts +73 -80
  18. package/package.json +86 -34
  19. package/postgres.d.ts +348 -170
  20. package/queue/redis.d.ts +13 -13
  21. package/queue.d.ts +107 -18
  22. package/react/auth.d.ts +22 -16
  23. package/react/head.d.ts +10 -4
  24. package/react.d.ts +206 -49
  25. package/redis.d.ts +23 -27
  26. package/retry.d.ts +75 -54
  27. package/router.cjs +8 -0
  28. package/router.d.ts +45 -0
  29. package/router.js +1 -0
  30. package/scheduler.d.ts +15 -16
  31. package/security.d.ts +229 -40
  32. package/server/cache.d.ts +7 -8
  33. package/server/compress.cjs +8 -0
  34. package/server/compress.d.ts +26 -0
  35. package/server/compress.js +1 -0
  36. package/server/cookies.d.ts +249 -18
  37. package/server/cors.d.ts +7 -3
  38. package/server/health.d.ts +21 -24
  39. package/server/helmet.cjs +8 -0
  40. package/server/helmet.d.ts +70 -0
  41. package/server/helmet.js +1 -0
  42. package/server/links.d.ts +87 -93
  43. package/server/metrics.cjs +8 -0
  44. package/server/metrics.d.ts +35 -0
  45. package/server/metrics.js +1 -0
  46. package/server/multipart.cjs +8 -0
  47. package/server/multipart.d.ts +46 -0
  48. package/server/multipart.js +1 -0
  49. package/server/proxy.d.ts +11 -11
  50. package/server/static.d.ts +70 -55
  51. package/server/swagger.d.ts +55 -54
  52. package/server.d.ts +273 -123
  53. package/topic/redis.d.ts +22 -23
  54. package/topic.d.ts +26 -19
  55. package/vite.d.ts +59 -36
package/server/links.d.ts CHANGED
@@ -1,18 +1,13 @@
1
- import * as _alepha_core23 from "@alepha/core";
2
- import * as _alepha_core24 from "@alepha/core";
3
- import * as _alepha_core0 from "@alepha/core";
4
- import { Alepha, KIND, Module, OPTIONS } from "@alepha/core";
5
- import * as _alepha_server16 from "@alepha/server";
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: _alepha_core23.Logger;
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
- * Resolve a link by its name and call it.
24
- * - If link is local, it will call the local handler.
25
- * - If link is remote, it will make a fetch request to the remote server.
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
- * The URL of the remote service.
57
- * You can use a function to generate the URL dynamically.
58
- * You probably should use $inject(env) to get the URL from the environment.
59
- *
60
- * @example
61
- * ```ts
62
- * import { $remote } from "@alepha/server";
63
- * import { $inject, t } from "@alepha/core";
64
- *
65
- * class App {
66
- * env = $inject(t.object({
67
- * REMOTE_URL: t.string({default: "http://localhost:3000"}),
68
- * }));
69
- * remote = $remote({
70
- * url: this.env.REMOTE_URL,
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
- * The name of the remote service.
78
- *
79
- * @default Member of the class containing the remote service.
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
- * If true, all methods of the remote service will be exposed as actions in this context.
84
- * > Note: Proxy will never use the service account, it just... proxies the request.
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
- * If true, the remote service won't be available internally, only through the proxy.
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
- * For communication between the server and the remote service with a security layer.
94
- * This will be used for internal communication and will not be exposed to the client.
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: _alepha_core24.Logger;
127
+ protected readonly log: Logger;
126
128
  getRemotes(): ServerRemote[];
127
- readonly configure: _alepha_core24.HookDescriptor<"configure">;
128
- readonly start: _alepha_core24.HookDescriptor<"start">;
129
+ readonly configure: HookDescriptor<"configure">;
130
+ readonly start: HookDescriptor<"start">;
129
131
  registerRemote(value: RemoteDescriptor, key: string): Promise<void>;
130
- protected readonly fetchLinks: _alepha_retry27.RetryDescriptor<(opts: {
131
- service: string;
132
- url: string;
133
- authorization?: string;
134
- }) => Promise<{
135
- prefix?: string | undefined;
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: _alepha_core0.HookDescriptor<"server:onRoute">;
155
- readonly links: _alepha_server16.RouteDescriptor<{
156
- response: _sinclair_typebox1.TObject<{
157
- prefix: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
158
- links: _sinclair_typebox1.TArray<_sinclair_typebox1.TObject<{
159
- name: _sinclair_typebox1.TString;
160
- path: _sinclair_typebox1.TString;
161
- method: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
162
- group: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
163
- requestBodyType: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
164
- service: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
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: _alepha_server16.RouteDescriptor<{
169
- params: _sinclair_typebox1.TObject<{
170
- name: _sinclair_typebox1.TString;
161
+ readonly schema: RouteDescriptor<{
162
+ params: TObject<{
163
+ name: TString;
171
164
  }>;
172
- response: _sinclair_typebox1.TRecord<_sinclair_typebox1.TString, _sinclair_typebox1.TAny>;
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 * as _alepha_core0 from "@alepha/core";
2
- import { Alepha, Async, KIND, Module, OPTIONS } from "@alepha/core";
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: _alepha_core0.Logger;
24
+ protected readonly log: Logger;
26
25
  protected readonly routerProvider: ServerRouterProvider;
27
26
  protected readonly alepha: Alepha;
28
- readonly configure: _alepha_core0.HookDescriptor<"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;
@@ -1,78 +1,84 @@
1
- import * as _alepha_core0 from "@alepha/core";
2
- import { Alepha, KIND, OPTIONS } from "@alepha/core";
3
- import { DateTimeProvider, DurationLike } from "@alepha/datetime";
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
- * Prefix for the served path.
11
- *
12
- * @default "/"
13
- */
16
+ * Prefix for the served path.
17
+ *
18
+ * @default "/"
19
+ */
14
20
  path?: string;
15
21
  /**
16
- * Path to the directory to serve.
17
- *
18
- * @default process.cwd()
19
- */
22
+ * Path to the directory to serve.
23
+ *
24
+ * @default process.cwd()
25
+ */
20
26
  root?: string;
21
27
  /**
22
- * If true, descriptor will be ignored.
23
- *
24
- * @default false
25
- */
28
+ * If true, descriptor will be ignored.
29
+ *
30
+ * @default false
31
+ */
26
32
  disabled?: boolean;
27
33
  /**
28
- * Whether to keep dot files (e.g. `.gitignore`, `.env`) in the served directory.
29
- *
30
- * @default true
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
- * Whether to use the index.html file when the path is a directory.
35
- *
36
- * @default true
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
- * Force all requests "not found" to be served with the index.html file.
41
- * This is useful for single-page applications (SPAs) that use client-side only routing.
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
- * Optional name of the descriptor.
46
- * This is used for logging and debugging purposes.
47
- *
48
- * @default Key name.
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
- * Whether to use cache control headers.
53
- *
54
- * @default {}
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
- * Whether to use cache control headers.
61
- *
62
- * @default [.js, .css]
63
- */
66
+ * Whether to use cache control headers.
67
+ *
68
+ * @default [.js, .css]
69
+ */
64
70
  fileTypes: string[];
65
71
  /**
66
- * The maximum age of the cache in seconds.
67
- *
68
- * @default 60 * 60 * 24 * 2 // 2 days
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
- * Whether to use immutable cache control headers.
73
- *
74
- * @default true
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: _alepha_core0.Logger;
95
+ protected readonly log: Logger;
94
96
  protected readonly directories: ServeDirectory[];
95
- protected readonly configure: _alepha_core0.HookDescriptor<"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
- export { $serve, CacheControlOptions, ServeDescriptor, ServeDescriptorOptions, ServeDirectory, ServerStaticProvider };
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