|
1 | | -``` |
2 | | -npm install |
3 | | -npm run dev |
4 | | -``` |
5 | | - |
6 | | -``` |
7 | | -open http://localhost:3000 |
8 | | -``` |
| 1 | +# Hono - Drizzle - Postgres Sample Todo Example |
| 2 | + |
| 3 | +This is a simple Todo application built using **Hono**, **Drizzle**, **PostgreSQL**, **JWT**, and **TypeScript**. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- User authentication with JWT |
| 8 | +- CRUD operations for Todo items |
| 9 | + - Drizzle ORM for fast and efficient database operations |
| 10 | + |
| 11 | +## Tech Stack |
| 12 | + |
| 13 | +- **Framework**: Hono |
| 14 | +- **Database**: PostgreSQL |
| 15 | +- **ORM**: Drizzle |
| 16 | +- **Authentication**: JWT |
| 17 | +- **Language**: TypeScript |
| 18 | +- **Package Manager**: NPM |
| 19 | + |
| 20 | +## API Endpoints |
| 21 | + |
| 22 | +The application includes the following API routes: |
| 23 | + |
| 24 | +### Public Routes |
| 25 | + |
| 26 | +- POST /auth/register - Register a new user |
| 27 | +- POST /auth/login - Log in a user |
| 28 | +- POST /auth/logout - Log out a user |
| 29 | + |
| 30 | +### Protected Routes (require authentication) |
| 31 | + |
| 32 | +- POST /todo/add-todo - Create a new todo |
| 33 | +- GET /todo/get-todos - Get all todos of a user |
| 34 | +- PUT /todo/toggle-todo-status - Toggle a todo status |
| 35 | +- DELETE /todo/delete-todo - Delete a todo |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +## Setup Instructions |
| 40 | + |
| 41 | + |
| 42 | +1. **Install dependencies**: |
| 43 | + ```sh |
| 44 | + npm install |
| 45 | + ``` |
| 46 | + |
| 47 | +2. **Set up the database**: |
| 48 | + Ensure you have PostgreSQL installed and running. Create a new database and update the database connection settings in the `.env` file. |
| 49 | + |
| 50 | + |
| 51 | +3. **Generate Drizzle models**: |
| 52 | + ```sh |
| 53 | + npx run db:generate |
| 54 | + ``` |
| 55 | + |
| 56 | + |
| 57 | +4. **Run database migrations**: |
| 58 | + ```sh |
| 59 | + npx run db:migrate |
| 60 | + ``` |
| 61 | + |
| 62 | +5. **Start the application**: |
| 63 | + ```sh |
| 64 | + npm run dev |
| 65 | + ``` |
| 66 | + |
| 67 | + |
| 68 | +### Note: |
| 69 | +Scripts like `db:generate` and `db:migrate` are defined in the `package.json` file already for your convenience. You can run them using `npm run <script-name>` as shown above. |
0 commit comments