Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/savareyhano/elysia-auth-old
Simple ElysiaJS authentication using jwt bearer token.
https://github.com/savareyhano/elysia-auth-old
access-token authentication bun elysia elysiajs jwt jwt-authentication jwt-bearer-tokens prisma refresh-token typescript
Last synced: about 2 months ago
JSON representation
Simple ElysiaJS authentication using jwt bearer token.
- Host: GitHub
- URL: https://github.com/savareyhano/elysia-auth-old
- Owner: savareyhano
- License: mit
- Created: 2024-07-11T14:23:09.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2024-07-13T00:04:30.000Z (6 months ago)
- Last Synced: 2024-08-27T20:07:38.127Z (4 months ago)
- Topics: access-token, authentication, bun, elysia, elysiajs, jwt, jwt-authentication, jwt-bearer-tokens, prisma, refresh-token, typescript
- Language: TypeScript
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elysia with Bun runtime
Simple ElysiaJS authentication using jwt bearer token.
File, folder, and code structure is inspired by [dicoding's 'Belajar Fundamental Aplikasi Back-End' repository.](https://github.com/dicodingacademy/a271-backend-menengah-labs)
## Prerequisite
- [Git](https://git-scm.com/downloads)
- [Bun](https://bun.sh/)## Getting Started
Clone the repository:
```bash
git clone https://github.com/savareyhano/elysia-auth.git
```Navigate to the project directory:
```
cd elysia-auth
```Create a `.env` file and configure it:
```bash
cp .env.example .env
```Install the dependencies:
```bash
bun install
```## Development
To start the development server run:
```bash
bun run dev
```Open http://localhost:3000/ with your browser to see the result.
## API
### Protected Endpoint
Endpoint:
`GET /protected`
Header:
```
Authorization: Bearer youraccesstokenhere
```### Register user
Endpoint:
`POST /api/users/register`
Payload:
```json
{
"username": "johndoe",
"password": "johndoe123"
}
```### Login user
Endpoint:
`POST /api/authentications/login`
Payload:
```json
{
"username": "johndoe",
"password": "johndoe123"
}
```### Refresh Token
Endpoint:
`POST /api/authentications/refresh-token`
Payload:
```json
{
"refreshToken": "yourrefreshtokenhere"
}
```