@heinhtet37/express-route-cache 0.1.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/LICENSE +21 -0
- package/README.md +130 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +225 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# @mvs/express-route-cache
|
|
2
|
+
|
|
3
|
+
Reusable Express middleware factories for route-level response caching and cache invalidation.
|
|
4
|
+
|
|
5
|
+
This package is intended to be published independently from this repo. You can:
|
|
6
|
+
|
|
7
|
+
1. `cd express-route-cache`
|
|
8
|
+
2. `npm install`
|
|
9
|
+
3. `npm publish`
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @mvs/express-route-cache
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## What it provides
|
|
18
|
+
|
|
19
|
+
- `createRouteCache()` to create middleware factories
|
|
20
|
+
- `createRedisStore()` for Redis-backed caching
|
|
21
|
+
- `createMemoryStore()` for local development and tests
|
|
22
|
+
|
|
23
|
+
## Basic usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createRedisStore, createRouteCache } from "@mvs/express-route-cache";
|
|
27
|
+
import redis from "./redis";
|
|
28
|
+
|
|
29
|
+
const cache = createRouteCache({
|
|
30
|
+
store: createRedisStore({
|
|
31
|
+
client: redis,
|
|
32
|
+
defaultTtlSeconds: 300,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const checkUsersCache = cache.check({
|
|
37
|
+
varyHeaders: ["accept-language"],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const setUsersCache = cache.capture();
|
|
41
|
+
|
|
42
|
+
export const invalidateUsersCache = cache.invalidate({
|
|
43
|
+
patterns: (req) => [
|
|
44
|
+
"/api/users",
|
|
45
|
+
"/api/users?*",
|
|
46
|
+
`/api/users/${req.params.id}*`,
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Then use it in your routes:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
router.get(
|
|
55
|
+
"/users",
|
|
56
|
+
checkUsersCache,
|
|
57
|
+
setUsersCache,
|
|
58
|
+
async (req, res) => {
|
|
59
|
+
res.json(await userService.getAll());
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
router.patch(
|
|
64
|
+
"/users/:id",
|
|
65
|
+
invalidateUsersCache,
|
|
66
|
+
async (req, res) => {
|
|
67
|
+
res.json(await userService.update(req.params.id, req.body));
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## API
|
|
73
|
+
|
|
74
|
+
### `createRouteCache({ store, logger, defaultTtlSeconds })`
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
|
|
78
|
+
- `check(options)`
|
|
79
|
+
- `capture(options)`
|
|
80
|
+
- `invalidate(options)`
|
|
81
|
+
- `get(key)`
|
|
82
|
+
- `set(key, value, ttlSeconds?)`
|
|
83
|
+
- `deleteByPatterns(patterns)`
|
|
84
|
+
|
|
85
|
+
### `check(options)`
|
|
86
|
+
|
|
87
|
+
Options:
|
|
88
|
+
|
|
89
|
+
- `key`: custom cache key or `(req) => string`
|
|
90
|
+
- `varyHeaders`: append selected request headers into the cache key
|
|
91
|
+
- `shouldBypass`: skip lookup for selected requests
|
|
92
|
+
- `hitHeader`: response header name for cache hit or miss, defaults to `x-cache`
|
|
93
|
+
|
|
94
|
+
### `capture(options)`
|
|
95
|
+
|
|
96
|
+
Options:
|
|
97
|
+
|
|
98
|
+
- `ttlSeconds`: number or `(req, res, body) => number | undefined`
|
|
99
|
+
- `shouldCache`: predicate to decide whether a response body should be cached
|
|
100
|
+
|
|
101
|
+
### `invalidate(options)`
|
|
102
|
+
|
|
103
|
+
Options:
|
|
104
|
+
|
|
105
|
+
- `patterns`: array or `(req, res, body) => string[]`
|
|
106
|
+
- `shouldInvalidate`: predicate to control invalidation
|
|
107
|
+
- `onInvalidate`: async hook for audit logging or side effects
|
|
108
|
+
|
|
109
|
+
### `createRedisStore({ client, defaultTtlSeconds, logger, scanCount })`
|
|
110
|
+
|
|
111
|
+
The Redis client should expose:
|
|
112
|
+
|
|
113
|
+
- `get`
|
|
114
|
+
- `del`
|
|
115
|
+
- one of `scan` or `keys`
|
|
116
|
+
- one of `setex` or `set(..., "EX", ttl)`
|
|
117
|
+
|
|
118
|
+
### `createMemoryStore({ defaultTtlSeconds })`
|
|
119
|
+
|
|
120
|
+
Simple in-memory cache store for testing or local usage.
|
|
121
|
+
|
|
122
|
+
## Publish
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
cd express-route-cache
|
|
126
|
+
npm install
|
|
127
|
+
npm publish
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Because `publishConfig.access` is already set to `public`, npm will publish it as a public package.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Request, RequestHandler, Response } from "express";
|
|
2
|
+
export interface CacheStore {
|
|
3
|
+
get<T>(key: string): Promise<T | null>;
|
|
4
|
+
set<T>(key: string, value: T, options?: {
|
|
5
|
+
ttlSeconds?: number;
|
|
6
|
+
}): Promise<void>;
|
|
7
|
+
deleteByPatterns(patterns: string[]): Promise<number | void>;
|
|
8
|
+
}
|
|
9
|
+
export interface CacheLogger {
|
|
10
|
+
error?(message: string, meta?: unknown): void;
|
|
11
|
+
warn?(message: string, meta?: unknown): void;
|
|
12
|
+
info?(message: string, meta?: unknown): void;
|
|
13
|
+
}
|
|
14
|
+
type ValueResolver<T> = T | ((req: Request, res: Response, body?: unknown) => T);
|
|
15
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
16
|
+
export interface CacheCheckOptions {
|
|
17
|
+
key?: string | ((req: Request) => string);
|
|
18
|
+
varyHeaders?: string[];
|
|
19
|
+
shouldBypass?: (req: Request) => boolean;
|
|
20
|
+
hitHeader?: string | false;
|
|
21
|
+
}
|
|
22
|
+
export interface CacheCaptureOptions {
|
|
23
|
+
ttlSeconds?: ValueResolver<number | undefined>;
|
|
24
|
+
shouldCache?: (req: Request, res: Response, body: unknown) => boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface CacheInvalidateOptions {
|
|
27
|
+
patterns: string[] | ((req: Request, res: Response, body: unknown) => string[]);
|
|
28
|
+
shouldInvalidate?: (req: Request, res: Response, body: unknown) => boolean;
|
|
29
|
+
onInvalidate?: (req: Request, res: Response, body: unknown, patterns: string[]) => MaybePromise<void>;
|
|
30
|
+
}
|
|
31
|
+
export interface CreateRouteCacheOptions {
|
|
32
|
+
store: CacheStore;
|
|
33
|
+
logger?: CacheLogger;
|
|
34
|
+
defaultTtlSeconds?: number;
|
|
35
|
+
}
|
|
36
|
+
export declare function createRouteCache(options: CreateRouteCacheOptions): {
|
|
37
|
+
check(checkOptions?: CacheCheckOptions): RequestHandler;
|
|
38
|
+
capture(captureOptions?: CacheCaptureOptions): RequestHandler;
|
|
39
|
+
invalidate(invalidateOptions: CacheInvalidateOptions): RequestHandler;
|
|
40
|
+
get<T>(key: string): Promise<T | null>;
|
|
41
|
+
set<T>(key: string, value: T, ttlSeconds?: number | undefined): Promise<void>;
|
|
42
|
+
deleteByPatterns(patterns: string[]): Promise<void>;
|
|
43
|
+
};
|
|
44
|
+
export interface RedisLikeClient {
|
|
45
|
+
get(key: string): Promise<string | null>;
|
|
46
|
+
setex?(key: string, ttlSeconds: number, value: string): Promise<unknown>;
|
|
47
|
+
set?(key: string, value: string, mode: "EX", ttlSeconds: number): Promise<unknown>;
|
|
48
|
+
keys?(pattern: string): Promise<string[]>;
|
|
49
|
+
scan?(cursor: string, tokenOne: "MATCH", pattern: string, tokenTwo: "COUNT", count: number): Promise<[string, string[]]>;
|
|
50
|
+
del(...keys: string[]): Promise<number>;
|
|
51
|
+
}
|
|
52
|
+
export interface CreateRedisStoreOptions {
|
|
53
|
+
client: RedisLikeClient;
|
|
54
|
+
defaultTtlSeconds?: number;
|
|
55
|
+
logger?: CacheLogger;
|
|
56
|
+
scanCount?: number;
|
|
57
|
+
deserialize?: <T>(value: string) => T;
|
|
58
|
+
serialize?: (value: unknown) => string;
|
|
59
|
+
}
|
|
60
|
+
export declare function createRedisStore(options: CreateRedisStoreOptions): CacheStore;
|
|
61
|
+
export interface CreateMemoryStoreOptions {
|
|
62
|
+
defaultTtlSeconds?: number;
|
|
63
|
+
}
|
|
64
|
+
export declare function createMemoryStore(options?: CreateMemoryStoreOptions): CacheStore;
|
|
65
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRouteCache = createRouteCache;
|
|
4
|
+
exports.createRedisStore = createRedisStore;
|
|
5
|
+
exports.createMemoryStore = createMemoryStore;
|
|
6
|
+
const ROUTE_CACHE_CONTEXT_KEY = "__routeCache";
|
|
7
|
+
function getCacheContext(res) {
|
|
8
|
+
return res.locals?.[ROUTE_CACHE_CONTEXT_KEY];
|
|
9
|
+
}
|
|
10
|
+
function setCacheContext(res, context) {
|
|
11
|
+
res.locals[ROUTE_CACHE_CONTEXT_KEY] = context;
|
|
12
|
+
}
|
|
13
|
+
function normalizeHeaderValue(value) {
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
return value.join(",");
|
|
16
|
+
}
|
|
17
|
+
return value ?? "";
|
|
18
|
+
}
|
|
19
|
+
function escapeForRegex(input) {
|
|
20
|
+
return input.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
|
|
21
|
+
}
|
|
22
|
+
function wildcardToRegExp(pattern) {
|
|
23
|
+
return new RegExp("^" + pattern.split("*").map(escapeForRegex).join(".*") + "$");
|
|
24
|
+
}
|
|
25
|
+
function buildCacheKey(req, varyHeaders = []) {
|
|
26
|
+
const suffix = varyHeaders
|
|
27
|
+
.map((headerName) => {
|
|
28
|
+
const normalized = headerName.toLowerCase();
|
|
29
|
+
const headerValue = normalizeHeaderValue(req.headers[normalized]);
|
|
30
|
+
return `${normalized}=${headerValue}`;
|
|
31
|
+
})
|
|
32
|
+
.filter((entry) => !entry.endsWith("="))
|
|
33
|
+
.join("&");
|
|
34
|
+
if (!suffix) {
|
|
35
|
+
return req.originalUrl;
|
|
36
|
+
}
|
|
37
|
+
const separator = req.originalUrl.includes("?") ? "&" : "?";
|
|
38
|
+
return `${req.originalUrl}${separator}${suffix}`;
|
|
39
|
+
}
|
|
40
|
+
function isSuccessfulStatus(statusCode) {
|
|
41
|
+
return statusCode >= 200 && statusCode < 300;
|
|
42
|
+
}
|
|
43
|
+
async function deletePatterns(store, patterns, logger) {
|
|
44
|
+
if (patterns.length === 0) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
await store.deleteByPatterns(patterns);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
logger?.error?.("Failed to invalidate cache patterns", error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function createRouteCache(options) {
|
|
55
|
+
const { defaultTtlSeconds, logger, store } = options;
|
|
56
|
+
return {
|
|
57
|
+
check(checkOptions = {}) {
|
|
58
|
+
const { hitHeader = "x-cache", key, shouldBypass, varyHeaders = [], } = checkOptions;
|
|
59
|
+
return async (req, res, next) => {
|
|
60
|
+
if (shouldBypass?.(req)) {
|
|
61
|
+
return next();
|
|
62
|
+
}
|
|
63
|
+
const cacheKey = typeof key === "function"
|
|
64
|
+
? key(req)
|
|
65
|
+
: key ?? buildCacheKey(req, varyHeaders);
|
|
66
|
+
setCacheContext(res, { key: cacheKey });
|
|
67
|
+
try {
|
|
68
|
+
const cachedBody = await store.get(cacheKey);
|
|
69
|
+
if (cachedBody !== null) {
|
|
70
|
+
if (hitHeader) {
|
|
71
|
+
res.setHeader(hitHeader, "HIT");
|
|
72
|
+
}
|
|
73
|
+
res.json(cachedBody);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (hitHeader) {
|
|
77
|
+
res.setHeader(hitHeader, "MISS");
|
|
78
|
+
}
|
|
79
|
+
next();
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
logger?.error?.("Failed to read from cache store", error);
|
|
83
|
+
next();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
capture(captureOptions = {}) {
|
|
88
|
+
const { shouldCache, ttlSeconds } = captureOptions;
|
|
89
|
+
return (req, res, next) => {
|
|
90
|
+
const originalJson = res.json.bind(res);
|
|
91
|
+
res.json = ((body) => {
|
|
92
|
+
const context = getCacheContext(res);
|
|
93
|
+
if (context &&
|
|
94
|
+
isSuccessfulStatus(res.statusCode) &&
|
|
95
|
+
(shouldCache?.(req, res, body) ?? true)) {
|
|
96
|
+
const resolvedTtl = typeof ttlSeconds === "function"
|
|
97
|
+
? ttlSeconds(req, res, body)
|
|
98
|
+
: ttlSeconds ?? defaultTtlSeconds;
|
|
99
|
+
store
|
|
100
|
+
.set(context.key, body, {
|
|
101
|
+
ttlSeconds: resolvedTtl,
|
|
102
|
+
})
|
|
103
|
+
.catch((error) => logger?.error?.("Failed to write response into cache store", error));
|
|
104
|
+
}
|
|
105
|
+
return originalJson(body);
|
|
106
|
+
});
|
|
107
|
+
next();
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
invalidate(invalidateOptions) {
|
|
111
|
+
const { onInvalidate, patterns, shouldInvalidate } = invalidateOptions;
|
|
112
|
+
return (req, res, next) => {
|
|
113
|
+
const originalJson = res.json.bind(res);
|
|
114
|
+
res.json = ((body) => {
|
|
115
|
+
const resolvedPatterns = typeof patterns === "function"
|
|
116
|
+
? patterns(req, res, body)
|
|
117
|
+
: patterns;
|
|
118
|
+
if (isSuccessfulStatus(res.statusCode) &&
|
|
119
|
+
(shouldInvalidate?.(req, res, body) ?? true)) {
|
|
120
|
+
Promise.resolve(onInvalidate?.(req, res, body, resolvedPatterns))
|
|
121
|
+
.then(() => deletePatterns(store, resolvedPatterns, logger))
|
|
122
|
+
.catch((error) => logger?.error?.("Failed while running cache invalidation hook", error));
|
|
123
|
+
}
|
|
124
|
+
return originalJson(body);
|
|
125
|
+
});
|
|
126
|
+
next();
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
async get(key) {
|
|
130
|
+
return store.get(key);
|
|
131
|
+
},
|
|
132
|
+
async set(key, value, ttlSeconds = defaultTtlSeconds) {
|
|
133
|
+
await store.set(key, value, { ttlSeconds });
|
|
134
|
+
},
|
|
135
|
+
async deleteByPatterns(patterns) {
|
|
136
|
+
await deletePatterns(store, patterns, logger);
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
async function collectKeysForPattern(client, pattern, scanCount) {
|
|
141
|
+
if (client.scan) {
|
|
142
|
+
let cursor = "0";
|
|
143
|
+
const matchedKeys = new Set();
|
|
144
|
+
do {
|
|
145
|
+
const [nextCursor, keys] = await client.scan(cursor, "MATCH", pattern, "COUNT", scanCount);
|
|
146
|
+
cursor = nextCursor;
|
|
147
|
+
keys.forEach((key) => matchedKeys.add(key));
|
|
148
|
+
} while (cursor !== "0");
|
|
149
|
+
return [...matchedKeys];
|
|
150
|
+
}
|
|
151
|
+
if (client.keys) {
|
|
152
|
+
return client.keys(pattern);
|
|
153
|
+
}
|
|
154
|
+
throw new Error("Redis client must provide either scan() or keys() for pattern invalidation.");
|
|
155
|
+
}
|
|
156
|
+
function createRedisStore(options) {
|
|
157
|
+
const { client, defaultTtlSeconds = 60, deserialize = JSON.parse, logger, scanCount = 200, serialize = JSON.stringify, } = options;
|
|
158
|
+
return {
|
|
159
|
+
async get(key) {
|
|
160
|
+
const rawValue = await client.get(key);
|
|
161
|
+
return rawValue ? deserialize(rawValue) : null;
|
|
162
|
+
},
|
|
163
|
+
async set(key, value, setOptions) {
|
|
164
|
+
const ttlSeconds = setOptions?.ttlSeconds ?? defaultTtlSeconds;
|
|
165
|
+
const payload = serialize(value);
|
|
166
|
+
if (client.setex) {
|
|
167
|
+
await client.setex(key, ttlSeconds, payload);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (client.set) {
|
|
171
|
+
await client.set(key, payload, "EX", ttlSeconds);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
throw new Error("Redis client must provide either setex() or set(..., 'EX', ttl).");
|
|
175
|
+
},
|
|
176
|
+
async deleteByPatterns(patterns) {
|
|
177
|
+
const matchedKeys = await Promise.all(patterns.map((pattern) => collectKeysForPattern(client, pattern, scanCount)));
|
|
178
|
+
const uniqueKeys = [...new Set(matchedKeys.flat())];
|
|
179
|
+
if (uniqueKeys.length === 0) {
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
const deletedCount = await client.del(...uniqueKeys);
|
|
183
|
+
logger?.info?.("Deleted cache keys", {
|
|
184
|
+
deletedCount,
|
|
185
|
+
patternCount: patterns.length,
|
|
186
|
+
});
|
|
187
|
+
return deletedCount;
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function createMemoryStore(options = {}) {
|
|
192
|
+
const { defaultTtlSeconds = 60 } = options;
|
|
193
|
+
const entries = new Map();
|
|
194
|
+
return {
|
|
195
|
+
async get(key) {
|
|
196
|
+
const entry = entries.get(key);
|
|
197
|
+
if (!entry) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
if (Date.now() > entry.expiresAt) {
|
|
201
|
+
entries.delete(key);
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
return entry.value;
|
|
205
|
+
},
|
|
206
|
+
async set(key, value, setOptions) {
|
|
207
|
+
const ttlSeconds = setOptions?.ttlSeconds ?? defaultTtlSeconds;
|
|
208
|
+
entries.set(key, {
|
|
209
|
+
expiresAt: Date.now() + ttlSeconds * 1000,
|
|
210
|
+
value,
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
async deleteByPatterns(patterns) {
|
|
214
|
+
const matchers = patterns.map(wildcardToRegExp);
|
|
215
|
+
let deletedCount = 0;
|
|
216
|
+
for (const key of entries.keys()) {
|
|
217
|
+
if (matchers.some((matcher) => matcher.test(key))) {
|
|
218
|
+
entries.delete(key);
|
|
219
|
+
deletedCount += 1;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return deletedCount;
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@heinhtet37/express-route-cache",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Reusable Express route caching middleware for Node.js and TypeScript services.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
22
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"express",
|
|
29
|
+
"cache",
|
|
30
|
+
"middleware",
|
|
31
|
+
"redis",
|
|
32
|
+
"typescript"
|
|
33
|
+
],
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"express": "^4.21.0 || ^5.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/express": "^5.0.0",
|
|
40
|
+
"typescript": "^5.7.3"
|
|
41
|
+
}
|
|
42
|
+
}
|