alepha 0.8.1 → 0.9.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/README.md +47 -17
- package/batch.d.ts +83 -117
- package/bucket.cjs +8 -0
- package/bucket.d.ts +194 -0
- package/bucket.js +1 -0
- package/cache/redis.d.ts +14 -14
- package/cache.d.ts +101 -238
- package/command.d.ts +66 -71
- package/core.d.ts +1003 -851
- package/datetime.d.ts +90 -116
- package/file.d.ts +23 -13
- package/lock/redis.d.ts +11 -11
- package/lock.d.ts +121 -111
- package/package.json +54 -40
- package/postgres.d.ts +218 -393
- package/queue/redis.d.ts +13 -13
- package/queue.d.ts +84 -198
- package/react/auth.d.ts +47 -53
- package/react/head.d.ts +4 -7
- package/react.d.ts +47 -183
- package/redis.d.ts +31 -16
- package/retry.d.ts +70 -59
- package/router.d.ts +9 -9
- package/scheduler.d.ts +54 -93
- package/security.d.ts +95 -276
- package/server/cache.d.ts +22 -28
- package/server/compress.d.ts +16 -7
- package/server/cookies.d.ts +65 -233
- package/server/cors.d.ts +15 -13
- package/server/health.d.ts +23 -23
- package/server/helmet.d.ts +17 -18
- package/server/links.d.ts +108 -88
- package/server/metrics.d.ts +25 -21
- package/server/multipart.d.ts +12 -14
- package/server/proxy.d.ts +22 -17
- package/server/security.cjs +8 -0
- package/server/security.d.ts +90 -0
- package/server/security.js +1 -0
- package/server/static.d.ts +63 -67
- package/server/swagger.d.ts +73 -62
- package/server.d.ts +250 -446
- package/topic/redis.d.ts +25 -24
- package/topic.d.ts +68 -115
package/server/cache.d.ts
CHANGED
|
@@ -1,48 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
1
|
+
import * as _alepha_cache0 from "alepha/cache";
|
|
2
|
+
import { CacheDescriptorOptions } from "alepha/cache";
|
|
3
|
+
import * as _alepha_core0$1 from "alepha";
|
|
4
|
+
import * as _alepha_core0 from "alepha";
|
|
5
|
+
import { Alepha } from "alepha";
|
|
5
6
|
import { DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
7
|
+
import { RequestConfigSchema, ServerRequest, ServerRoute } from "alepha/server";
|
|
6
8
|
|
|
7
9
|
//#region src/providers/ServerCacheProvider.d.ts
|
|
8
10
|
declare module "alepha/server" {
|
|
9
11
|
interface ServerRoute {
|
|
10
12
|
cache?: ServerRouteCache;
|
|
11
13
|
}
|
|
12
|
-
interface ActionDescriptor {
|
|
14
|
+
interface ActionDescriptor<TConfig extends RequestConfigSchema> {
|
|
13
15
|
invalidate: () => Promise<void>;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
declare class ServerCacheProvider {
|
|
17
|
-
protected readonly log:
|
|
19
|
+
protected readonly log: _alepha_core0$1.Logger;
|
|
18
20
|
protected readonly alepha: Alepha;
|
|
19
|
-
protected readonly cacheProvider: CacheDescriptorProvider;
|
|
20
21
|
protected readonly time: DateTimeProvider;
|
|
21
|
-
protected readonly
|
|
22
|
-
readonly onConfigure: _alepha_core1.HookDescriptor<"configure">;
|
|
23
|
-
readonly onRoute: _alepha_core1.HookDescriptor<"server:onRoute">;
|
|
24
|
-
readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
25
|
-
readonly onSend: _alepha_core1.HookDescriptor<"server:onResponse">;
|
|
22
|
+
protected readonly cache: _alepha_cache0.CacheDescriptorFn<RouteCacheEntry, any[]>;
|
|
26
23
|
generateETag(content: string): string;
|
|
27
|
-
invalidate(route:
|
|
28
|
-
protected
|
|
29
|
-
protected
|
|
24
|
+
invalidate(route: ServerRoute): Promise<void>;
|
|
25
|
+
protected readonly onRequest: _alepha_core0$1.HookDescriptor<"server:onRequest">;
|
|
26
|
+
protected readonly onSend: _alepha_core0$1.HookDescriptor<"server:onResponse">;
|
|
27
|
+
protected getCacheOptions(cache: ServerRouteCache): {
|
|
28
|
+
provider?: (_alepha_core0$1.InstantiableClass<_alepha_cache0.CacheProvider> | "memory") | undefined;
|
|
29
|
+
name?: string | undefined;
|
|
30
|
+
ttl?: DurationLike | undefined;
|
|
31
|
+
disabled?: boolean | undefined;
|
|
32
|
+
};
|
|
33
|
+
protected createCacheKey(route: ServerRoute, args?: ServerRequest): string;
|
|
30
34
|
}
|
|
31
35
|
type ServerRouteCache = boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
|
|
32
|
-
|
|
36
|
+
interface RouteCacheEntry {
|
|
33
37
|
contentType?: string;
|
|
34
38
|
body: string;
|
|
35
39
|
status?: number;
|
|
36
40
|
lastModified: string;
|
|
37
41
|
hash: string;
|
|
38
|
-
}
|
|
39
|
-
type RouteLike = {
|
|
40
|
-
[OPTIONS]: {
|
|
41
|
-
handler?: ServerHandler;
|
|
42
|
-
};
|
|
43
|
-
} | {
|
|
44
|
-
handler?: ServerHandler;
|
|
45
|
-
};
|
|
42
|
+
}
|
|
46
43
|
//#endregion
|
|
47
44
|
//#region src/index.d.ts
|
|
48
45
|
/**
|
|
@@ -73,10 +70,7 @@ type RouteLike = {
|
|
|
73
70
|
* @see {@link ServerCacheProvider}
|
|
74
71
|
* @module alepha.server.cache
|
|
75
72
|
*/
|
|
76
|
-
declare
|
|
77
|
-
readonly name = "alepha.server.cache";
|
|
78
|
-
readonly $services: (alepha: Alepha) => Alepha;
|
|
79
|
-
}
|
|
73
|
+
declare const AlephaServerCache: _alepha_core0.ModuleDescriptor;
|
|
80
74
|
//# sourceMappingURL=index.d.ts.map
|
|
81
75
|
|
|
82
76
|
//#endregion
|
package/server/compress.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as _alepha_core0 from "alepha";
|
|
2
|
+
import { HookDescriptor } from "alepha";
|
|
1
3
|
import { ServerResponse } from "alepha/server";
|
|
2
4
|
import { Transform } from "node:stream";
|
|
3
|
-
import { Alepha, HookDescriptor, Module } from "alepha";
|
|
4
5
|
|
|
5
6
|
//#region src/providers/ServerCompressProvider.d.ts
|
|
6
7
|
declare class ServerCompressProvider {
|
|
@@ -8,19 +9,27 @@ declare class ServerCompressProvider {
|
|
|
8
9
|
compress: (...args: any[]) => Promise<Buffer>;
|
|
9
10
|
stream: (options?: any) => Transform;
|
|
10
11
|
} | undefined>;
|
|
12
|
+
options: ServerCompressProviderOptions;
|
|
11
13
|
readonly onResponse: HookDescriptor<"server:onResponse">;
|
|
12
14
|
protected isAllowedContentType(contentType: string | undefined): boolean;
|
|
13
15
|
protected compress(encoding: keyof typeof (void 0).compressors, response: ServerResponse): Promise<void>;
|
|
14
16
|
protected getParams(encoding: keyof typeof (void 0).compressors): Record<number, any>;
|
|
15
17
|
protected setHeaders(response: ServerResponse, encoding: keyof typeof (void 0).compressors): void;
|
|
16
18
|
}
|
|
19
|
+
interface ServerCompressProviderOptions {
|
|
20
|
+
allowedContentTypes: string[];
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ServerCompressProvider.d.ts.map
|
|
17
23
|
//#endregion
|
|
18
24
|
//#region src/index.d.ts
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Plugin for Alepha Server that provides server-side compression capabilities.
|
|
27
|
+
*
|
|
28
|
+
* Compresses responses using gzip, brotli, or zstd based on the `Accept-Encoding` header.
|
|
29
|
+
*/
|
|
30
|
+
declare const AlephaServerCompress: _alepha_core0.ModuleDescriptor;
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
32
|
+
|
|
24
33
|
//#endregion
|
|
25
|
-
export { AlephaServerCompress, ServerCompressProvider };
|
|
34
|
+
export { AlephaServerCompress, ServerCompressProvider, ServerCompressProviderOptions };
|
|
26
35
|
//# sourceMappingURL=index.d.ts.map
|
package/server/cookies.d.ts
CHANGED
|
@@ -1,18 +1,53 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _alepha_core0$1 from "alepha";
|
|
2
|
+
import * as _alepha_core0 from "alepha";
|
|
3
|
+
import { Alepha, Descriptor, KIND, Static, TSchema } from "alepha";
|
|
2
4
|
import { DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
3
5
|
|
|
6
|
+
//#region src/providers/ServerCookiesProvider.d.ts
|
|
7
|
+
declare const envSchema: _alepha_core0$1.TObject<{
|
|
8
|
+
/**
|
|
9
|
+
* A 32-byte secret key used for cookie encryption and signing. MUST be set for `encrypt` or `sign` to work.
|
|
10
|
+
*/
|
|
11
|
+
COOKIE_SECRET: _alepha_core0$1.TOptional<_alepha_core0$1.TString>;
|
|
12
|
+
}>;
|
|
13
|
+
declare module "alepha" {
|
|
14
|
+
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
15
|
+
}
|
|
16
|
+
declare class ServerCookiesProvider {
|
|
17
|
+
protected readonly alepha: Alepha;
|
|
18
|
+
protected readonly log: _alepha_core0$1.Logger;
|
|
19
|
+
protected readonly env: {
|
|
20
|
+
COOKIE_SECRET?: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
23
|
+
protected readonly ALGORITHM = "aes-256-gcm";
|
|
24
|
+
protected readonly IV_LENGTH = 16;
|
|
25
|
+
protected readonly AUTH_TAG_LENGTH = 16;
|
|
26
|
+
protected readonly SIGNATURE_LENGTH = 32;
|
|
27
|
+
readonly onRequest: _alepha_core0$1.HookDescriptor<"server:onRequest">;
|
|
28
|
+
readonly onSend: _alepha_core0$1.HookDescriptor<"server:onSend">;
|
|
29
|
+
protected getCookiesFromContext(cookies?: Cookies): Cookies;
|
|
30
|
+
getCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, contextCookies?: Cookies): Static<T> | undefined;
|
|
31
|
+
setCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, data: Static<T>, contextCookies?: Cookies): void;
|
|
32
|
+
deleteCookie<T extends TSchema>(name: string, contextCookies?: Cookies): void;
|
|
33
|
+
protected encrypt(text: string): string;
|
|
34
|
+
protected decrypt(encryptedText: string): string;
|
|
35
|
+
secretKey(): string;
|
|
36
|
+
protected sign(data: string): string;
|
|
37
|
+
protected parseRequestCookies(header: string): Record<string, string>;
|
|
38
|
+
protected serializeResponseCookies(cookies: Record<string, Cookie | null>, isHttps: boolean): string[];
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
4
41
|
//#region src/descriptors/$cookie.d.ts
|
|
5
|
-
declare const KEY = "COOKIE";
|
|
6
42
|
/**
|
|
7
|
-
* Declares a type-safe, configurable HTTP cookie.
|
|
8
|
-
* This descriptor provides methods to get, set, and delete the cookie
|
|
9
|
-
* within the server request/response cycle.
|
|
10
|
-
*/
|
|
43
|
+
* Declares a type-safe, configurable HTTP cookie.
|
|
44
|
+
* This descriptor provides methods to get, set, and delete the cookie
|
|
45
|
+
* within the server request/response cycle.
|
|
46
|
+
*/
|
|
11
47
|
declare const $cookie: {
|
|
12
48
|
<T extends TSchema>(options: CookieDescriptorOptions<T>): CookieDescriptor<T>;
|
|
13
|
-
[KIND]:
|
|
49
|
+
[KIND]: typeof CookieDescriptor;
|
|
14
50
|
};
|
|
15
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
16
51
|
interface CookieDescriptorOptions<T extends TSchema> {
|
|
17
52
|
/** The schema for the cookie's value, used for validation and type safety. */
|
|
18
53
|
schema: T;
|
|
@@ -37,22 +72,21 @@ interface CookieDescriptorOptions<T extends TSchema> {
|
|
|
37
72
|
/** If true, the cookie will be signed to prevent tampering. Requires `COOKIE_SECRET` env var. */
|
|
38
73
|
sign?: boolean;
|
|
39
74
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
schema: T;
|
|
75
|
+
declare class CookieDescriptor<T extends TSchema> extends Descriptor<CookieDescriptorOptions<T>> {
|
|
76
|
+
protected readonly serverCookiesProvider: ServerCookiesProvider;
|
|
77
|
+
get name(): string;
|
|
44
78
|
/** Sets the cookie with the given value in the current request's response. */
|
|
45
|
-
set
|
|
79
|
+
set(value: Static<T>, options?: {
|
|
46
80
|
cookies?: Cookies;
|
|
47
|
-
})
|
|
81
|
+
}): void;
|
|
48
82
|
/** Gets the cookie value from the current request. Returns undefined if not found or invalid. */
|
|
49
|
-
get
|
|
83
|
+
get(options?: {
|
|
50
84
|
cookies?: Cookies;
|
|
51
|
-
})
|
|
85
|
+
}): Static<T> | undefined;
|
|
52
86
|
/** Deletes the cookie in the current request's response. */
|
|
53
|
-
del
|
|
87
|
+
del(options?: {
|
|
54
88
|
cookies?: Cookies;
|
|
55
|
-
})
|
|
89
|
+
}): void;
|
|
56
90
|
}
|
|
57
91
|
interface Cookies {
|
|
58
92
|
req: Record<string, string>;
|
|
@@ -67,229 +101,27 @@ interface Cookie {
|
|
|
67
101
|
sameSite?: "strict" | "lax" | "none";
|
|
68
102
|
domain?: string;
|
|
69
103
|
}
|
|
70
|
-
//#
|
|
71
|
-
//#region src/providers/ServerCookiesProvider.d.ts
|
|
72
|
-
declare const envSchema: TObject<{
|
|
73
|
-
COOKIE_SECRET: TOptional<TString>;
|
|
74
|
-
}>;
|
|
75
|
-
declare module "alepha" {
|
|
76
|
-
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
77
|
-
}
|
|
78
|
-
declare class ServerCookiesProvider {
|
|
79
|
-
protected readonly alepha: Alepha;
|
|
80
|
-
protected readonly log: Logger;
|
|
81
|
-
protected readonly env: Static<typeof envSchema>;
|
|
82
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
83
|
-
// Crypto constants
|
|
84
|
-
protected readonly ALGORITHM = "aes-256-gcm";
|
|
85
|
-
protected readonly IV_LENGTH = 16;
|
|
86
|
-
protected readonly AUTH_TAG_LENGTH = 16;
|
|
87
|
-
protected readonly SIGNATURE_LENGTH = 32;
|
|
88
|
-
protected readonly configure: HookDescriptor<"configure">;
|
|
89
|
-
protected createApi<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>): CookieDescriptor<T>;
|
|
90
|
-
readonly onRequest: HookDescriptor<"server:onRequest">;
|
|
91
|
-
readonly onSend: HookDescriptor<"server:onSend">;
|
|
92
|
-
protected getCookiesFromContext(cookies?: Cookies): Cookies;
|
|
93
|
-
protected getCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, contextCookies?: Cookies): Static<T> | undefined;
|
|
94
|
-
protected setCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, data: Static<T>, contextCookies?: Cookies): void;
|
|
95
|
-
protected deleteCookie<T extends TSchema>(name: string, contextCookies?: Cookies): void;
|
|
96
|
-
// --- Crypto & Parsing ---
|
|
97
|
-
protected encrypt(text: string): string;
|
|
98
|
-
protected decrypt(encryptedText: string): string;
|
|
99
|
-
secretKey(): string;
|
|
100
|
-
protected sign(data: string): string;
|
|
101
|
-
protected parseRequestCookies(header: string): Record<string, string>;
|
|
102
|
-
protected serializeResponseCookies(cookies: Record<string, Cookie | null>, isHttps: boolean): string[];
|
|
103
|
-
}
|
|
104
|
+
//# sourceMappingURL=$cookie.d.ts.map
|
|
104
105
|
//#endregion
|
|
105
106
|
//#region src/index.d.ts
|
|
106
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
107
107
|
declare module "alepha/server" {
|
|
108
108
|
interface ServerRequest {
|
|
109
109
|
cookies: Cookies;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
|
-
* Provides HTTP cookie management capabilities for server requests and responses with type-safe cookie descriptors.
|
|
114
|
-
*
|
|
115
|
-
* The server-cookies module enables declarative cookie handling using the `$cookie` descriptor on class properties.
|
|
116
|
-
* It offers automatic cookie parsing, secure cookie configuration, and seamless integration with server routes
|
|
117
|
-
* for managing user sessions, preferences, and authentication tokens.
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
* - Integration with server request/response lifecycle
|
|
126
|
-
*
|
|
127
|
-
* **Basic Usage:**
|
|
128
|
-
* ```ts
|
|
129
|
-
* import { Alepha, run, t } from "alepha";
|
|
130
|
-
* import { AlephaServer, $route } from "alepha/server";
|
|
131
|
-
* import { AlephaServerCookies, $cookie } from "alepha/server/cookies";
|
|
132
|
-
*
|
|
133
|
-
* class AuthRoutes {
|
|
134
|
-
* // Define authentication cookie
|
|
135
|
-
* authToken = $cookie({
|
|
136
|
-
* name: "auth_token",
|
|
137
|
-
* httpOnly: true,
|
|
138
|
-
* secure: true,
|
|
139
|
-
* sameSite: "strict",
|
|
140
|
-
* maxAge: "7d",
|
|
141
|
-
* });
|
|
142
|
-
*
|
|
143
|
-
* // Define user preferences cookie
|
|
144
|
-
* userPrefs = $cookie({
|
|
145
|
-
* name: "user_prefs",
|
|
146
|
-
* schema: t.object({
|
|
147
|
-
* theme: t.union([t.literal("light"), t.literal("dark")]),
|
|
148
|
-
* language: t.string(),
|
|
149
|
-
* }),
|
|
150
|
-
* maxAge: "30d",
|
|
151
|
-
* });
|
|
152
|
-
*
|
|
153
|
-
* login = $route({
|
|
154
|
-
* path: "/login",
|
|
155
|
-
* method: "POST",
|
|
156
|
-
* schema: {
|
|
157
|
-
* body: t.object({
|
|
158
|
-
* email: t.string(),
|
|
159
|
-
* password: t.string(),
|
|
160
|
-
* }),
|
|
161
|
-
* },
|
|
162
|
-
* handler: async ({ body, reply }) => {
|
|
163
|
-
* const user = await authenticateUser(body.email, body.password);
|
|
164
|
-
* if (!user) {
|
|
165
|
-
* return new Response("Invalid credentials", { status: 401 });
|
|
166
|
-
* }
|
|
167
|
-
*
|
|
168
|
-
* const token = await generateJWT(user.id);
|
|
169
|
-
*
|
|
170
|
-
* // Set authentication cookie
|
|
171
|
-
* this.authToken.set(reply, token);
|
|
172
|
-
*
|
|
173
|
-
* return Response.json({ success: true, user });
|
|
174
|
-
* },
|
|
175
|
-
* });
|
|
176
|
-
*
|
|
177
|
-
* profile = $route({
|
|
178
|
-
* path: "/profile",
|
|
179
|
-
* method: "GET",
|
|
180
|
-
* handler: async ({ cookies }) => {
|
|
181
|
-
* // Get authentication token from cookie
|
|
182
|
-
* const token = this.authToken.get(cookies);
|
|
183
|
-
* if (!token) {
|
|
184
|
-
* return new Response("Unauthorized", { status: 401 });
|
|
185
|
-
* }
|
|
186
|
-
*
|
|
187
|
-
* const user = await validateJWT(token);
|
|
188
|
-
* const preferences = this.userPrefs.get(cookies) || {
|
|
189
|
-
* theme: "light",
|
|
190
|
-
* language: "en",
|
|
191
|
-
* };
|
|
192
|
-
*
|
|
193
|
-
* return Response.json({ user, preferences });
|
|
194
|
-
* },
|
|
195
|
-
* });
|
|
196
|
-
*
|
|
197
|
-
* logout = $route({
|
|
198
|
-
* path: "/logout",
|
|
199
|
-
* method: "POST",
|
|
200
|
-
* handler: async ({ reply }) => {
|
|
201
|
-
* // Clear authentication cookie
|
|
202
|
-
* this.authToken.clear(reply);
|
|
203
|
-
* return Response.json({ success: true });
|
|
204
|
-
* },
|
|
205
|
-
* });
|
|
206
|
-
* }
|
|
207
|
-
*
|
|
208
|
-
* const alepha = Alepha.create()
|
|
209
|
-
* .with(AlephaServer)
|
|
210
|
-
* .with(AlephaServerCookies)
|
|
211
|
-
* .with(AuthRoutes);
|
|
212
|
-
*
|
|
213
|
-
* run(alepha);
|
|
214
|
-
* ```
|
|
215
|
-
*
|
|
216
|
-
* **Advanced Cookie Management:**
|
|
217
|
-
* ```ts
|
|
218
|
-
* class SessionRoutes {
|
|
219
|
-
* // Session cookie with custom configuration
|
|
220
|
-
* sessionId = $cookie({
|
|
221
|
-
* name: "session_id",
|
|
222
|
-
* httpOnly: true,
|
|
223
|
-
* secure: process.env.NODE_ENV === "production",
|
|
224
|
-
* sameSite: "lax",
|
|
225
|
-
* path: "/",
|
|
226
|
-
* maxAge: "2h",
|
|
227
|
-
* encrypt: true, // Optional encryption
|
|
228
|
-
* });
|
|
229
|
-
*
|
|
230
|
-
* // Shopping cart cookie
|
|
231
|
-
* cart = $cookie({
|
|
232
|
-
* name: "shopping_cart",
|
|
233
|
-
* schema: t.object({
|
|
234
|
-
* items: t.array(t.object({
|
|
235
|
-
* id: t.string(),
|
|
236
|
-
* quantity: t.number(),
|
|
237
|
-
* })),
|
|
238
|
-
* total: t.number(),
|
|
239
|
-
* }),
|
|
240
|
-
* maxAge: "30d",
|
|
241
|
-
* });
|
|
242
|
-
*
|
|
243
|
-
* // Tracking consent cookie
|
|
244
|
-
* consent = $cookie({
|
|
245
|
-
* name: "tracking_consent",
|
|
246
|
-
* schema: t.object({
|
|
247
|
-
* analytics: t.boolean(),
|
|
248
|
-
* marketing: t.boolean(),
|
|
249
|
-
* functional: t.boolean(),
|
|
250
|
-
* }),
|
|
251
|
-
* maxAge: "1y",
|
|
252
|
-
* });
|
|
253
|
-
*
|
|
254
|
-
* updateCart = $route({
|
|
255
|
-
* path: "/cart",
|
|
256
|
-
* method: "POST",
|
|
257
|
-
* schema: {
|
|
258
|
-
* body: t.object({
|
|
259
|
-
* productId: t.string(),
|
|
260
|
-
* quantity: t.number(),
|
|
261
|
-
* }),
|
|
262
|
-
* },
|
|
263
|
-
* handler: async ({ body, cookies, reply }) => {
|
|
264
|
-
* const currentCart = this.cart.get(cookies) || { items: [], total: 0 };
|
|
265
|
-
*
|
|
266
|
-
* // Update cart logic
|
|
267
|
-
* const existingItem = currentCart.items.find(item => item.id === body.productId);
|
|
268
|
-
* if (existingItem) {
|
|
269
|
-
* existingItem.quantity = body.quantity;
|
|
270
|
-
* } else {
|
|
271
|
-
* currentCart.items.push({ id: body.productId, quantity: body.quantity });
|
|
272
|
-
* }
|
|
273
|
-
*
|
|
274
|
-
* // Recalculate total
|
|
275
|
-
* currentCart.total = await calculateCartTotal(currentCart.items);
|
|
276
|
-
*
|
|
277
|
-
* // Update cookie
|
|
278
|
-
* this.cart.set(reply, currentCart);
|
|
279
|
-
*
|
|
280
|
-
* return Response.json(currentCart);
|
|
281
|
-
* },
|
|
282
|
-
* });
|
|
283
|
-
* }
|
|
284
|
-
* ```
|
|
285
|
-
*
|
|
286
|
-
* @see {@link $cookie}
|
|
287
|
-
* @module alepha.server.cookies
|
|
288
|
-
*/
|
|
289
|
-
declare class AlephaServerCookies implements Module {
|
|
290
|
-
readonly name = "alepha.server.cookies";
|
|
291
|
-
readonly $services: (alepha: Alepha) => void;
|
|
292
|
-
}
|
|
113
|
+
* Provides HTTP cookie management capabilities for server requests and responses with type-safe cookie descriptors.
|
|
114
|
+
*
|
|
115
|
+
* The server-cookies module enables declarative cookie handling using the `$cookie` descriptor on class properties.
|
|
116
|
+
* It offers automatic cookie parsing, secure cookie configuration, and seamless integration with server routes
|
|
117
|
+
* for managing user sessions, preferences, and authentication tokens.
|
|
118
|
+
*
|
|
119
|
+
* @see {@link $cookie}
|
|
120
|
+
* @module alepha.server.cookies
|
|
121
|
+
*/
|
|
122
|
+
declare const AlephaServerCookies: _alepha_core0.ModuleDescriptor;
|
|
123
|
+
//# sourceMappingURL=index.d.ts.map
|
|
124
|
+
|
|
293
125
|
//#endregion
|
|
294
126
|
export { $cookie, AlephaServerCookies, Cookie, CookieDescriptor, CookieDescriptorOptions, Cookies, ServerCookiesProvider };
|
|
295
127
|
//# sourceMappingURL=index.d.ts.map
|
package/server/cors.d.ts
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
|
+
import * as _alepha_core0$1 from "alepha";
|
|
2
|
+
import * as _alepha_core0 from "alepha";
|
|
1
3
|
import { ServerRouterProvider } from "alepha/server";
|
|
2
|
-
import { Alepha, HookDescriptor, Module } from "alepha";
|
|
3
4
|
|
|
4
5
|
//#region src/providers/ServerCorsProvider.d.ts
|
|
5
6
|
declare class ServerCorsProvider {
|
|
6
7
|
protected readonly serverRouterProvider: ServerRouterProvider;
|
|
7
|
-
options:
|
|
8
|
-
protected readonly
|
|
9
|
-
protected readonly onRequest: HookDescriptor<"server:onRequest">;
|
|
10
|
-
isOriginAllowed(origin: string | undefined, allowed:
|
|
8
|
+
options: ServerCorsProviderOptions;
|
|
9
|
+
protected readonly configure: _alepha_core0$1.HookDescriptor<"configure">;
|
|
10
|
+
protected readonly onRequest: _alepha_core0$1.HookDescriptor<"server:onRequest">;
|
|
11
|
+
isOriginAllowed(origin: string | undefined, allowed: ServerCorsProviderOptions["origin"]): boolean;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
interface CorsOptions {
|
|
13
|
+
interface ServerCorsProviderOptions {
|
|
14
14
|
origin?: string | string[] | ((origin: string | undefined) => boolean);
|
|
15
15
|
methods: string[];
|
|
16
16
|
headers: string[];
|
|
17
17
|
credentials?: boolean;
|
|
18
18
|
maxAge?: number;
|
|
19
19
|
}
|
|
20
|
+
//# sourceMappingURL=ServerCorsProvider.d.ts.map
|
|
20
21
|
//#endregion
|
|
21
22
|
//#region src/index.d.ts
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Plugin for configuring CORS on the Alepha server.
|
|
25
|
+
*/
|
|
26
|
+
declare const AlephaServerCors: _alepha_core0.ModuleDescriptor;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
28
|
+
|
|
27
29
|
//#endregion
|
|
28
|
-
export { AlephaServerCors,
|
|
30
|
+
export { AlephaServerCors, ServerCorsProvider, ServerCorsProviderOptions };
|
|
29
31
|
//# sourceMappingURL=index.d.ts.map
|
package/server/health.d.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Alepha
|
|
1
|
+
import * as _alepha_core0 from "alepha";
|
|
2
|
+
import { Alepha } from "alepha";
|
|
3
|
+
import * as _alepha_server0 from "alepha/server";
|
|
3
4
|
import { DateTimeProvider } from "alepha/datetime";
|
|
5
|
+
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
4
6
|
|
|
5
7
|
//#region src/providers/ServerHealthProvider.d.ts
|
|
6
|
-
|
|
7
8
|
/**
|
|
8
|
-
* Register `/health` endpoint.
|
|
9
|
-
*
|
|
10
|
-
* - Provides basic health information about the server.
|
|
11
|
-
*/
|
|
9
|
+
* Register `/health` endpoint.
|
|
10
|
+
*
|
|
11
|
+
* - Provides basic health information about the server.
|
|
12
|
+
*/
|
|
12
13
|
declare class ServerHealthProvider {
|
|
13
14
|
protected readonly time: DateTimeProvider;
|
|
14
15
|
protected readonly alepha: Alepha;
|
|
15
|
-
readonly health: RouteDescriptor<{
|
|
16
|
-
response: TObject<{
|
|
17
|
-
message: TString;
|
|
18
|
-
uptime: TNumber;
|
|
19
|
-
date: TString;
|
|
20
|
-
ready: TBoolean;
|
|
16
|
+
readonly health: _alepha_server0.RouteDescriptor<{
|
|
17
|
+
response: _sinclair_typebox0.TObject<{
|
|
18
|
+
message: _sinclair_typebox0.TString;
|
|
19
|
+
uptime: _sinclair_typebox0.TNumber;
|
|
20
|
+
date: _sinclair_typebox0.TString;
|
|
21
|
+
ready: _sinclair_typebox0.TBoolean;
|
|
21
22
|
}>;
|
|
22
23
|
}>;
|
|
23
24
|
}
|
|
25
|
+
//# sourceMappingURL=ServerHealthProvider.d.ts.map
|
|
24
26
|
//#endregion
|
|
25
27
|
//#region src/index.d.ts
|
|
26
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
27
28
|
/**
|
|
28
|
-
* Plugin for Alepha Server that provides health-check endpoints.
|
|
29
|
-
*
|
|
30
|
-
* @see {@link ServerHealthProvider}
|
|
31
|
-
* @module alepha.server.health
|
|
32
|
-
*/
|
|
33
|
-
declare
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
29
|
+
* Plugin for Alepha Server that provides health-check endpoints.
|
|
30
|
+
*
|
|
31
|
+
* @see {@link ServerHealthProvider}
|
|
32
|
+
* @module alepha.server.health
|
|
33
|
+
*/
|
|
34
|
+
declare const AlephaServerHealth: _alepha_core0.ModuleDescriptor;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
36
|
+
|
|
37
37
|
//#endregion
|
|
38
38
|
export { AlephaServerHealth, ServerHealthProvider };
|
|
39
39
|
//# sourceMappingURL=index.d.ts.map
|
package/server/helmet.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _alepha_core0 from "alepha";
|
|
2
|
+
import { Alepha, HookDescriptor } from "alepha";
|
|
2
3
|
|
|
3
4
|
//#region src/providers/ServerHelmetProvider.d.ts
|
|
4
5
|
type CspDirective = string | string[];
|
|
@@ -38,33 +39,31 @@ interface HelmetOptions {
|
|
|
38
39
|
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
|
}
|
|
40
41
|
/**
|
|
41
|
-
* Provides a configurable way to apply essential HTTP security headers
|
|
42
|
-
* to every server response, without external dependencies.
|
|
43
|
-
*/
|
|
42
|
+
* Provides a configurable way to apply essential HTTP security headers
|
|
43
|
+
* to every server response, without external dependencies.
|
|
44
|
+
*/
|
|
44
45
|
declare class ServerHelmetProvider {
|
|
45
46
|
protected readonly alepha: Alepha;
|
|
46
47
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
* The configuration options. These can be overridden during
|
|
49
|
+
* the application's configuration phase using `alepha.configure()`.
|
|
50
|
+
*/
|
|
50
51
|
options: HelmetOptions;
|
|
51
52
|
private buildHeaders;
|
|
52
53
|
protected readonly onResponse: HookDescriptor<"server:onResponse">;
|
|
53
54
|
}
|
|
54
55
|
//#endregion
|
|
55
56
|
//#region src/index.d.ts
|
|
56
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
57
57
|
/**
|
|
58
|
-
* Automatically adds important HTTP security headers to every response
|
|
59
|
-
* to help protect your application from common web vulnerabilities.
|
|
60
|
-
*
|
|
61
|
-
* @see {@link ServerHelmetProvider}
|
|
62
|
-
* @module alepha.server.helmet
|
|
63
|
-
*/
|
|
64
|
-
declare
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
58
|
+
* Automatically adds important HTTP security headers to every response
|
|
59
|
+
* to help protect your application from common web vulnerabilities.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link ServerHelmetProvider}
|
|
62
|
+
* @module alepha.server.helmet
|
|
63
|
+
*/
|
|
64
|
+
declare const AlephaServerHelmet: _alepha_core0.ModuleDescriptor;
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
66
|
+
|
|
68
67
|
//#endregion
|
|
69
68
|
export { AlephaServerHelmet, CspOptions, HelmetOptions, HstsOptions, ServerHelmetProvider };
|
|
70
69
|
//# sourceMappingURL=index.d.ts.map
|