### Running Automated Project Setup with Bun Source: https://github.com/edgefirst-dev/starter/blob/main/docs/setup.md This command initiates the automated setup script for the project. It prompts for a project name, Cloudflare API token, and optionally Gravatar and Verifier API keys, then creates necessary Cloudflare bindings, runs migrations, and configures `.dev.vars` and `wrangler.toml`. ```bash bun run setup ``` -------------------------------- ### Creating a New React Application with Edge-first Starter Kit Source: https://github.com/edgefirst-dev/starter/blob/main/README.md This snippet provides commands to initialize a new React application using the Edge-first Starter Kit. It uses `bun create` to scaffold the project, then navigates into the new directory, and finally runs a setup script to configure the project locally and on Cloudflare. ```Shell bun create edgefirst-dev/starter cd my-app bun run setup ``` -------------------------------- ### Running Local Database Migrations with Bun Source: https://github.com/edgefirst-dev/starter/blob/main/docs/setup.md This command executes database migrations against the local D1 database. The `` placeholder must be replaced with the actual database name configured in `wrangler.toml` to ensure the schema is up-to-date. ```bash bun run db:migrate:local db-name ``` -------------------------------- ### Creating Cloudflare Worker Secrets with Wrangler Source: https://github.com/edgefirst-dev/starter/blob/main/docs/setup.md These commands create secrets in the Cloudflare Workers environment for production deployment. `APP_ENV` should be set to `production`, and `GRAVATAR_API_TOKEN` and `VERIFIER_API_KEY` should match the values used in `.dev.vars`. ```bash bunx wrangler secret put APP_ENV bunx wrangler secret put GRAVATAR_API_TOKEN bunx wrangler secret put VERIFIER_API_KEY ``` -------------------------------- ### Creating Cloudflare D1, KV, R2, and Queue Bindings Source: https://github.com/edgefirst-dev/starter/blob/main/docs/setup.md These commands create the necessary Cloudflare resources (D1 database, KV namespace, R2 bucket, and Queue) required by the project. Users need to replace placeholder names and update `wrangler.toml` with the generated IDs and names. Binding names must be `DB`, `KV`, and `FS`. ```sh bunx wrangler d1 create bunx wrangler kv namespace create bunx wrangler r2 bucket create bunx wrangler queues create ``` -------------------------------- ### Configuring Manual Environment Variables in .dev.vars Source: https://github.com/edgefirst-dev/starter/blob/main/docs/setup.md This snippet shows the structure for the `.dev.vars` file, which holds local development environment variables. Users must replace placeholder values for Cloudflare account, database, API token, Gravatar API token, and Verifier API key to enable local development. ```txt APP_ENV="development" CLOUDFLARE_ACCOUNT_ID="" CLOUDFLARE_DATABASE_ID="" CLOUDFLARE_API_TOKEN="" GRAVATAR_API_TOKEN="" VERIFIER_API_KEY="" ``` -------------------------------- ### Running Local Database Migrations (Bun) Source: https://github.com/edgefirst-dev/starter/blob/main/docs/database.md This command executes any pending database migrations against the local Cloudflare D1 instance. It requires specifying the database name as an argument. This command also generates new migration files if changes are detected in `db/schema.ts`. ```Shell bun run db:migrate:locale ``` -------------------------------- ### Seeding Local Database (Bun) Source: https://github.com/edgefirst-dev/starter/blob/main/docs/database.md This command applies the seed data defined in `db/seed.sql` to the specified local Cloudflare D1 database. It's used to populate the database with initial data, such as default users or configurations. ```Shell bun run db:seed ``` -------------------------------- ### Organizing View Routes in TypeScript Projects Source: https://github.com/edgefirst-dev/starter/blob/main/docs/file-structure.md This snippet illustrates a recommended file structure for view-rendering routes within the `app/views` directory, following a Rails-like convention. It shows how layouts are separated and how resources like users and posts can have their own folders with standard CRUD-related view files (index, show, edit, new), typically implemented using TypeScript/TSX. ```File System app/views ├── layouts │ ├── auth.tsx │ ├── landing.tsx ├── users │ ├── edit.tsx │ ├── index.tsx │ ├── new.tsx │ ├── show.tsx ├── posts │ ├── edit.tsx │ ├── index.tsx │ ├── new.tsx │ ├── show.tsx ``` -------------------------------- ### Structuring Resource Routes in TypeScript Projects Source: https://github.com/edgefirst-dev/starter/blob/main/docs/file-structure.md This snippet demonstrates a recommended file structure for resource routes within the `app/resources` directory. It suggests creating dedicated subfolders for API endpoints and webhooks, along with a general file for other resources, using TypeScript files (`.ts`) for their implementation. ```File System app/resources ├── api │ ├── users.ts │ ├── posts.ts ├── webhooks │ ├── stripe.ts │ ├── mailgun.ts ├── file.ts ``` -------------------------------- ### Defining a Service Function in TypeScript Source: https://github.com/edgefirst-dev/starter/blob/main/docs/architecture.md This snippet illustrates the standard pattern for defining a service function within the Business Logic Layer. It shows how a service function accepts an `input` object and a `deps` object for dependencies, returning a `Promise` of `Output`. The associated namespace defines the `Input`, `Dependencies`, and `Output` interfaces, promoting type safety and facilitating dependency injection for testing. ```TypeScript export async function serviceName( input: serviceName.Input, deps: serviceName.Dependencies = { // Default instances of the dependencies } ): Promise { // Business logic here } export namespace servieName { export interface Input { // Input data } export interface Dependencies { // Dependencies like repositories or API clients } export interface Output { // Output data, this can be left to be inferred by the return type of the function } } ``` -------------------------------- ### Dropping Local Cloudflare State (Bun) Source: https://github.com/edgefirst-dev/starter/blob/main/docs/database.md This command completely removes all local Cloudflare state, including the D1 database, KV store, R2 buckets, and cache. It's useful for resetting the local development environment or clearing all persisted data. ```Shell bun run db:drop ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.