### Run Project with Bun Source: https://github.com/stevedylandev/bhvr/blob/main/server/README.md Starts the development server for the BHVR project using Bun. This command typically launches the application and makes it accessible at a specified local address. ```sh bun run dev ``` -------------------------------- ### Install Dependencies with Bun Source: https://github.com/stevedylandev/bhvr/blob/main/server/README.md Installs project dependencies using the Bun package manager. This command ensures all required libraries are downloaded and available for the project. ```sh bun install ``` -------------------------------- ### Install Project Dependencies with Bun Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Instructions to install all project dependencies across workspaces using Bun. ```bash bun install ``` -------------------------------- ### Install Dependencies with Bun Source: https://github.com/stevedylandev/bhvr/blob/main/CONTRIBUTING.md Installs project dependencies using the Bun package manager. This command fetches and sets up all necessary libraries required for the project to run or be built. ```shell bun install ``` -------------------------------- ### Initialize New bhvr Project via CLI Source: https://github.com/stevedylandev/bhvr/blob/main/README.md The command to quickly scaffold a new bhvr project using the dedicated `create-bhvr` CLI tool, simplifying the initial setup process. ```bash bun create bhvr ``` -------------------------------- ### Bhvr Project CLI Commands Source: https://github.com/stevedylandev/bhvr/blob/main/README.md A collection of essential Bash commands for managing a Bhvr project. These include creating a new project, installing dependencies, running development servers, building for production, linting, type checking, and running tests. ```bash # Create a new bhvr project bun create bhvr ``` ```bash # Install dependencies for all workspaces bun install ``` ```bash # Run all workspaces in development mode with Turbo bun run dev # Or run individual workspaces directly bun run dev:client # Run the Vite dev server for React bun run dev:server # Run the Hono backend ``` ```bash # Build all workspaces with Turbo bun run build # Or build individual workspaces directly bun run build:client # Build the React frontend bun run build:server # Build the Hono backend ``` ```bash # Lint all workspaces bun run lint # Type check all workspaces bun run type-check # Run tests across all workspaces bun run test ``` -------------------------------- ### Import Shared TypeScript Types Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Example of importing types from the shared package, demonstrating automatic type sharing between client and server via TypeScript path aliases. ```typescript import { ApiResponse } from 'shared/types'; ``` -------------------------------- ### ESLint React-Specific Lint Rules Source: https://github.com/stevedylandev/bhvr/blob/main/client/README.md Integrates React-specific linting rules by adding the `eslint-plugin-react-x` and `eslint-plugin-react-dom` plugins to the ESLint configuration. This enhances the linting process for React components and DOM interactions, providing recommended rules for improved development practices. ```js // eslint.config.js import reactX from 'eslint-plugin-react-x' import reactDom from 'eslint-plugin-react-dom' export default tseslint.config({ plugins: { // Add the react-x and react-dom plugins 'react-x': reactX, 'react-dom': reactDom, }, rules: { // other rules... // Enable its recommended typescript rules ...reactX.configs['recommended-typescript'].rules, ...reactDom.configs.recommended.rules, }, }) ``` -------------------------------- ### Hono Server Setup and Routes Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Demonstrates setting up a basic Hono application with CORS enabled. It includes a root route returning plain text and a '/hello' endpoint that returns a JSON response conforming to the shared ApiResponse type. This snippet highlights Hono's ease of use for defining routes and handling JSON payloads. ```typescript import { Hono } from 'hono' import { cors } from 'hono/cors' import type { ApiResponse } from 'shared/dist' const app = new Hono() app.use(cors()) app.get('/', (c) => { return c.text('Hello Hono!') }) app.get('/hello', async (c) => { const data: ApiResponse = { message: "Hello BHVR!", success: true } return c.json(data, { status: 200 }) }) export default app ``` -------------------------------- ### Importing Shared Types in Monorepo Packages Source: https://github.com/stevedylandev/bhvr/blob/main/README.md An example demonstrating the syntax for importing types defined in the `shared` package into other monorepo packages like `client` or `server`, leveraging the monorepo's module resolution. ```typescript import { ApiResponse } from 'shared' ``` -------------------------------- ### ESLint Type-Aware Lint Rules Source: https://github.com/stevedylandev/bhvr/blob/main/client/README.md Extends the ESLint configuration to enable type-aware linting rules using the tseslint package. This requires specifying project configurations for TypeScript compilation, ensuring better code quality and catching type-related errors during development. ```js export default tseslint.config({ extends: [ // Remove ...tseslint.configs.recommended and replace with this ...tseslint.configs.recommendedTypeChecked, // Alternatively, use this for stricter rules // ...tseslint.configs.strictTypeChecked, // Optionally, add this for stylistic rules // ...tseslint.configs.stylisticTypeChecked, ], languageOptions: { // other options... parserOptions: { project: ['./tsconfig.node.json', './tsconfig.app.json'], tsconfigRootDir: import.meta.dirname, }, }, }) ``` -------------------------------- ### React Client Fetching Data from Hono API Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Shows a React component that fetches data from the Hono backend's '/hello' endpoint. It uses the Vite environment variable for the server URL and displays the message and success status from the ApiResponse. The example includes basic state management and error handling for the API call. ```typescript import { useState } from 'react' import beaver from './assets/beaver.svg' import { ApiResponse } from 'shared' import './App.css' const SERVER_URL = import.meta.env.VITE_SERVER_URL || "http://localhost:3000" function App() { const [data, setData] = useState() async function sendRequest() { try { const req = await fetch(`${SERVER_URL}/hello`) const res: ApiResponse = await req.json() setData(res) } catch (error) { console.log(error) } } return ( <>
beaver logo

