Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/api/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
})

return await this.auth(res, user.id)

Check warning on line 63 in apps/api/src/auth/auth.service.ts

View workflow job for this annotation

GitHub Actions / ci

Unsafe argument of type error typed assigned to a parameter of type `string`
}

async login(res: Response, dto: LoginRequestDto) {
Expand All @@ -80,13 +80,13 @@
throw new NotFoundException('Пользователь не найден')
}

const isPasswordValid = await verify(user.password, password)

Check warning on line 83 in apps/api/src/auth/auth.service.ts

View workflow job for this annotation

GitHub Actions / ci

Unsafe argument of type error typed assigned to a parameter of type `string`

if (!isPasswordValid) {
throw new NotFoundException('Пользователь не найден')
}

return await this.auth(res, user.id)

Check warning on line 89 in apps/api/src/auth/auth.service.ts

View workflow job for this annotation

GitHub Actions / ci

Unsafe argument of type error typed assigned to a parameter of type `string`
}

async refresh(req: Request, res: Response) {
Expand Down Expand Up @@ -118,7 +118,7 @@
throw new NotFoundException('Пользователь не найден')
}

return await this.auth(res, user.id)

Check warning on line 121 in apps/api/src/auth/auth.service.ts

View workflow job for this annotation

GitHub Actions / ci

Unsafe argument of type error typed assigned to a parameter of type `string`
}
}

Expand All @@ -132,7 +132,7 @@
}
}

this.setCookie(res, 'refreshToken', '', new Date(0), '/auth/refresh')
this.setCookie(res, 'refreshToken', '', new Date(0), '/')
this.setCookie(res, 'accessToken', '', new Date(0), '/')

return { message: 'Пользователь успешно вышел', success: true }
Expand Down Expand Up @@ -162,7 +162,7 @@
'refreshToken',
refreshToken,
new Date(Date.now() + parseTTLToMs(this.COOKIE_TTL)),
'/auth/refresh',
'/',
)

this.setCookie(
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function bootstrap() {

setupSwagger(app)

await app.listen(4000)
await app.listen(process.env.PORT ?? 3000)
}

void bootstrap()
5 changes: 3 additions & 2 deletions apps/web/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import { NextResponse, type NextRequest, type ProxyConfig } from 'next/server'
export function proxy(request: NextRequest) {
const { pathname, search } = request.nextUrl
const accessToken = !!request.cookies.get('accessToken')?.value
const refreshToken = !!request.cookies.get('refreshToken')?.value

if (!accessToken && isProtectedRoute(pathname)) {
if (!refreshToken && isProtectedRoute(pathname)) {
const url = new URL(ROUTES.login, request.url)
url.searchParams.set(ROUTE_QUERY_PARAMS.from, `${pathname}${search}`)
return NextResponse.redirect(url)
}

if (accessToken && isAuthRoute(pathname)) {
if ((accessToken || refreshToken) && isAuthRoute(pathname)) {
return NextResponse.redirect(new URL(ROUTES.teams, request.url))
}

Expand Down
4 changes: 2 additions & 2 deletions docs/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@

1. **Запустить Redis** — `pnpm docker:redis-up`
2. **Настройка валидации** — [validation/setup](../validation/setup.md)
3. **Swagger** — http://localhost:4000/api/docs
3. **Swagger** — http://localhost:3000/api/docs
4. **Prisma Studio** — `pnpm prisma:studio`

## Реализованные эндпоинты

Актуальный список с описанием запросов/ответов — в Swagger: http://localhost:4000/api/docs
Актуальный список с описанием запросов/ответов — в Swagger: http://localhost:3000/api/docs

### Аутентификация (JWT + Cookie)

Expand Down
6 changes: 3 additions & 3 deletions docs/backend/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

| URL | Описание |
| ---------------------------------- | ------------ |
| http://localhost:4000/api/docs | Swagger UI |
| http://localhost:4000/swagger.json | OpenAPI JSON |
| http://localhost:4000/swagger.yaml | OpenAPI YAML |
| http://localhost:3000/api/docs | Swagger UI |
| http://localhost:3000/swagger.json | OpenAPI JSON |
| http://localhost:3000/swagger.yaml | OpenAPI YAML |

## Установка зависимостей

Expand Down
4 changes: 2 additions & 2 deletions docs/work/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ pnpm dev

Приложение будет доступно:

- Frontend (Web): http://localhost:3000
- Backend (API): http://localhost:4000
- Frontend (Web): http://localhost:3001
- Backend (API): http://localhost:3000

## Полезные команды

Expand Down
2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dev": {
"cache": false,
"persistent": true,
"env": ["DATABASE_URL"]
"env": ["DATABASE_URL", "PORT"]
},
"build": {
"dependsOn": ["^build"],
Expand Down
Loading