Skip to content

Commit 239a44d

Browse files
authored
Merge pull request #40 from aoda-zhang/develop
implement cookie-based authentication with refresh token mechanism
2 parents 773db41 + d217a50 commit 239a44d

48 files changed

Lines changed: 587 additions & 184 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,4 @@ tsconfig.tsbuildinfo
128128
.turbo
129129

130130
# prisma dev runtime
131-
**/prisma/generated/**
132-
**/prisma/**/generated/**
131+
**/prisma/**/client**

README.MD

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# 🐾 PawHaven - Animal Rescue Platform
1+
[English](./README.MD) | [中文](./READMECN.MD)
22

3-
[English](./README.md) | [中文](./READMECN.md)
3+
# 🐾 PawHaven - Animal Rescue Platform
44

55
![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)
66
![React](https://img.shields.io/badge/React-20232a?logo=react&logoColor=61dafb)
@@ -46,14 +46,14 @@ In addition to the application itself, PawHaven also serves as a **practice of m
4646

4747
# 🚀 Tech Stack
4848

49-
| Layer | Technology |
50-
|------|------------|
51-
| Frontend | React, TypeScript, React Query, React Hook Form |
52-
| Backend | NestJS, Node.js |
53-
| Architecture | Microservices, Monorepo |
54-
| Package Management | pnpm workspace |
55-
| Code Quality | ESLint, Prettier, Husky |
56-
| CI/CD | GitHub Actions |
49+
| Layer | Technology |
50+
| ------------------ | ----------------------------------------------- |
51+
| Frontend | React, TypeScript, React Query, React Hook Form |
52+
| Backend | NestJS, Node.js |
53+
| Architecture | Microservices, Monorepo |
54+
| Package Management | pnpm workspace |
55+
| Code Quality | ESLint, Prettier, Husky |
56+
| CI/CD | GitHub Actions |
5757

5858
---
5959

READMECN.MD

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# 🐾 PawHaven - 动物救援平台
2-
3-
[English](./README.md) | [中文](./READMECN.md)
1+
[English](./README.MD) | [中文](./READMECN.MD)
42

53
![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)
64
![React](https://img.shields.io/badge/React-20232a?logo=react&logoColor=61dafb)
@@ -46,14 +44,14 @@
4644

4745
# 🚀 技术栈
4846

49-
| 层级 | 技术 |
50-
|------|------|
51-
| 前端 | React, TypeScript, React Query, React Hook Form |
52-
| 后端 | NestJS, Node.js |
53-
| 架构 | 微服务, Monorepo |
54-
| 包管理 | pnpm workspace |
55-
| 代码规范 | ESLint, Prettier, Husky |
56-
| CI/CD | GitHub Actions |
47+
| 层级 | 技术 |
48+
| -------- | ----------------------------------------------- |
49+
| 前端 | React, TypeScript, React Query, React Hook Form |
50+
| 后端 | NestJS, Node.js |
51+
| 架构 | 微服务, Monorepo |
52+
| 包管理 | pnpm workspace |
53+
| 代码规范 | ESLint, Prettier, Husky |
54+
| CI/CD | GitHub Actions |
5755

5856
---
5957

apps/backend/auth-service/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
"@nestjs/axios": "^4.0.1",
2020
"@nestjs/common": "^11.1.6",
2121
"@nestjs/config": "^4.0.2",
22-
"@pawhaven/eslint-config": "workspace:*",
23-
"@pawhaven/backend-core": "workspace:*",
24-
"@pawhaven/tsconfig": "workspace:*",
25-
"@pawhaven/shared": "workspace:*",
2622
"@nestjs/core": "^11.1.6",
2723
"@nestjs/jwt": "^11.0.1",
2824
"@nestjs/microservices": "^11.1.6",
@@ -31,6 +27,11 @@
3127
"@nestjs/platform-express": "^11.1.6",
3228
"@nestjs/terminus": "^11.0.0",
3329
"@nestjs/throttler": "^6.4.0",
30+
"@pawhaven/backend-core": "workspace:*",
31+
"@pawhaven/eslint-config": "workspace:*",
32+
"@pawhaven/shared": "workspace:*",
33+
"@pawhaven/tsconfig": "workspace:*",
34+
"@prisma/client": "^6.19.1",
3435
"@types/bcrypt": "^6.0.0",
3536
"@types/express": "^5.0.3",
3637
"@types/passport-jwt": "^4.0.1",
@@ -45,28 +46,28 @@
4546
"dotenv": "^17.2.3",
4647
"helmet": "^8.1.0",
4748
"mongoose": "^8.19.1",
49+
"nestjs-zod": "^5.1.1",
4850
"passport": "^0.7.0",
4951
"passport-jwt": "^4.0.1",
5052
"passport-local": "^1.0.0",
5153
"reflect-metadata": "^0.2.2",
52-
"@prisma/client": "^6.19.1",
5354
"rxjs": "^7.8.2",
5455
"uuid": "^13.0.0",
55-
"zod": "^4.3.6",
56-
"nestjs-zod": "^5.1.1"
56+
"zod": "^4.3.6"
5757
},
5858
"devDependencies": {
5959
"@nestjs/cli": "^11.0.10",
6060
"@nestjs/schematics": "^11.0.9",
6161
"@nestjs/testing": "^11.1.6",
62+
"@types/cookie-parser": "^1.4.10",
6263
"@types/crypto-js": "^4.2.2",
6364
"@types/jest": "^30.0.0",
6465
"@types/js-yaml": "^4.0.9",
6566
"@types/node": "^24.7.1",
6667
"@types/passport-local": "^1.0.38",
6768
"@types/supertest": "^6.0.3",
68-
"source-map-support": "^0.5.21",
6969
"prisma": "^6.19.1",
70+
"source-map-support": "^0.5.21",
7071
"supertest": "^7.1.4",
7172
"ts-loader": "^9.5.4",
7273
"ts-node": "^10.9.2",

apps/backend/auth-service/src/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { join } from 'path';
22

33
import { AuthModule } from '@modules/Auth/auth.module';
44
import { Module } from '@nestjs/common';
5-
import { PrismaClient as MongoPrismaClient } from '@prisma/client';
65
import { SharedModule, SharedModuleFeatures } from '@pawhaven/backend-core';
76
import {
87
databaseEngines,
98
microServiceNames,
109
} from '@pawhaven/backend-core/constants';
10+
import { PrismaClient } from '@prismaClient';
1111

1212
@Module({
1313
imports: [
@@ -22,7 +22,7 @@ import {
2222
module: SharedModuleFeatures.PrismaModule,
2323
options: {
2424
databaseEngine: databaseEngines.mongodb,
25-
Client: MongoPrismaClient,
25+
Client: PrismaClient,
2626
},
2727
},
2828
{

apps/backend/auth-service/src/config/dev/env/index.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ cors:
4040
- OPTIONS
4141
auth:
4242
jwtSecret: ${JWT_SECRET}
43-
jwtExpiresIn: 3600
43+
jwtExpiresIn: 1800
44+
refreshTokenExpiresIn: 604800

apps/backend/auth-service/src/config/prod/env/index.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ cors:
4141

4242
auth:
4343
jwtSecret: ${JWT_SECRET}
44-
jwtExpiresIn: 3600
44+
jwtExpiresIn: 1800
45+
refreshTokenExpiresIn: 604800

apps/backend/auth-service/src/config/test/env/index.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ cors:
4141

4242
auth:
4343
jwtSecret: ${JWT_SECRET}
44-
jwtExpiresIn: 3600
44+
jwtExpiresIn: 1800
45+
refreshTokenExpiresIn: 604800

apps/backend/auth-service/src/config/uat/env/index.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ cors:
4141

4242
auth:
4343
jwtSecret: ${JWT_SECRET}
44-
jwtExpiresIn: 3600
44+
jwtExpiresIn: 1800
45+
refreshTokenExpiresIn: 604800

apps/backend/auth-service/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { NestExpressApplication } from '@nestjs/platform-express';
22
import { NestFactory } from '@nestjs/core';
33
import { ConfigService } from '@nestjs/config';
44
import { Logger } from '@nestjs/common';
5+
import cookieParser from 'cookie-parser';
56

67
import { AppModule } from './app.module';
78

@@ -11,6 +12,7 @@ async function bootstrap(): Promise<void> {
1112
bufferLogs: true,
1213
});
1314
const configService = app.get(ConfigService) as ConfigService;
15+
app.use(cookieParser());
1416
app.setGlobalPrefix(configService.get('http.prefix')!);
1517
const port = configService.get('http.port');
1618

0 commit comments

Comments
 (0)