Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zckyachmd/hono-auth
Hono-Auth is a lightweight authentication boilerplate created with Hono.js and Bun. It offers essential features and functionality for building secure and efficient web applications.
https://github.com/zckyachmd/hono-auth
auth bun honojs jwt open-api prisma-orm swagger-api typescript
Last synced: 23 days ago
JSON representation
Hono-Auth is a lightweight authentication boilerplate created with Hono.js and Bun. It offers essential features and functionality for building secure and efficient web applications.
- Host: GitHub
- URL: https://github.com/zckyachmd/hono-auth
- Owner: zckyachmd
- License: mit
- Created: 2024-09-08T07:11:32.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-09-15T11:12:42.000Z (about 2 months ago)
- Last Synced: 2024-10-14T03:01:29.925Z (23 days ago)
- Topics: auth, bun, honojs, jwt, open-api, prisma-orm, swagger-api, typescript
- Language: TypeScript
- Homepage:
- Size: 27.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Hono Auth
**Hono-Auth** is a simple authentication boilerplate built with Hono.js using Bun and TypeScript, designed to provide essential auth functionality. This project includes four key authentication endpoints and leverages Prisma ORM for database management, Zod for validation, and Swagger UI for API documentation.
## Features
- User Authentication: Includes user registration, login, logout, and token refresh.
- Prisma ORM: Simplified database operations.
- Zod Validation: Schema validation for secure data handling.
- Swagger UI: Auto-generated API docs for easy testing and integration.## Tech Stack (Framework & Libraries)
- Hono.js (Bun & TypeScript)
- Prisma ORM (PostgreSQL)
- Swagger UI (OpenAPI)
- Zod (Data Validation)## Endpoints
| Endpoint | Method | Description |
| ------------------- | ------ | -------------------- |
| /auth/register | POST | Register a new user |
| /auth/login | POST | Log in a user |
| /auth/refresh-token | POST | Refresh access token |
| /auth/logout | POST | Log out a user |## Setup and Usage
Click to expand
1. Clone the repository and install dependencies:```bash
git clone https://github.com/zckyachmd/hono-auth.git
cd hono-auth
bun install
```2. Create a `.env` file in the root directory:
```bash
cp .env.example .env
nano .env # Edit the variables as needed (see below)#... (.env)
DATABASE_URL=postgresql://user:password@localhost:5432/database?schema=public
JWT_SECRET=your-secret-token
SALT_ROUNDS=10 # Number of rounds for password hashing
```3. Migrate the database:
```bash
bun prisma migrate dev
```4. Start the server:
```bash
bun run dev# Open http://localhost:3000/ui in your browser
```
## Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for more information.