@nowarajs/elysia-cache 1.3.2 โ 1.3.4
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/dist/cache.d.ts +11 -177
- package/package.json +1 -1
- package/AGENTS.md +0 -44
package/dist/cache.d.ts
CHANGED
|
@@ -1,183 +1,17 @@
|
|
|
1
1
|
import type { KvStore } from '@nowarajs/kv-store/types';
|
|
2
|
-
import { Elysia } from 'elysia';
|
|
2
|
+
import { Elysia, type DefinitionBase, type MetadataBase, type SingletonBase } from 'elysia';
|
|
3
3
|
import type { CacheOptions } from './types/cache-options';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
standaloneSchema: {};
|
|
4
|
+
/**
|
|
5
|
+
* Response caching plugin for Elysia applications.
|
|
6
|
+
*
|
|
7
|
+
* Caches responses per route with configurable TTL. Adds standard cache headers
|
|
8
|
+
* (`Cache-Control`, `ETag`, `Last-Modified`, `Expires`, `X-Cache`).
|
|
9
|
+
*
|
|
10
|
+
* @param store - KV store for caching. Defaults to in-memory.
|
|
11
|
+
* @returns Elysia plugin with `isCached` macro
|
|
12
|
+
*/
|
|
13
|
+
export declare const cache: (store?: KvStore) => Elysia<"", SingletonBase, DefinitionBase, MetadataBase & {
|
|
15
14
|
macro: Partial<{
|
|
16
15
|
readonly isCached: CacheOptions;
|
|
17
16
|
}>;
|
|
18
|
-
macroFn: {
|
|
19
|
-
readonly isCached: ({ ttl, prefix }: CacheOptions) => {
|
|
20
|
-
readonly afterHandle: ({ set, responseValue, request }: {
|
|
21
|
-
body: unknown;
|
|
22
|
-
query: Record<string, string>;
|
|
23
|
-
params: {};
|
|
24
|
-
headers: Record<string, string | undefined>;
|
|
25
|
-
cookie: Record<string, import("elysia").Cookie<unknown>>;
|
|
26
|
-
server: import("elysia/universal/server").Server | null;
|
|
27
|
-
redirect: import("elysia").redirect;
|
|
28
|
-
set: {
|
|
29
|
-
headers: import("elysia").HTTPHeaders;
|
|
30
|
-
status?: number | keyof import("elysia").StatusMap;
|
|
31
|
-
redirect?: string;
|
|
32
|
-
cookie?: Record<string, import("elysia/cookies").ElysiaCookie>;
|
|
33
|
-
};
|
|
34
|
-
path: string;
|
|
35
|
-
route: string;
|
|
36
|
-
request: Request;
|
|
37
|
-
store: {};
|
|
38
|
-
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
39
|
-
readonly 100: "Continue";
|
|
40
|
-
readonly 101: "Switching Protocols";
|
|
41
|
-
readonly 102: "Processing";
|
|
42
|
-
readonly 103: "Early Hints";
|
|
43
|
-
readonly 200: "OK";
|
|
44
|
-
readonly 201: "Created";
|
|
45
|
-
readonly 202: "Accepted";
|
|
46
|
-
readonly 203: "Non-Authoritative Information";
|
|
47
|
-
readonly 204: "No Content";
|
|
48
|
-
readonly 205: "Reset Content";
|
|
49
|
-
readonly 206: "Partial Content";
|
|
50
|
-
readonly 207: "Multi-Status";
|
|
51
|
-
readonly 208: "Already Reported";
|
|
52
|
-
readonly 300: "Multiple Choices";
|
|
53
|
-
readonly 301: "Moved Permanently";
|
|
54
|
-
readonly 302: "Found";
|
|
55
|
-
readonly 303: "See Other";
|
|
56
|
-
readonly 304: "Not Modified";
|
|
57
|
-
readonly 307: "Temporary Redirect";
|
|
58
|
-
readonly 308: "Permanent Redirect";
|
|
59
|
-
readonly 400: "Bad Request";
|
|
60
|
-
readonly 401: "Unauthorized";
|
|
61
|
-
readonly 402: "Payment Required";
|
|
62
|
-
readonly 403: "Forbidden";
|
|
63
|
-
readonly 404: "Not Found";
|
|
64
|
-
readonly 405: "Method Not Allowed";
|
|
65
|
-
readonly 406: "Not Acceptable";
|
|
66
|
-
readonly 407: "Proxy Authentication Required";
|
|
67
|
-
readonly 408: "Request Timeout";
|
|
68
|
-
readonly 409: "Conflict";
|
|
69
|
-
readonly 410: "Gone";
|
|
70
|
-
readonly 411: "Length Required";
|
|
71
|
-
readonly 412: "Precondition Failed";
|
|
72
|
-
readonly 413: "Payload Too Large";
|
|
73
|
-
readonly 414: "URI Too Long";
|
|
74
|
-
readonly 415: "Unsupported Media Type";
|
|
75
|
-
readonly 416: "Range Not Satisfiable";
|
|
76
|
-
readonly 417: "Expectation Failed";
|
|
77
|
-
readonly 418: "I'm a teapot";
|
|
78
|
-
readonly 420: "Enhance Your Calm";
|
|
79
|
-
readonly 421: "Misdirected Request";
|
|
80
|
-
readonly 422: "Unprocessable Content";
|
|
81
|
-
readonly 423: "Locked";
|
|
82
|
-
readonly 424: "Failed Dependency";
|
|
83
|
-
readonly 425: "Too Early";
|
|
84
|
-
readonly 426: "Upgrade Required";
|
|
85
|
-
readonly 428: "Precondition Required";
|
|
86
|
-
readonly 429: "Too Many Requests";
|
|
87
|
-
readonly 431: "Request Header Fields Too Large";
|
|
88
|
-
readonly 451: "Unavailable For Legal Reasons";
|
|
89
|
-
readonly 500: "Internal Server Error";
|
|
90
|
-
readonly 501: "Not Implemented";
|
|
91
|
-
readonly 502: "Bad Gateway";
|
|
92
|
-
readonly 503: "Service Unavailable";
|
|
93
|
-
readonly 504: "Gateway Timeout";
|
|
94
|
-
readonly 505: "HTTP Version Not Supported";
|
|
95
|
-
readonly 506: "Variant Also Negotiates";
|
|
96
|
-
readonly 507: "Insufficient Storage";
|
|
97
|
-
readonly 508: "Loop Detected";
|
|
98
|
-
readonly 510: "Not Extended";
|
|
99
|
-
readonly 511: "Network Authentication Required";
|
|
100
|
-
}[Code] : Code>(code: Code, response?: T) => import("elysia").ElysiaCustomStatusResponse<Code, T, Code extends "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? {
|
|
101
|
-
readonly Continue: 100;
|
|
102
|
-
readonly "Switching Protocols": 101;
|
|
103
|
-
readonly Processing: 102;
|
|
104
|
-
readonly "Early Hints": 103;
|
|
105
|
-
readonly OK: 200;
|
|
106
|
-
readonly Created: 201;
|
|
107
|
-
readonly Accepted: 202;
|
|
108
|
-
readonly "Non-Authoritative Information": 203;
|
|
109
|
-
readonly "No Content": 204;
|
|
110
|
-
readonly "Reset Content": 205;
|
|
111
|
-
readonly "Partial Content": 206;
|
|
112
|
-
readonly "Multi-Status": 207;
|
|
113
|
-
readonly "Already Reported": 208;
|
|
114
|
-
readonly "Multiple Choices": 300;
|
|
115
|
-
readonly "Moved Permanently": 301;
|
|
116
|
-
readonly Found: 302;
|
|
117
|
-
readonly "See Other": 303;
|
|
118
|
-
readonly "Not Modified": 304;
|
|
119
|
-
readonly "Temporary Redirect": 307;
|
|
120
|
-
readonly "Permanent Redirect": 308;
|
|
121
|
-
readonly "Bad Request": 400;
|
|
122
|
-
readonly Unauthorized: 401;
|
|
123
|
-
readonly "Payment Required": 402;
|
|
124
|
-
readonly Forbidden: 403;
|
|
125
|
-
readonly "Not Found": 404;
|
|
126
|
-
readonly "Method Not Allowed": 405;
|
|
127
|
-
readonly "Not Acceptable": 406;
|
|
128
|
-
readonly "Proxy Authentication Required": 407;
|
|
129
|
-
readonly "Request Timeout": 408;
|
|
130
|
-
readonly Conflict: 409;
|
|
131
|
-
readonly Gone: 410;
|
|
132
|
-
readonly "Length Required": 411;
|
|
133
|
-
readonly "Precondition Failed": 412;
|
|
134
|
-
readonly "Payload Too Large": 413;
|
|
135
|
-
readonly "URI Too Long": 414;
|
|
136
|
-
readonly "Unsupported Media Type": 415;
|
|
137
|
-
readonly "Range Not Satisfiable": 416;
|
|
138
|
-
readonly "Expectation Failed": 417;
|
|
139
|
-
readonly "I'm a teapot": 418;
|
|
140
|
-
readonly "Enhance Your Calm": 420;
|
|
141
|
-
readonly "Misdirected Request": 421;
|
|
142
|
-
readonly "Unprocessable Content": 422;
|
|
143
|
-
readonly Locked: 423;
|
|
144
|
-
readonly "Failed Dependency": 424;
|
|
145
|
-
readonly "Too Early": 425;
|
|
146
|
-
readonly "Upgrade Required": 426;
|
|
147
|
-
readonly "Precondition Required": 428;
|
|
148
|
-
readonly "Too Many Requests": 429;
|
|
149
|
-
readonly "Request Header Fields Too Large": 431;
|
|
150
|
-
readonly "Unavailable For Legal Reasons": 451;
|
|
151
|
-
readonly "Internal Server Error": 500;
|
|
152
|
-
readonly "Not Implemented": 501;
|
|
153
|
-
readonly "Bad Gateway": 502;
|
|
154
|
-
readonly "Service Unavailable": 503;
|
|
155
|
-
readonly "Gateway Timeout": 504;
|
|
156
|
-
readonly "HTTP Version Not Supported": 505;
|
|
157
|
-
readonly "Variant Also Negotiates": 506;
|
|
158
|
-
readonly "Insufficient Storage": 507;
|
|
159
|
-
readonly "Loop Detected": 508;
|
|
160
|
-
readonly "Not Extended": 510;
|
|
161
|
-
readonly "Network Authentication Required": 511;
|
|
162
|
-
}[Code] : Code>;
|
|
163
|
-
} & {
|
|
164
|
-
responseValue: unknown;
|
|
165
|
-
response: unknown;
|
|
166
|
-
}) => Promise<void>;
|
|
167
|
-
};
|
|
168
|
-
};
|
|
169
|
-
parser: {};
|
|
170
|
-
response: {};
|
|
171
|
-
}, {}, {
|
|
172
|
-
derive: {};
|
|
173
|
-
resolve: {};
|
|
174
|
-
schema: {};
|
|
175
|
-
standaloneSchema: {};
|
|
176
|
-
response: {};
|
|
177
|
-
}, {
|
|
178
|
-
derive: {};
|
|
179
|
-
resolve: {};
|
|
180
|
-
schema: {};
|
|
181
|
-
standaloneSchema: {};
|
|
182
|
-
response: {};
|
|
183
17
|
}>;
|
package/package.json
CHANGED
package/AGENTS.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Development_Workflow_and_Code_Standards
|
|
3
|
-
description: Guidelines for development workflow and code standards
|
|
4
|
-
applyTo: '**'
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## TypeScript and Project Conventions
|
|
8
|
-
1. Use underscore prefix for private or non-exported elements (e.g., _privateMethod)
|
|
9
|
-
2. Always specify visibility modifiers (private, protected, public), plus readonly, override, etc. when applicable
|
|
10
|
-
3. Naming conventions: camelCase for variables/functions/methods; PascalCase for classes/interfaces/types; SCREAMING_CASE for constants
|
|
11
|
-
4. Explicit typing: Always specify types for variables, parameters, and return values; never use any; prefer unknown if type cannot be determined; prefer interface over type alias for extendable objects
|
|
12
|
-
5. Documentation: Use TSDoc style; explain purpose, parameters, return values, and behavior; only document code when requested; for @throws, use format "@throws ({@link Type}) โ description"; for object/interface properties, write comment above each property instead of @param
|
|
13
|
-
6. Control structures: Omit curly braces for single-statement bodies
|
|
14
|
-
7. Path Aliases: Use $ for internal imports; do not import barrel files except as entry points
|
|
15
|
-
8. Export Pattern: Each directory has index.ts re-exporting public items; types exported in types/index.ts
|
|
16
|
-
9. Function style: Class methods use standard method syntax; helpers/callbacks/HOFs prefer arrow functions unless function syntax is required
|
|
17
|
-
|
|
18
|
-
## Contribution Principles
|
|
19
|
-
1. Follow TypeScript best practices and idiomatic patterns
|
|
20
|
-
2. Maintain existing code structure and modular organization
|
|
21
|
-
3. Keep developer experience in mind
|
|
22
|
-
4. Keep pull requests focused and well-documented (with TsDoc if asked)
|
|
23
|
-
5. Commit different types of changes separately; avoid mixing tests and features in one commit
|
|
24
|
-
|
|
25
|
-
## Commit Message Convention (Conventional Commits + Emoji)
|
|
26
|
-
Format: <type>(<emoji>): [summary up to 72 chars]
|
|
27
|
-
(blank line, then context or description)
|
|
28
|
-
|
|
29
|
-
<type> is lowercase
|
|
30
|
-
summary is surrounded by brackets `[summary]`
|
|
31
|
-
|
|
32
|
-
Types:
|
|
33
|
-
feat(๐) โ New features
|
|
34
|
-
fix(๐ง) โ Bug fixes
|
|
35
|
-
perf(โก) โ Performance improvements
|
|
36
|
-
refactor(๐งน) โ Refactoring
|
|
37
|
-
build(๐ฆ) โ Build tools / dependency changes
|
|
38
|
-
types(๐) โ Type definitions
|
|
39
|
-
chore(๐ฆ) โ Maintenance, non-code/test changes
|
|
40
|
-
examples(๐) โ Example updates
|
|
41
|
-
docs(๐) โ Documentation changes
|
|
42
|
-
test(๐งช) โ Test code updates
|
|
43
|
-
style(๐จ) โ Style/formatting only
|
|
44
|
-
ci(๐ค) โ CI/CD configuration
|