Skip to content

Commit a2eba97

Browse files
committed
sync
1 parent 99a9111 commit a2eba97

File tree

9 files changed

+356
-41
lines changed

9 files changed

+356
-41
lines changed

.github/workflows/deploy.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
workflow_dispatch:
8+
9+
concurrency: ${{ github.workflow }}-${{ github.ref }}
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Bun
19+
uses: oven-sh/setup-bun@v1
20+
with:
21+
bun-version: latest
22+
23+
- name: Install dependencies
24+
run: bun install
25+
26+
- name: Run validation script
27+
run: bun scripts/validate
28+
29+
- name: Generate data
30+
run: bun scripts/generate
31+
32+
- run: bun sst deploy --stage=dev
33+
env:
34+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

.github/workflows/generate.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
3333
# Finder (MacOS) folder config
3434
.DS_Store
3535

36-
# OpenCode
37-
.opencode
36+
# SST
37+
.sst
3838

39-
models.json
39+
# OpenCode
40+
.opencode

app/worker.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export default {
2+
async fetch(req: Request) {
3+
const url = new URL(req.url);
4+
5+
if (url.pathname !== "/") {
6+
return Response.redirect("/", 302);
7+
}
8+
9+
return new Response(
10+
`
11+
<html>
12+
<body>
13+
<h1>Hello World</h1>
14+
</body>
15+
</html>
16+
`,
17+
{
18+
headers: {
19+
"Content-Type": "text/html",
20+
},
21+
}
22+
);
23+
},
24+
};

bun.lock

Lines changed: 251 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@iarna/toml": "^2.2.5",
14+
"sst": "^3.17.3",
1415
"zod": "^3.25.51"
1516
}
1617
}

scripts/generate

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/usr/bin/env bun
22

33
import { join } from "path";
4-
import { readdir, stat, writeFile } from "fs/promises";
4+
import { readdir, stat, writeFile, mkdir } from "fs/promises";
55
import { parse } from "@iarna/toml";
66
import { file } from "bun";
77

88
async function build() {
99
const providersDir = join(import.meta.dir, "..", "providers");
10-
const outputPath = join(import.meta.dir, "..", "data.json");
10+
const distDir = join(import.meta.dir, "..", "dist");
11+
const outputPath = join(distDir, "api.json");
1112
const result = {};
1213

1314
try {
@@ -47,7 +48,8 @@ async function build() {
4748
}
4849

4950
// Write the result to data.json
50-
await writeFile(outputPath, JSON.stringify(result, null, 2));
51+
await mkdir(distDir, { recursive: true });
52+
await writeFile(outputPath, JSON.stringify(result));
5153
console.log(
5254
`\n✅ Successfully built data.json with ${
5355
Object.keys(result).length

sst-env.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* This file is auto-generated by SST. Do not edit. */
2+
/* tslint:disable */
3+
/* eslint-disable */
4+
/* deno-fmt-ignore-file */
5+
6+
declare module "sst" {
7+
export interface Resource {
8+
"MyWorker": {
9+
"type": "sst.cloudflare.Worker"
10+
"url": string
11+
}
12+
}
13+
}
14+
/// <reference path="sst-env.d.ts" />
15+
16+
import "sst"
17+
export {}

sst.config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference path="./.sst/platform/config.d.ts" />
2+
3+
export default $config({
4+
app() {
5+
return {
6+
name: "models-dev",
7+
home: "cloudflare",
8+
};
9+
},
10+
async run() {
11+
new sst.cloudflare.Worker("MyWorker", {
12+
domain: "models.dev",
13+
handler: "app/worker.ts",
14+
url: true,
15+
assets: {
16+
directory: "./dist",
17+
},
18+
});
19+
},
20+
});

0 commit comments

Comments
 (0)