alepha 0.7.2 → 0.7.3
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/package.json +26 -26
- package/scheduler.d.ts +2 -2
- package/server/{metrics.cjs → cache.cjs} +3 -3
- package/server/cache.d.ts +51 -0
- package/server/cache.js +1 -0
- package/server.d.ts +3 -20
- package/src/server/cache.ts +1 -0
- package/vite.d.ts +13 -19
- package/server/metrics.d.ts +0 -14
- package/server/metrics.js +0 -1
- package/src/server/metrics.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alepha",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "TypeScript framework for building full-stack apps with strict conventions, custom schemas, and React-based SPA or SSR without filesystem-based routing.",
|
|
@@ -12,26 +12,26 @@
|
|
|
12
12
|
"main": "./core.js",
|
|
13
13
|
"types": "./core.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@alepha/cache": "0.7.
|
|
16
|
-
"@alepha/core": "0.7.
|
|
17
|
-
"@alepha/datetime": "0.7.
|
|
18
|
-
"@alepha/lock": "0.7.
|
|
19
|
-
"@alepha/postgres": "0.7.
|
|
20
|
-
"@alepha/queue": "0.7.
|
|
21
|
-
"@alepha/react": "0.7.
|
|
22
|
-
"@alepha/react-auth": "0.7.
|
|
23
|
-
"@alepha/redis": "0.7.
|
|
24
|
-
"@alepha/retry": "0.7.
|
|
25
|
-
"@alepha/scheduler": "0.7.
|
|
26
|
-
"@alepha/security": "0.7.
|
|
27
|
-
"@alepha/server": "0.7.
|
|
28
|
-
"@alepha/server-
|
|
29
|
-
"@alepha/server-
|
|
30
|
-
"@alepha/server-static": "0.7.
|
|
31
|
-
"@alepha/server-swagger": "0.7.
|
|
32
|
-
"@alepha/testing": "0.7.
|
|
33
|
-
"@alepha/topic": "0.7.
|
|
34
|
-
"@alepha/vite": "0.7.
|
|
15
|
+
"@alepha/cache": "0.7.3",
|
|
16
|
+
"@alepha/core": "0.7.3",
|
|
17
|
+
"@alepha/datetime": "0.7.3",
|
|
18
|
+
"@alepha/lock": "0.7.3",
|
|
19
|
+
"@alepha/postgres": "0.7.3",
|
|
20
|
+
"@alepha/queue": "0.7.3",
|
|
21
|
+
"@alepha/react": "0.7.3",
|
|
22
|
+
"@alepha/react-auth": "0.7.3",
|
|
23
|
+
"@alepha/redis": "0.7.3",
|
|
24
|
+
"@alepha/retry": "0.7.3",
|
|
25
|
+
"@alepha/scheduler": "0.7.3",
|
|
26
|
+
"@alepha/security": "0.7.3",
|
|
27
|
+
"@alepha/server": "0.7.3",
|
|
28
|
+
"@alepha/server-cache": "0.7.3",
|
|
29
|
+
"@alepha/server-cookies": "0.7.3",
|
|
30
|
+
"@alepha/server-static": "0.7.3",
|
|
31
|
+
"@alepha/server-swagger": "0.7.3",
|
|
32
|
+
"@alepha/testing": "0.7.3",
|
|
33
|
+
"@alepha/topic": "0.7.3",
|
|
34
|
+
"@alepha/vite": "0.7.3"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@types/react": "^19",
|
|
@@ -141,11 +141,6 @@
|
|
|
141
141
|
"require": "./server/cookies.cjs",
|
|
142
142
|
"types": "./server/cookies.d.ts"
|
|
143
143
|
},
|
|
144
|
-
"./server/metrics": {
|
|
145
|
-
"import": "./server/metrics.js",
|
|
146
|
-
"require": "./server/metrics.cjs",
|
|
147
|
-
"types": "./server/metrics.d.ts"
|
|
148
|
-
},
|
|
149
144
|
"./server/static": {
|
|
150
145
|
"import": "./server/static.js",
|
|
151
146
|
"require": "./server/static.cjs",
|
|
@@ -156,6 +151,11 @@
|
|
|
156
151
|
"require": "./server/swagger.cjs",
|
|
157
152
|
"types": "./server/swagger.d.ts"
|
|
158
153
|
},
|
|
154
|
+
"./server/cache": {
|
|
155
|
+
"import": "./server/cache.js",
|
|
156
|
+
"require": "./server/cache.cjs",
|
|
157
|
+
"types": "./server/cache.d.ts"
|
|
158
|
+
},
|
|
159
159
|
"./topic": {
|
|
160
160
|
"import": "./topic.js",
|
|
161
161
|
"require": "./topic.cjs",
|
package/scheduler.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as _alepha_core from '@alepha/core';
|
|
|
2
2
|
import { Async, KIND, OPTIONS, Static, Alepha } from '@alepha/core';
|
|
3
3
|
import { DurationLike, DateTimeProvider, Interval } from '@alepha/datetime';
|
|
4
4
|
import * as _alepha_lock from '@alepha/lock';
|
|
5
|
-
import {
|
|
5
|
+
import { ScheduledTask } from 'node-cron';
|
|
6
6
|
|
|
7
7
|
declare const KEY = "SCHEDULER";
|
|
8
8
|
type SchedulerDescriptorOptions = {
|
|
@@ -173,7 +173,7 @@ interface Scheduler {
|
|
|
173
173
|
name: string;
|
|
174
174
|
options: SchedulerDescriptorOptions;
|
|
175
175
|
trigger: () => Promise<void>;
|
|
176
|
-
|
|
176
|
+
cron?: ScheduledTask;
|
|
177
177
|
interval?: Interval;
|
|
178
178
|
}
|
|
179
179
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var serverCache = require('@alepha/server-cache');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
Object.keys(
|
|
7
|
+
Object.keys(serverCache).forEach(function (k) {
|
|
8
8
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return serverCache[k]; }
|
|
11
11
|
});
|
|
12
12
|
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as _alepha_core from '@alepha/core';
|
|
2
|
+
import { Alepha, OPTIONS } from '@alepha/core';
|
|
3
|
+
import { CacheDescriptorOptions, CacheDescriptorProvider, Cache } from '@alepha/cache';
|
|
4
|
+
import { DurationLike, DateTimeProvider } from '@alepha/datetime';
|
|
5
|
+
import { ServerHandler, ServerRequestConfig } from '@alepha/server';
|
|
6
|
+
|
|
7
|
+
declare module "alepha/server" {
|
|
8
|
+
interface ServerRoute {
|
|
9
|
+
cache?: ServiceRouteCache;
|
|
10
|
+
}
|
|
11
|
+
interface ActionDescriptor {
|
|
12
|
+
invalidate: () => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
declare class ServerCacheProvider {
|
|
16
|
+
protected readonly log: _alepha_core.Logger;
|
|
17
|
+
protected readonly alepha: Alepha;
|
|
18
|
+
protected readonly cacheProvider: CacheDescriptorProvider;
|
|
19
|
+
protected readonly time: DateTimeProvider;
|
|
20
|
+
protected readonly caches: Map<ServerHandler, RouteCache>;
|
|
21
|
+
readonly onConfigure: _alepha_core.HookDescriptor<"configure">;
|
|
22
|
+
readonly onRoute: _alepha_core.HookDescriptor<"server:onRoute">;
|
|
23
|
+
readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
|
|
24
|
+
readonly onSend: _alepha_core.HookDescriptor<"server:onResponse">;
|
|
25
|
+
generateETag(content: string): string;
|
|
26
|
+
invalidate(route: RouteLike): Promise<void>;
|
|
27
|
+
protected getCacheByRoute(route: RouteLike): RouteCache | undefined;
|
|
28
|
+
protected createCacheKey(args: ServerRequestConfig): string;
|
|
29
|
+
}
|
|
30
|
+
type ServiceRouteCache = boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
|
|
31
|
+
type RouteCache = Cache<{
|
|
32
|
+
contentType?: string;
|
|
33
|
+
body: string;
|
|
34
|
+
status?: number;
|
|
35
|
+
lastModified: string;
|
|
36
|
+
hash: string;
|
|
37
|
+
}>;
|
|
38
|
+
type RouteLike = {
|
|
39
|
+
[OPTIONS]: {
|
|
40
|
+
handler?: ServerHandler;
|
|
41
|
+
};
|
|
42
|
+
} | {
|
|
43
|
+
handler?: ServerHandler;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
declare class ServerCacheModule {
|
|
47
|
+
protected readonly alepha: Alepha;
|
|
48
|
+
constructor();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { ServerCacheModule, ServerCacheProvider, type ServiceRouteCache };
|
package/server/cache.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/server-cache';
|
package/server.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as _alepha_core from '@alepha/core';
|
|
2
2
|
import { Static as Static$1, TObject as TObject$1, TSchema as TSchema$2, Async, StreamLike, Alepha, FileLike, OPTIONS, KIND, Service } from '@alepha/core';
|
|
3
3
|
export { KIND } from '@alepha/core';
|
|
4
|
-
import * as _alepha_cache from '@alepha/cache';
|
|
5
|
-
import { CacheDescriptorOptions } from '@alepha/cache';
|
|
6
|
-
import { DurationLike, DateTimeProvider } from '@alepha/datetime';
|
|
7
4
|
import { UserAccountToken, Permission, ServiceAccountDescriptor as ServiceAccountDescriptor$1, SecurityProvider, JwtProvider } from '@alepha/security';
|
|
8
5
|
import { IncomingMessage, ServerResponse as ServerResponse$1 } from 'node:http';
|
|
9
6
|
import { Readable } from 'node:stream';
|
|
10
7
|
import { ReadableStream } from 'node:stream/web';
|
|
11
8
|
import { Route, RouterProvider } from '@alepha/router';
|
|
9
|
+
import * as _alepha_cache from '@alepha/cache';
|
|
10
|
+
import { DurationLike, DateTimeProvider } from '@alepha/datetime';
|
|
12
11
|
import * as _alepha_retry from '@alepha/retry';
|
|
13
12
|
import { BusboyConfig } from '@fastify/busboy';
|
|
14
13
|
import * as http from 'http';
|
|
@@ -210,8 +209,6 @@ interface TSchema$1 extends TKind$1, SchemaOptions$1 {
|
|
|
210
209
|
declare const routeMethods: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE"];
|
|
211
210
|
type RouteMethod = (typeof routeMethods)[number];
|
|
212
211
|
|
|
213
|
-
type ServiceRouteCache = boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
|
|
214
|
-
|
|
215
212
|
declare const envSchema$4: TObject$1<{
|
|
216
213
|
SERVER_ALS_ENABLED: TBoolean;
|
|
217
214
|
}>;
|
|
@@ -289,10 +286,6 @@ interface ServerRoute<TConfig extends RequestConfigSchema = RequestConfigSchema>
|
|
|
289
286
|
* @see ServerSecurityProvider
|
|
290
287
|
*/
|
|
291
288
|
secure?: ServerRouteSecure;
|
|
292
|
-
/**
|
|
293
|
-
* @see ServerCacheProvider
|
|
294
|
-
*/
|
|
295
|
-
cache?: ServiceRouteCache;
|
|
296
289
|
}
|
|
297
290
|
type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends TSchema$2 ? Static$1<TConfig["response"]> : ResponseBodyType;
|
|
298
291
|
type ResponseType = "json" | "text" | "void" | "file" | "any";
|
|
@@ -537,11 +530,6 @@ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema = RequestC
|
|
|
537
530
|
* Main route handler. This is where the route logic is implemented.
|
|
538
531
|
*/
|
|
539
532
|
handler?: ServerHandler<TConfig>;
|
|
540
|
-
/**
|
|
541
|
-
* If true, the route will be cached.
|
|
542
|
-
* - Number as seconds or boolean to enable cache.
|
|
543
|
-
*/
|
|
544
|
-
cache?: boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
|
|
545
533
|
}
|
|
546
534
|
interface ActionDescriptor<TConfig extends RequestConfigSchema = RequestConfigSchema> {
|
|
547
535
|
[KIND]: typeof KEY$2;
|
|
@@ -558,11 +546,6 @@ interface ActionDescriptor<TConfig extends RequestConfigSchema = RequestConfigSc
|
|
|
558
546
|
* Name of the permission required to access this route.
|
|
559
547
|
*/
|
|
560
548
|
permission: () => string;
|
|
561
|
-
/**
|
|
562
|
-
* Invalidate the cache for this action.
|
|
563
|
-
* This is only available if the action has cache enabled.
|
|
564
|
-
*/
|
|
565
|
-
invalidate: () => Promise<void>;
|
|
566
549
|
}
|
|
567
550
|
declare const $action: {
|
|
568
551
|
<TConfig extends RequestConfigSchema>(options: ActionDescriptorOptions<TConfig>): ActionDescriptor<TConfig>;
|
|
@@ -982,8 +965,8 @@ declare class RemoteDescriptorProvider {
|
|
|
982
965
|
}) => Promise<{
|
|
983
966
|
prefix?: string | undefined;
|
|
984
967
|
links: {
|
|
985
|
-
group?: string | undefined;
|
|
986
968
|
method?: string | undefined;
|
|
969
|
+
group?: string | undefined;
|
|
987
970
|
requestBodyType?: string | undefined;
|
|
988
971
|
service?: string | undefined;
|
|
989
972
|
path: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@alepha/server-cache";
|
package/vite.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { Alepha } from '@alepha/core';
|
|
2
|
-
import {
|
|
2
|
+
import { Plugin } from 'vite';
|
|
3
3
|
import { BrotliOptions, ZlibOptions } from 'node:zlib';
|
|
4
4
|
|
|
5
5
|
interface ViteAlephaBuildOptions {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @default 'src/index.server.ts'
|
|
7
|
+
* Path to the entry file for the server build.
|
|
8
|
+
* If empty, SSR build will be skipped.
|
|
10
9
|
*/
|
|
11
|
-
|
|
10
|
+
serverEntry?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Set false to skip the client build.
|
|
13
|
+
* This is useful if you only want to build the server-side application.
|
|
14
|
+
*/
|
|
15
|
+
client?: false;
|
|
12
16
|
/**
|
|
13
17
|
* If true, the build will be optimized for Vercel deployment.
|
|
14
18
|
*
|
|
@@ -17,25 +21,15 @@ interface ViteAlephaBuildOptions {
|
|
|
17
21
|
* @default false
|
|
18
22
|
*/
|
|
19
23
|
vercel?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Vite server options to override the default server configuration.
|
|
22
|
-
*/
|
|
23
|
-
server?: false | UserConfig;
|
|
24
|
-
client?: false;
|
|
25
|
-
/**
|
|
26
|
-
* If true, all compatible pages will be pre-rendered.
|
|
27
|
-
*/
|
|
28
|
-
prerender?: boolean;
|
|
29
24
|
}
|
|
30
25
|
declare function viteAlephaBuild(options?: ViteAlephaBuildOptions): Promise<Plugin>;
|
|
31
26
|
|
|
32
27
|
interface ViteAlephaDevOptions {
|
|
33
28
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @default 'src/index.server.ts'
|
|
29
|
+
* Path to the entry file for the server build.
|
|
30
|
+
* If empty, plugin will be disabled.
|
|
37
31
|
*/
|
|
38
|
-
|
|
32
|
+
serverEntry?: string;
|
|
39
33
|
/**
|
|
40
34
|
* Enable or disable debug mode
|
|
41
35
|
*
|
|
@@ -44,7 +38,7 @@ interface ViteAlephaDevOptions {
|
|
|
44
38
|
debug?: boolean;
|
|
45
39
|
}
|
|
46
40
|
/**
|
|
47
|
-
*
|
|
41
|
+
* Plug Alepha into Vite development server.
|
|
48
42
|
*/
|
|
49
43
|
declare function viteAlephaDev(options?: ViteAlephaDevOptions): Promise<Plugin>;
|
|
50
44
|
|
package/server/metrics.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as _alepha_server from '@alepha/server';
|
|
2
|
-
|
|
3
|
-
declare class ServerMetricsProvider {
|
|
4
|
-
private readonly register;
|
|
5
|
-
private cpuUsage;
|
|
6
|
-
private memoryUsage;
|
|
7
|
-
private gcDuration;
|
|
8
|
-
private heapUsage;
|
|
9
|
-
readonly metrics: _alepha_server.ActionDescriptor<_alepha_server.RequestConfigSchema>;
|
|
10
|
-
constructor();
|
|
11
|
-
private collectMetrics;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { ServerMetricsProvider };
|
package/server/metrics.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@alepha/server-metrics';
|
package/src/server/metrics.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@alepha/server-metrics";
|