Initial commit: Meshkee CMS API

NestJS backend with Prisma, Docker Compose for Postgres/Redis, and deploy docs for the production VM.
This commit is contained in:
Ali Reza
2026-07-21 17:52:36 +03:30
commit bb59d5e9ba
254 changed files with 37031 additions and 0 deletions
+108
View File
@@ -0,0 +1,108 @@
import {
Body,
Controller,
Delete,
Get,
Param,
Patch,
Post,
UseGuards,
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { CurrentUser } from './decorators/current-user.decorator';
import { ChangePasswordDto } from './dto/change-password.dto';
import { LoginDto } from './dto/login.dto';
import { RefreshTokenDto } from './dto/refresh-token.dto';
import { RegisterDto } from './dto/register.dto';
import { SendOtpDto } from './dto/send-otp.dto';
import { UpdateProfileDto } from './dto/update-profile.dto';
import { UpsertUserAddressDto } from './dto/upsert-user-address.dto';
import { VerifyOtpDto } from './dto/verify-otp.dto';
import { JwtAuthGuard } from './guards/jwt-auth.guard';
import { AuthUser } from './auth.types';
import { UserAddressesService } from './user-addresses.service';
@Controller('auth')
export class AuthController {
constructor(
private readonly authService: AuthService,
private readonly userAddresses: UserAddressesService,
) {}
@Post('register')
register(@Body() dto: RegisterDto) {
return this.authService.register(dto);
}
@Post('login')
login(@Body() dto: LoginDto) {
return this.authService.login(dto);
}
@Post('refresh')
refresh(@Body() dto: RefreshTokenDto) {
return this.authService.refresh(dto.refreshToken);
}
@Get('me')
@UseGuards(JwtAuthGuard)
me(@CurrentUser() user: AuthUser) {
return this.authService.me(user);
}
@Patch('profile')
@UseGuards(JwtAuthGuard)
updateProfile(@CurrentUser() user: AuthUser, @Body() dto: UpdateProfileDto) {
return this.authService.updateProfile(user, dto);
}
@Post('change-password')
@UseGuards(JwtAuthGuard)
changePassword(@CurrentUser() user: AuthUser, @Body() dto: ChangePasswordDto) {
return this.authService.changePassword(user, dto);
}
@Post('send-otp')
sendOtp(@Body() dto: SendOtpDto) {
return this.authService.sendOtp(dto.cellNumber);
}
@Post('verify-otp')
verifyOtp(@Body() dto: VerifyOtpDto) {
return this.authService.verifyOtp(dto.cellNumber, dto.code);
}
@Get('addresses')
@UseGuards(JwtAuthGuard)
listAddresses(@CurrentUser() user: AuthUser) {
return this.userAddresses.list(user);
}
@Post('addresses')
@UseGuards(JwtAuthGuard)
createAddress(
@CurrentUser() user: AuthUser,
@Body() dto: UpsertUserAddressDto,
) {
return this.userAddresses.create(user, dto);
}
@Patch('addresses/:addressId')
@UseGuards(JwtAuthGuard)
updateAddress(
@CurrentUser() user: AuthUser,
@Param('addressId') addressId: string,
@Body() dto: UpsertUserAddressDto,
) {
return this.userAddresses.update(user, addressId, dto);
}
@Delete('addresses/:addressId')
@UseGuards(JwtAuthGuard)
removeAddress(
@CurrentUser() user: AuthUser,
@Param('addressId') addressId: string,
) {
return this.userAddresses.remove(user, addressId);
}
}