hono-rpc-starter Svelte Themes

Hono Rpc Starter

This project is a starter template for building a server-client application using Hono Rpc and TypeScript

Hono RPC Starter

This project is a starter template for building a server-client application using Hono Rpc and TypeScript. It includes a basic setup for serving and consuming a REST API.

Project Structure

  • src/app.ts: Defines the main application using Hono.
  • src/index.ts: Sets up the server using Hono and defines the routes.
  • src/routes: Contains the route definitions for handling requests.
  • src/client.ts: Provides a client setup for consuming the API endpoints.
  • tsconfig.json: TypeScript configuration file.
  • package.json: Project dependencies and scripts.

Getting Started

Prerequisites

  • Node.js (v14 or later)
  • npm or pnpm

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/hono-rpc-starter.git
    
  2. Navigate to the project directory:

    cd hono-rpc-starter
    
  3. Install the dependencies:

    pnpm install
    

Running the Application

  1. Start the server:

    pnpm server
    

    The server will start on http://localhost:3000.

  2. Start the client:

    pnpm client
    

Building for Production

To build the project for production, run:

pnpm build

This will compile the TypeScript files into JavaScript in the dist directory.

API Endpoints

  • GET /: Returns a simple "Hello Hono!" message.
  • GET /user/me: Fetches user data.
  • GET /posts/all: Fetches all posts.
  • GET /posts/id:slug: Fetches a specific post by slug.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any changes.

Acknowledgements

This project uses the Hono framework and the Zod validation library.

Top categories

Loading Svelte Themes