@appwarden/middleware 1.1.4 → 1.1.5
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 +22 -2
- package/{chunk-6DI6L6AE.js → chunk-CGJ2UT3T.js} +6 -11
- package/cloudflare.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @appwarden/middleware
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Read the docs [to learn more](https://appwarden.io/docs)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Stop in progress attacks in their tracks
|
|
6
|
+
|
|
7
|
+
Instantly halt all external access to a domain from your Discord server
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
/quarantine lock your.app.io
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Compatible with websites powered by [Cloudflare](https://developers.cloudflare.com/pages/) or [Vercel](https://vercel.com).
|
|
16
|
+
|
|
17
|
+
### Cloudflare
|
|
18
|
+
|
|
19
|
+
We recommend using the [`@appwarden/build-cloudflare-action`](https://github.com/appwarden/build-cloudflare-action) Github Action to deploy on Cloudflare.
|
|
20
|
+
|
|
21
|
+
> Read the docs [to get started](https://appwarden.io/docs/guides/cloudflare-integration)
|
|
22
|
+
|
|
23
|
+
### Vercel
|
|
24
|
+
|
|
25
|
+
> Read the docs [to get started](https://appwarden.io/docs/guides/vercel-integration)
|
|
@@ -18,12 +18,7 @@ var store = {
|
|
|
18
18
|
const cacheKeyUrl = new URL(cacheKey, context.serviceOrigin);
|
|
19
19
|
return {
|
|
20
20
|
getValue: () => getCacheValue(context, cacheKeyUrl),
|
|
21
|
-
updateValue: (json) => updateCacheValue(
|
|
22
|
-
context,
|
|
23
|
-
cacheKeyUrl,
|
|
24
|
-
json,
|
|
25
|
-
options?.cacheExpirationSeconds
|
|
26
|
-
),
|
|
21
|
+
updateValue: (json) => updateCacheValue(context, cacheKeyUrl, json, options?.ttl),
|
|
27
22
|
deleteValue: () => clearCache(context, cacheKeyUrl)
|
|
28
23
|
};
|
|
29
24
|
}
|
|
@@ -37,20 +32,20 @@ var getCacheValue = async (context, cacheKey) => {
|
|
|
37
32
|
debug(`[${cacheKey.pathname}] Cache MATCH!`);
|
|
38
33
|
return match;
|
|
39
34
|
};
|
|
40
|
-
var updateCacheValue = async (context, cacheKey, value,
|
|
35
|
+
var updateCacheValue = async (context, cacheKey, value, ttl) => {
|
|
41
36
|
debug(
|
|
42
37
|
"updating cache...",
|
|
43
38
|
cacheKey.href,
|
|
44
39
|
value,
|
|
45
|
-
|
|
40
|
+
ttl ? `expires in ${ttl}s` : ""
|
|
46
41
|
);
|
|
47
42
|
await context.cache.put(
|
|
48
43
|
cacheKey,
|
|
49
44
|
new Response(JSON.stringify(value), {
|
|
50
45
|
headers: {
|
|
51
46
|
"content-type": "application/json",
|
|
52
|
-
...
|
|
53
|
-
"cache-control": `max-age=${
|
|
47
|
+
...ttl && {
|
|
48
|
+
"cache-control": `max-age=${ttl}`
|
|
54
49
|
}
|
|
55
50
|
}
|
|
56
51
|
})
|
|
@@ -85,8 +80,8 @@ var getLockValue = async (context) => {
|
|
|
85
80
|
try {
|
|
86
81
|
let shouldDeleteEdgeValue = false;
|
|
87
82
|
let cacheResponse, lockValue = {
|
|
88
|
-
isLockedTest: 0,
|
|
89
83
|
isLocked: 0,
|
|
84
|
+
isLockedTest: 0,
|
|
90
85
|
lastCheck: Date.now(),
|
|
91
86
|
code: ""
|
|
92
87
|
};
|
package/cloudflare.js
CHANGED
package/index.js
CHANGED