@joripspace/cli 0.5.8 → 0.6.1
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 -21
- package/README.md +243 -142
- package/THIRD_PARTY_NOTICES.md +136 -136
- package/bin/joripspace.js +66 -64
- package/lib/auth-redaction.js +1 -0
- package/lib/checkpoint-client.js +15 -2
- package/lib/connection-persistence.js +36 -0
- package/lib/credential-store.js +2 -2
- package/lib/deploy-files.js +5 -11
- package/lib/deployment-error.js +14 -14
- package/lib/help.js +47 -6
- package/lib/remote-commands.js +3 -42
- package/lib/secret-commands.js +96 -0
- package/lib/start.js +1507 -1507
- package/lib/template-commands.js +15 -9
- package/package.json +48 -48
- package/vendor/core/auth-redaction.cjs +21 -0
- package/vendor/core/cli-onboarding.cjs +35 -5
- package/vendor/core/onboarding.cjs +82 -69
- package/vendor/core/template-publish-workflow.cjs +169 -169
- package/vendor/templates/index.js +104 -104
- package/vendor/templates/templates/basic-worker/files/worker.js +9 -9
- package/vendor/templates/templates/basic-worker/manifest.json +14 -14
- package/vendor/templates/templates/r2-file-api/files/worker.js +42 -42
- package/vendor/templates/templates/r2-file-api/manifest.json +7 -7
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
async function cacheTagForKey(key) {
|
|
2
|
-
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(key));
|
|
3
|
-
const hex = Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
4
|
-
return `r2-${hex}`;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
async fetch(request, env, ctx) {
|
|
9
|
-
const url = new URL(request.url);
|
|
10
|
-
const match = url.pathname.match(/^\/files\/(.+)$/);
|
|
11
|
-
if (!match) {
|
|
12
|
-
return Response.json({ ok: true, routes: ['/files/{key}'] });
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const key = decodeURIComponent(match[1]);
|
|
16
|
-
if (request.method === 'GET') {
|
|
17
|
-
const object = await env.STORAGE.get(key);
|
|
18
|
-
if (!object) {
|
|
19
|
-
return new Response('Not found', { status: 404 });
|
|
20
|
-
}
|
|
21
|
-
return new Response(object.body, {
|
|
22
|
-
headers: {
|
|
23
|
-
'Content-Type': object.httpMetadata?.contentType ?? 'application/octet-stream',
|
|
24
|
-
'Cache-Control': 'public, max-age=3600',
|
|
25
|
-
'Cache-Tag': await cacheTagForKey(key),
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (request.method === 'PUT') {
|
|
31
|
-
await env.STORAGE.put(key, request.body, {
|
|
32
|
-
httpMetadata: {
|
|
33
|
-
contentType: request.headers.get('content-type') ?? 'application/octet-stream',
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
await ctx.cache.purge({ tags: [await cacheTagForKey(key)] });
|
|
37
|
-
return Response.json({ ok: true, key }, { headers: { 'Cache-Control': 'private, no-store' } });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return new Response('Method not allowed', { status: 405 });
|
|
41
|
-
},
|
|
42
|
-
};
|
|
1
|
+
async function cacheTagForKey(key) {
|
|
2
|
+
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(key));
|
|
3
|
+
const hex = Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
4
|
+
return `r2-${hex}`;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
async fetch(request, env, ctx) {
|
|
9
|
+
const url = new URL(request.url);
|
|
10
|
+
const match = url.pathname.match(/^\/files\/(.+)$/);
|
|
11
|
+
if (!match) {
|
|
12
|
+
return Response.json({ ok: true, routes: ['/files/{key}'] });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const key = decodeURIComponent(match[1]);
|
|
16
|
+
if (request.method === 'GET') {
|
|
17
|
+
const object = await env.STORAGE.get(key);
|
|
18
|
+
if (!object) {
|
|
19
|
+
return new Response('Not found', { status: 404 });
|
|
20
|
+
}
|
|
21
|
+
return new Response(object.body, {
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': object.httpMetadata?.contentType ?? 'application/octet-stream',
|
|
24
|
+
'Cache-Control': 'public, max-age=3600',
|
|
25
|
+
'Cache-Tag': await cacheTagForKey(key),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (request.method === 'PUT') {
|
|
31
|
+
await env.STORAGE.put(key, request.body, {
|
|
32
|
+
httpMetadata: {
|
|
33
|
+
contentType: request.headers.get('content-type') ?? 'application/octet-stream',
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
await ctx.cache.purge({ tags: [await cacheTagForKey(key)] });
|
|
37
|
+
return Response.json({ ok: true, key }, { headers: { 'Cache-Control': 'private, no-store' } });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return new Response('Method not allowed', { status: 405 });
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "r2-file-api",
|
|
3
|
-
"name": "R2 File API",
|
|
4
|
-
"description": "PUT and GET files through the project R2 bucket.",
|
|
5
|
-
"entrypoint": "worker.js",
|
|
6
|
-
"tags": ["starter", "r2", "api"]
|
|
7
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"id": "r2-file-api",
|
|
3
|
+
"name": "R2 File API",
|
|
4
|
+
"description": "PUT and GET files through the project R2 bucket.",
|
|
5
|
+
"entrypoint": "worker.js",
|
|
6
|
+
"tags": ["starter", "r2", "api"]
|
|
7
|
+
}
|