{"id":31287900,"url":"https://github.com/notties/blog-hono-api","last_synced_at":"2026-04-13T19:31:51.842Z","repository":{"id":315773024,"uuid":"1060771268","full_name":"Notties/blog-hono-api","owner":"Notties","description":"Bun + Hono Stacks, Redis Auth etc.","archived":false,"fork":false,"pushed_at":"2025-09-20T16:47:07.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-20T17:37:41.900Z","etag":null,"topics":["bun","docker","drizzle-orm","hono","jwt","postgresql","redis","zod"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Notties.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-20T15:02:01.000Z","updated_at":"2025-09-20T16:47:10.000Z","dependencies_parsed_at":"2025-09-20T17:37:45.164Z","dependency_job_id":"70e6afc1-d8c2-43ab-9f9d-b6613504b288","html_url":"https://github.com/Notties/blog-hono-api","commit_stats":null,"previous_names":["notties/blog-hono-api"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Notties/blog-hono-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Notties%2Fblog-hono-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Notties%2Fblog-hono-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Notties%2Fblog-hono-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Notties%2Fblog-hono-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Notties","download_url":"https://codeload.github.com/Notties/blog-hono-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Notties%2Fblog-hono-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276738917,"owners_count":25696023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-24T02:00:09.776Z","response_time":97,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","docker","drizzle-orm","hono","jwt","postgresql","redis","zod"],"created_at":"2025-09-24T11:31:01.866Z","updated_at":"2025-09-24T11:32:21.874Z","avatar_url":"https://github.com/Notties.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# REST API with Bun, Hono, and Drizzle ORM\n\n## ✨ Key Features\n\n-   ⚡️ **Powered by Bun**: Uses the fast Bun runtime for development, testing, and bundling.\n-   🚀 **Blazing Fast Hono**: Built on the Hono web framework, known for its exceptional performance.\n-   🐘 **PostgreSQL with Drizzle ORM**: Type-safe SQL queries and schema management with Drizzle ORM.\n-   🛡️ **JWT Authentication**: Secure user authentication using JSON Web Tokens.\n-   👑 **Role-Based Access Control (RBAC)**: Middleware to protect routes based on user roles (`admin`, `user`).\n-    caching for frequently accessed data.\n-   📝 **Input Validation**: Uses `zod` for robust and type-safe validation of incoming requests.\n-   🐳 **Optimized for Docker**: Includes a multi-stage `Dockerfile` that builds a tiny, secure production image.\n\n---\n\n## 🛠️ Technology Stack\n\n-   **Runtime**: [Bun](https://bun.sh/)\n-   **Framework**: [Hono](https://hono.dev/)\n-   **Database**: [PostgreSQL](https://www.postgresql.org/)\n-   **ORM**: [Drizzle ORM](https://orm.drizzle.team/)\n-   **Authentication**: [Hono/jwt](https://hono.dev/middlewares/jwt)\n-   **Validation**: [Zod](https://zod.dev/) \u0026 `@hono/zod-validator`\n-   **Caching**: [Redis](https://redis.io/)\n-   **Containerization**: [Docker](https://www.docker.com/)\n\n---\n\n## 🚀 Getting Started\n\n### Prerequisites\n\n-   [Bun](https://bun.sh/docs/installation) (v1.0 or higher)\n-   [Docker](https://www.docker.com/get-started/) and Docker Compose\n\n### Installation \u0026 Setup\n\n1.  **Install dependencies:**\n    ```bash\n    bun install\n    ```\n\n2.  **Set up Environment Variables:**\n    Create a `.env` file in the root of the project by copying the example file.\n    ```bash\n    cp .env.example .env\n    ```\n    Then, fill in the required values in the `.env` file:\n    ```env\n    DATABASE_URL=\"postgres://USER:PASSWORD@HOST:PORT/DATABASE\"\n    JWT_SECRET=\"your-super-secret-and-long-jwt-secret-key\"\n    REDIS_URL=\"redis://127.0.0.1:6379\"\n    PORT=\"3000\"\n    ```\n\n3.  **Run Database Migrations:**\n    This command will generate your schema and apply them to the database.\n    ```bash\n    bun run db:push\n    ```\n\n---\n\n## 📜 Available Scripts\n\n-   **Development Server**: Start the server in watch mode.\n    ```bash\n    bun dev\n    ```\n\n-   **Production Build**: Compile the application into a single binary.\n    ```bash\n    bun run build\n    ```\n\n-   **Start in Production Mode**: Run the compiled binary. Requires environment variables to be set manually.\n    ```bash\n    bun start\n    ```\n---\n\n## Endpoints\n\n| Method   | Path                  | Description                      | Auth Required | Admin Only |\n| :------- | :-------------------- | :------------------------------- | :-----------: | :--------: |\n| `POST`   | `/api/auth/register`  | Register a new user.             |      ❌       |     ❌     |\n| `POST`   | `/api/auth/login`     | Log in to get a JWT.             |      ❌       |     ❌     |\n| `GET`    | `/api/posts`          | Get a list of all posts.         |      ❌       |     ❌     |\n| `GET`    | `/api/posts/:id`      | Get a single post by its ID.     |      ❌       |     ❌     |\n| `POST`   | `/api/posts`          | Create a new post.               |      ✅      |     ❌     |\n| `DELETE` | `/api/posts/:id`      | Delete a post by its ID.         |      ✅      |    ✅     |\n\n---\n\n## 🐳 Dockerization\n\nThis project is fully containerized for easy deployment.\n\n1.  **Build the Docker image:**\n    ```bash\n    docker build -t your-api-name .\n    ```\n\n2.  **Run the Docker container:**\n    Make sure to pass all required environment variables to the container.\n    ```bash\n    docker run -p 3000:3000 \\\n      -e DATABASE_URL=\"\u003cyour_database_url\u003e\" \\\n      -e JWT_SECRET=\"\u003cyour_jwt_secret\u003e\" \\\n      -e REDIS_URL=\"\u003cyour_redis_url\u003e\" \\\n      -d your-api-name\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotties%2Fblog-hono-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotties%2Fblog-hono-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotties%2Fblog-hono-api/lists"}