### Starting Edge-first App Locally Source: https://github.com/edgefirst-dev/kit/blob/main/docs/getting-started/installation.md These commands guide the user to navigate into the newly created application directory, install project dependencies using Bun, and then start the local development server. This allows for local testing and development of the Edge-first application. ```bash cd example-app bun install bun run dev ``` -------------------------------- ### Installing Dependencies with Bun Source: https://github.com/edgefirst-dev/kit/blob/main/CONTRIBUTING.md This command uses Bun to install all project dependencies, ensuring the development environment is ready for use. ```Shell bun install ``` -------------------------------- ### Creating New Edge-first App with Degit Source: https://github.com/edgefirst-dev/kit/blob/main/docs/getting-started/installation.md This command uses `npx degit` to scaffold a new Edge-first application project. It clones the `edgefirst-dev/starter` template into a new directory named `my-app`, providing a pre-configured Cloudflare Worker setup with EdgeKit.js and React Router v7. ```bash npx degit edgefirst-dev/starter my-app ``` -------------------------------- ### Running Tests with Bun Source: https://github.com/edgefirst-dev/kit/blob/main/CONTRIBUTING.md This command executes the project's test suite using Bun, verifying the correctness and functionality of the code. ```Shell bun test ``` -------------------------------- ### Configuring EdgeKit.js Environment Variables Source: https://github.com/edgefirst-dev/kit/blob/main/docs/getting-started/installation.md This `.env` file example illustrates the necessary environment variables for an EdgeKit.js application, typically stored in a `.dev.vars` file for local development. It includes placeholders for Cloudflare account details, API tokens, and other service keys required for the application's functionality. ```env APP_ENV="development" CLOUDFLARE_ACCOUNT_ID="" CLOUDFLARE_DATABASE_ID="" CLOUDFLARE_API_TOKEN="" GRAVATAR_API_TOKEN="" VERIFIER_API_KEY="" ``` -------------------------------- ### Installing EdgeKit.js with Bun Source: https://github.com/edgefirst-dev/kit/blob/main/docs/getting-started/installation.md This command installs the EdgeKit.js library into your project using the Bun package manager. It is a prerequisite for developing Edge-first applications with EdgeKit.js. ```bash bun install edgekitjs ``` -------------------------------- ### Checking Exports with Bun Source: https://github.com/edgefirst-dev/kit/blob/main/CONTRIBUTING.md This command verifies the project's exports using Bun, ensuring that modules are correctly exposed and accessible. ```Shell bun run exports ``` -------------------------------- ### Checking Code Quality with Bun Source: https://github.com/edgefirst-dev/kit/blob/main/CONTRIBUTING.md This command initiates the code quality checker via Bun, helping to maintain consistent coding standards and identify potential issues. ```Shell bun run quality ``` -------------------------------- ### Running Type Checker with Bun Source: https://github.com/edgefirst-dev/kit/blob/main/CONTRIBUTING.md This command runs the type checker using Bun, ensuring type safety and catching type-related errors in the codebase. ```Shell bun run typecheck ``` -------------------------------- ### Installing EdgeKit.js Toolkit (Bun) Source: https://github.com/edgefirst-dev/kit/blob/main/README.md This command adds the EdgeKit.js toolkit as a dependency to your project using the Bun package manager. It's a prerequisite for manually setting up EdgeKit.js in a Cloudflare Worker. ```bash bun add edgekitjs ``` -------------------------------- ### Bootstrapping EdgeKit.js in Cloudflare Worker Source: https://github.com/edgefirst-dev/kit/blob/main/docs/getting-started/installation.md This JavaScript code demonstrates how to initialize EdgeKit.js within a Cloudflare Worker script. It imports the `bootstrap` function and exports its result, providing an `onRequest` handler to define the application's core logic and return a response. ```javascript import { bootstrap } from "edgekitjs"; export default bootstrap({ onRequest(request) { // Write your application here return new Response("Hello, World!", { headers: { "content-type": "text/plain" } }); } }); ``` -------------------------------- ### Creating New Edge-first App with EdgeKit.js (Bash) Source: https://github.com/edgefirst-dev/kit/blob/main/README.md This command initializes a new Cloudflare Worker project pre-configured with EdgeKit.js and React Router v7. It uses `npx degit` to clone a starter template, providing a quick way to begin development. ```bash npx degit edgefirst-dev/starter my-app ``` -------------------------------- ### Standard Directory Structure for Edge-first Applications Source: https://github.com/edgefirst-dev/kit/blob/main/docs/getting-started/directory-structure.md This snippet illustrates the recommended directory structure for an Edge-first application, mirroring a typical Cloudflare Worker project. It shows the top-level directories like `my-app/`, `worker.ts`, `app/`, `config/`, `db/`, and `scripts/`, along with their key subdirectories, providing a clear organizational blueprint for project files. ```plaintext my-app/ ├── worker.ts ├── app/ │ ├── assets/ │ ├── clients/ │ ├── components/ │ ├── entities/ │ ├── helpers/ │ ├── jobs/ │ ├── mocks/ │ ├── repositories/ │ ├── resources/ │ ├── services/ │ ├── tasks/ │ ├── views/ | | ├── layouts/ ├── config/ | ├── redirects.ts ├── db/ | ├── helpers/ | ├── migrations/ | ├── schema.ts | ├── seed.sql ├── scripts/ ``` -------------------------------- ### Bootstrapping Cloudflare Worker with EdgeKit.js (TypeScript) Source: https://github.com/edgefirst-dev/kit/blob/main/README.md This snippet demonstrates how to manually set up EdgeKit.js in a Cloudflare Worker by calling the `bootstrap` function. It configures the ORM with a Drizzle schema, sets up rate limiting, registers background jobs and scheduled tasks, and defines an `onRequest` handler. It also shows how to augment the `edgekitjs` module to add custom environment variables and override the default database schema. ```typescript import schema from "db:schema"; // Import your Drizzle schema import { bootstrap } from "edgekitjs/worker"; export default bootstrap({ orm: { schema }, rateLimit: { limit: 1000, period: 60 }, jobs() { // Register your jobs here return []; }, tasks() { // Schedule your tasks here return []; }, async onRequest(request) { // Inside this function you can use all the functions provided by EdgeKit.js return new Response("Hello, World!", { status: 200 }); } }); declare module "edgekitjs" { export interface Environment { // Add your custom env variables or bindings here } // Override the default DatabaseSchema with your own type Schema = typeof schema; export interface DatabaseSchema extends Schema {} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.