Skip to content

Commit 9b095ef

Browse files
committed
Convert project to sveltekit
1 parent 07bd0a0 commit 9b095ef

27 files changed

+4857
-5841
lines changed

.cargo-ok

Whitespace-only changes.

.gitignore

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1-
dist
21
node_modules
3-
transpiled
4-
worker
2+
3+
# Output
4+
.output
5+
.vercel
6+
.netlify
7+
.wrangler
8+
/.svelte-kit
9+
/build
10+
11+
# OS
12+
.DS_Store
13+
Thumbs.db
14+
15+
# Env
16+
.env
17+
.env.*
18+
!.env.example
19+
!.env.test
20+
21+
# Vite
22+
vite.config.js.timestamp-*
23+
vite.config.ts.timestamp-*

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true

.prettierrc

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

LICENSE_APACHE

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

LICENSE_MIT

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

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
1-
# ʕ •́؈•̀) `workers-typescript-template`
1+
# sv
22

3-
A batteries included template for kick starting a TypeScript Cloudflare worker project.
3+
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
44

5-
## 🔋 Getting Started
5+
## Creating a project
66

7-
This template is meant to be used with [Wrangler](https://github.com/cloudflare/wrangler). If you are not already familiar with the tool, we recommend that you install the tool and configure it to work with your [Cloudflare account](https://dash.cloudflare.com). Documentation can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler/).
8-
9-
To generate using Wrangler, run this command:
7+
If you're seeing this, you've probably already done this step. Congrats!
108

119
```bash
12-
wrangler generate my-ts-project https://github.com/EverlastingBugstopper/worker-typescript-template
13-
```
14-
15-
### 👩 💻 Developing
10+
# create a new project in the current directory
11+
npx sv create
1612

17-
[`src/index.js`](./src/index.ts) calls the request handler in [`src/handler.ts`](./src/handler.ts), and will return the [request method](https://developer.mozilla.org/en-US/docs/Web/API/Request/method) for the given request.
18-
19-
### 🧪 Testing
13+
# create a new project in my-app
14+
npx sv create my-app
15+
```
2016

21-
This template comes with mocha tests which simply test that the request handler can handle each request method. `npm test` will run your tests.
17+
## Developing
2218

23-
### ✏️ Formatting
19+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
2420

25-
This template uses [`prettier`](https://prettier.io/) to format the project. To invoke, run `npm run format`.
21+
```bash
22+
npm run dev
2623

27-
### 👀 Previewing and Publishing
24+
# or start the server and open the app in a new browser tab
25+
npm run dev -- --open
26+
```
2827

29-
For information on how to preview and publish your worker, please see the [Wrangler docs](https://developers.cloudflare.com/workers/tooling/wrangler/commands/#publish).
28+
## Building
3029

31-
## 🤢 Issues
30+
To create a production version of your app:
3231

33-
If you run into issues with this specific project, please feel free to file an issue [here](https://github.com/cloudflare/workers-typescript-template/issues). If the problem is with Wrangler, please file an issue [here](https://github.com/cloudflare/wrangler/issues).
32+
```bash
33+
npm run build
34+
```
3435

35-
## ⚠️ Caveats
36+
You can preview the production build with `npm run preview`.
3637

37-
The `service-worker-mock` used by the tests is not a perfect representation of the Cloudflare Workers runtime. It is a general approximation. We recommend that you test end to end with `wrangler dev` in addition to a [staging environment](https://developers.cloudflare.com/workers/tooling/wrangler/configuration/environments/) to test things before deploying.
38+
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.

eslint.config.mjs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { FlatCompat } from "@eslint/eslintrc";
2+
import js from "@eslint/js";
3+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
4+
import tsParser from "@typescript-eslint/parser";
5+
import globals from "globals";
6+
import path from "node:path";
7+
import { fileURLToPath } from "node:url";
8+
import parser from "svelte-eslint-parser";
9+
10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename);
12+
const compat = new FlatCompat({
13+
baseDirectory: __dirname,
14+
recommendedConfig: js.configs.recommended,
15+
allConfig: js.configs.all
16+
});
17+
18+
export default [
19+
{
20+
ignores: [
21+
"**/.DS_Store",
22+
"**/node_modules",
23+
"build",
24+
".svelte-kit",
25+
"package",
26+
"**/.env",
27+
"**/.env.*",
28+
"!**/.env.example",
29+
"**/pnpm-lock.yaml",
30+
"**/package-lock.json",
31+
"**/yarn.lock",
32+
"**/dist",
33+
"**/coverage",
34+
"**/public",
35+
"**/static",
36+
"**/tmp",
37+
"**/.firestore",
38+
"**/.vercel"
39+
]
40+
},
41+
...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:svelte/recommended", "prettier"),
42+
{
43+
plugins: {
44+
"@typescript-eslint": typescriptEslint
45+
},
46+
rules: {
47+
"@typescript-eslint/no-explicit-any": "warn",
48+
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "none" }],
49+
quotes: ["warn", "double"]
50+
},
51+
languageOptions: {
52+
globals: {
53+
...globals.browser,
54+
...globals.node
55+
},
56+
parser: tsParser,
57+
ecmaVersion: 2020,
58+
sourceType: "module",
59+
parserOptions: {
60+
extraFileExtensions: [".svelte"]
61+
}
62+
}
63+
},
64+
{
65+
files: ["**/*.svelte"],
66+
67+
languageOptions: {
68+
parser: parser,
69+
ecmaVersion: 5,
70+
sourceType: "script",
71+
72+
parserOptions: {
73+
parser: "@typescript-eslint/parser"
74+
}
75+
}
76+
}
77+
];

0 commit comments

Comments
 (0)