Skip to content

A modern framework for building REST APIs with TypeScript, Prisma, and Bun πŸš€ Instant API generation, authentication, and more.

License

Notifications You must be signed in to change notification settings

BramSuurdje/RestRocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

43 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RestRocket πŸš€

RestRocket is a lightning-fast, developer-friendly framework for creating REST APIs in seconds. Built with modern technologies and best practices, it allows you to focus on defining your data model while taking care of the heavy lifting of API creation.

Features ✨

  • Instant API Generation: Define your Prisma schema and routes configuration - RestRocket handles the rest
  • Type Safety: Built with TypeScript for robust type checking and better developer experience
  • Authentication Ready: Integrated with Better Auth for secure authentication out of the box
  • Multiple Response Formats: Supports JSON and XML responses
  • Database Integration: Seamless PostgreSQL integration with Prisma
  • Performance Optimized: Built on top of Bun and Hono for maximum performance
  • Logging: Structured logging with Pino

Tech Stack πŸ’»

Prerequisites πŸ“‹

  • Bun (Latest version)
  • Docker and Docker Compose
  • Node.js 18+ (for development tools)

Getting Started πŸš€

  1. Clone the repository:

    git clone https://github.com/BramSuurdje/RestRocket.git
    cd restrocket
  2. Copy the environment file and configure your variables:

    cp .env.example .env
  3. Install dependencies:

    bun install
  4. Run database migrations:

    bun run migrate:dev
  5. Deploy the migrations to the database:

    bun run migrate:deploy
  6. Start the development server:

    bun run dev

The API will be available at http://localhost:3000 by default.

Environment Variables πŸ”§

Variable Description Default
POSTGRES_PASSWORD PostgreSQL password changeme
POSTGRES_USER PostgreSQL username restrocket
POSTGRES_DB PostgreSQL database name restrocket
BETTER_AUTH_SECRET Authentication secret key changeme
BETTER_AUTH_URL Base URL of your application http://localhost:3000
LOG_LEVEL Application log level debug

Development Commands πŸ› οΈ

  • bun run dev - Start development server with hot reload
  • bun run build - Generate Prisma client
  • bun run start - Start production server
  • bun run format - Format code using Biome
  • bun run migrate:dev - Run database migrations for development
  • bun run migrate:prod - Run database migrations for production

Creating an API Endpoint πŸ“

  1. Define your model in prisma/schema.prisma:

    model Post {
      id        String   @id @default(uuid())
      title     String
      content   String
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
    }
  2. Add your route configuration in src/config/routes.ts:

    export const routeConfigurations: RouteConfigInputType = {
       Post: { routeName: "post"}
    } as const;
  3. RestRocket automatically generates:

    • CRUD endpoints
    • Input validation
    • Type-safe responses
    • API documentation

Authentication with Better Auth πŸ”

RestRocket uses Better Auth for authentication. To set up authentication:

  1. Create a Better Auth client instance by following the Better Auth documentation

  2. Point your Better Auth client's baseUrl to your RestRocket API instance:

    export const authClient = createAuthClient({
       baseURL: "http://localhost:3000" // the base url of your api server
    })
  3. All routes in RestRocket are automatically protected by the authentication middleware. The middleware will verify the session token and make the user data available in your route handlers.

For more details about authentication features and configuration options, please refer to the Better Auth documentation.

License πŸ“„

This project is licensed under the MIT License - see the LICENSE file for details.

Author ✍️

Bram Suurd


Made with ❀️ by Bram Suurd

About

A modern framework for building REST APIs with TypeScript, Prisma, and Bun πŸš€ Instant API generation, authentication, and more.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published