|
1 | | -# ʕ •́؈•̀) `workers-typescript-template` |
| 1 | +# sv |
2 | 2 |
|
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). |
4 | 4 |
|
5 | | -## 🔋 Getting Started |
| 5 | +## Creating a project |
6 | 6 |
|
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! |
10 | 8 |
|
11 | 9 | ```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 |
16 | 12 |
|
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 | +``` |
20 | 16 |
|
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 |
22 | 18 |
|
23 | | -### ✏️ Formatting |
| 19 | +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: |
24 | 20 |
|
25 | | -This template uses [`prettier`](https://prettier.io/) to format the project. To invoke, run `npm run format`. |
| 21 | +```bash |
| 22 | +npm run dev |
26 | 23 |
|
27 | | -### 👀 Previewing and Publishing |
| 24 | +# or start the server and open the app in a new browser tab |
| 25 | +npm run dev -- --open |
| 26 | +``` |
28 | 27 |
|
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 |
30 | 29 |
|
31 | | -## 🤢 Issues |
| 30 | +To create a production version of your app: |
32 | 31 |
|
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 | +``` |
34 | 35 |
|
35 | | -## ⚠️ Caveats |
| 36 | +You can preview the production build with `npm run preview`. |
36 | 37 |
|
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. |
0 commit comments