bhvr

Bun + Hono + Vite + React

A typesafe fullstack monorepo

{data && (
            
            Message: {data.message} 
Success: {data.success.toString()}
)}

Click the beaver to learn more

) } export default App ``` -------------------------------- ### Build Project with Bun Source: https://github.com/stevedylandev/bhvr/blob/main/CONTRIBUTING.md Builds the project using the Bun runtime. This command typically compiles, bundles, or prepares the project's code for deployment or execution. ```shell bun run build ``` -------------------------------- ### Build All Project Components Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Command to build all project components, including shared types and the React frontend. ```bash bun run build ``` -------------------------------- ### Monorepo Shared Package Compilation Commands Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Commands used to compile and export packages from the `shared` directory, ensuring they are built and available for consumption by the `client` and `server` applications within the monorepo. ```bash bun run dev ``` ```bash bun run build ``` -------------------------------- ### Run All Project Components in Development Mode Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Command to concurrently run shared types in watch mode, the server, and the client for development. ```bash bun run dev ``` -------------------------------- ### Build Individual Project Components Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Commands to build specific parts of the project (shared types, client) independently. ```bash bun run build:shared bun run build:client ``` -------------------------------- ### Run Individual Project Components in Development Mode Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Commands to run specific parts of the project (shared types, server, client) independently during development. ```bash bun run dev:shared bun run dev:server bun run dev:client ``` -------------------------------- ### Shared Package Directory Structure Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Shows the directory layout for the `shared` package, designed to hold common TypeScript definitions and utilities used by both client and server applications within the monorepo. ```text shared ├── package.json ├── src │   ├── index.ts │   └── types │   └── index.ts └── tsconfig.json ``` -------------------------------- ### Shared Package Type Export Configuration Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Illustrates how types and other code are exported from the `shared` package's `index.ts`, making them easily accessible to other parts of the monorepo. ```typescript export * from "./types" ``` -------------------------------- ### Import Shared Types Source: https://github.com/stevedylandev/bhvr/blob/main/README.md Demonstrates how to import types exported from the `shared` package. This allows for seamless type sharing between the client and server environments within the Bhvr monorepo. ```typescript import { ApiResponse } from 'shared' ``` ```typescript import { ApiResponse } from 'shared/types'; ``` -------------------------------- ### Export from Shared Package Source: https://github.com/stevedylandev/bhvr/blob/main/README.md This TypeScript code snippet shows how the `src/index.ts` file in the shared package exports types from the `./types` directory. This facilitates code sharing across different parts of the monorepo. ```typescript export * from "./types" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.