customize template

This commit is contained in:
2025-10-20 05:14:06 -07:00
parent 7dd84c77a4
commit 96041e5ce5
16 changed files with 1105 additions and 1736 deletions
-12
View File
@@ -1,12 +0,0 @@
# http://editorconfig.org
root = true
[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.yml]
indent_style = space
+4
View File
@@ -165,3 +165,7 @@ dist
.env* .env*
!.env.example !.env.example
.wrangler/ .wrangler/
# selflare/typescript build output
worker.capnp
public/*.js
-6
View File
@@ -1,6 +0,0 @@
{
"printWidth": 140,
"singleQuote": true,
"semi": true,
"useTabs": true
}
-5
View File
@@ -1,5 +0,0 @@
{
"files.associations": {
"wrangler.json": "jsonc"
}
}
+12
View File
@@ -0,0 +1,12 @@
FROM jacoblincool/workerd:latest
COPY ./worker.capnp ./worker.capnp
VOLUME /worker/cache
VOLUME /worker/kv
VOLUME /worker/d1
VOLUME /worker/r2
EXPOSE 8080/tcp
CMD ["serve", "--experimental", "--binary", "worker.capnp"]
+1040 -1577
View File
File diff suppressed because it is too large Load Diff
+1 -4
View File
@@ -5,14 +5,11 @@
"scripts": { "scripts": {
"deploy": "wrangler deploy", "deploy": "wrangler deploy",
"dev": "wrangler dev", "dev": "wrangler dev",
"start": "wrangler dev",
"test": "vitest",
"cf-typegen": "wrangler types" "cf-typegen": "wrangler types"
}, },
"devDependencies": { "devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.8.19", "selflare": "^1.1.2",
"typescript": "^5.5.2", "typescript": "^5.5.2",
"vitest": "~3.2.0",
"wrangler": "^4.43.0" "wrangler": "^4.43.0"
} }
} }
+4 -18
View File
@@ -1,4 +1,7 @@
<!doctype html> <!doctype html>
<head>
<link rel="icon" href="data:image/png;base64,iVBORw0KGgo=">
</head>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
@@ -10,23 +13,6 @@
<p>This page comes from a static asset stored at `public/index.html` as configured in `wrangler.jsonc`.</p> <p>This page comes from a static asset stored at `public/index.html` as configured in `wrangler.jsonc`.</p>
<button id="button" type="button">Fetch a random UUID</button> <button id="button" type="button">Fetch a random UUID</button>
<output id="random" for="button"></output> <output id="random" for="button"></output>
<script> <script src="script.js"></script>
fetch('/message')
.then((resp) => resp.text())
.then((text) => {
const h1 = document.getElementById('heading');
h1.textContent = text;
});
const button = document.getElementById("button");
button.addEventListener("click", () => {
fetch('/random')
.then((resp) => resp.text())
.then((text) => {
const random = document.getElementById('random');
random.textContent = text;
});
});
</script>
</body> </body>
</html> </html>
+16
View File
@@ -0,0 +1,16 @@
fetch('/message')
.then((resp) => resp.text())
.then((text) => {
const h1 = document.getElementById('heading')!;
h1.textContent = text;
});
const button = document.getElementById("button")!;
button.addEventListener("click", () => {
fetch('/random')
.then((resp) => resp.text())
.then((text) => {
const random = document.getElementById('random')!;
random.textContent = text;
});
});
+7
View File
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"target": "es2020",
"module": "es2020",
"moduleResolution": "node",
}
}
-3
View File
@@ -1,3 +0,0 @@
declare module 'cloudflare:test' {
interface ProvidedEnv extends Env {}
}
-41
View File
@@ -1,41 +0,0 @@
import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
import { describe, it, expect } from 'vitest';
import worker from '../src';
describe('Hello World user worker', () => {
describe('request for /message', () => {
it('/ responds with "Hello, World!" (unit style)', async () => {
const request = new Request<unknown, IncomingRequestCfProperties>('http://example.com/message');
// Create an empty context to pass to `worker.fetch()`.
const ctx = createExecutionContext();
const response = await worker.fetch(request, env, ctx);
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
await waitOnExecutionContext(ctx);
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
});
it('responds with "Hello, World!" (integration style)', async () => {
const request = new Request('http://example.com/message');
const response = await SELF.fetch(request);
expect(await response.text()).toMatchInlineSnapshot(`"Hello, World!"`);
});
});
describe('request for /random', () => {
it('/ responds with a random UUID (unit style)', async () => {
const request = new Request<unknown, IncomingRequestCfProperties>('http://example.com/random');
// Create an empty context to pass to `worker.fetch()`.
const ctx = createExecutionContext();
const response = await worker.fetch(request, env, ctx);
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
await waitOnExecutionContext(ctx);
expect(await response.text()).toMatch(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/);
});
it('responds with a random UUID (integration style)', async () => {
const request = new Request('http://example.com/random');
const response = await SELF.fetch(request);
expect(await response.text()).toMatch(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/);
});
});
});
-8
View File
@@ -1,8 +0,0 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": ["@cloudflare/vitest-pool-workers"]
},
"include": ["./**/*.ts", "../worker-configuration.d.ts"],
"exclude": []
}
-11
View File
@@ -1,11 +0,0 @@
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';
export default defineWorkersConfig({
test: {
poolOptions: {
workers: {
wrangler: { configPath: './wrangler.jsonc' },
},
},
},
});
-50
View File
@@ -1,50 +0,0 @@
/**
* For more details on how to configure Wrangler, refer to:
* https://developers.cloudflare.com/workers/wrangler/configuration/
*/
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "twitch-cloud-ebs",
"main": "src/index.ts",
"compatibility_date": "2025-10-11",
"compatibility_flags": [
"global_fetch_strictly_public"
],
"assets": {
// The path to the directory containing the `index.html` file to be served at `/`
"directory": "./public"
},
"observability": {
"enabled": true
}
/**
* Smart Placement
* Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
*/
// "placement": { "mode": "smart" }
/**
* Bindings
* Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including
* databases, object storage, AI inference, real-time communication and more.
* https://developers.cloudflare.com/workers/runtime-apis/bindings/
*/
/**
* Environment Variables
* https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
*/
// "vars": { "MY_VARIABLE": "production_value" }
/**
* Note: Use secrets to store sensitive data.
* https://developers.cloudflare.com/workers/configuration/secrets/
*/
/**
* Static Assets
* https://developers.cloudflare.com/workers/static-assets/binding/
*/
// "assets": { "directory": "./public/", "binding": "ASSETS" }
/**
* Service Bindings (communicate between multiple Workers)
* https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
*/
// "services": [{ "binding": "MY_SERVICE", "service": "my-service" }]
}
+20
View File
@@ -0,0 +1,20 @@
# https://developers.cloudflare.com/workers/wrangler/configuration/
name = "twitch-cloud-ebs"
main = "src/index.ts"
compatibility_date = "2025-10-11"
compatibility_flags = [ "global_fetch_strictly_public" ]
keep_vars=true
workers_dev=false
[build]
command='esbuild *.ts --outdir=. --minify --bundle --sourcemap=inline --sources-content=false --format=esm'
cwd='public'
[assets]
directory = "./public"
[observability]
enabled = true
[placement]
mode = "smart"