81 lines
814 B
Markdown
81 lines
814 B
Markdown
# backend
|
|
|
|
## Install
|
|
|
|
```bash
|
|
bun install
|
|
```
|
|
|
|
## Environment
|
|
|
|
Create a `.env` file:
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
|
|
Set:
|
|
|
|
```bash
|
|
DATABASE_URL=postgres://username:password@localhost:5432/database_name
|
|
JWT_SECRET=replace_with_a_long_random_secret
|
|
JWT_EXPIRES_IN=7d
|
|
PORT=3000
|
|
```
|
|
|
|
## Run app
|
|
|
|
```bash
|
|
bun run dev
|
|
```
|
|
|
|
## Drizzle ORM
|
|
|
|
Generate migrations:
|
|
|
|
```bash
|
|
bun run db:generate
|
|
```
|
|
|
|
Apply migrations:
|
|
|
|
```bash
|
|
bun run db:migrate
|
|
```
|
|
|
|
Open Drizzle Studio:
|
|
|
|
```bash
|
|
bun run db:studio
|
|
```
|
|
|
|
## Auth API
|
|
|
|
Register:
|
|
|
|
```bash
|
|
POST /auth/register
|
|
{
|
|
"email": "user@example.com",
|
|
"password": "password123",
|
|
"name": "User Name"
|
|
}
|
|
```
|
|
|
|
Login:
|
|
|
|
```bash
|
|
POST /auth/login
|
|
{
|
|
"email": "user@example.com",
|
|
"password": "password123"
|
|
}
|
|
```
|
|
|
|
Get current user:
|
|
|
|
```bash
|
|
GET /auth/me
|
|
Authorization: Bearer <token>
|
|
```
|