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
20 changes: 13 additions & 7 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
## Description

<!-- Describe your changes in detail -->

## Type of Change

<!-- Mark the relevant option with an [x] -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Test addition/improvement

## Checklist

<!-- Please ensure all items are checked before submitting -->
- [ ] I have run `npm run lint` and fixed any errors

- [ ] I have run `npm run build` successfully with no errors
- [ ] I have run `npm test` and all tests pass
- [ ] If I added new test files, they all pass
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code

## CI/CD Requirements

The following checks will run automatically on this PR:
1. ✅ **Lint Check** - Ensures code has no ESLint errors
2. ✅ **Build Check** - Ensures the project builds successfully
3. ✅ **Test Check** - Ensures all tests pass (including any new test files)

1. ✅ **Build Check** - Ensures the project builds successfully
2. ✅ **Test Check** - Ensures all tests pass (including any new test files)

## Screenshots (if applicable)

<!-- Add screenshots to help explain your changes -->

## Additional Notes
<!-- Add any other context about the PR here -->
## Closes

<!-- Close your PR here -->
9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
branches: [main, master, develop]

jobs:
lint-and-build:
name: Lint and Build Check
build:
name: Build Check
runs-on: ubuntu-latest

steps:
Expand All @@ -24,16 +24,13 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run ESLint (Check for errors)
run: npm run lint

- name: Build project
run: npm run build

test:
name: Test Check
runs-on: ubuntu-latest
needs: lint-and-build
needs: build

steps:
- name: Checkout code
Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,18 @@
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"rootDir": ".",
"testRegex": "test/.*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
"src/**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
"coverageDirectory": "coverage",
"testEnvironment": "node",
"moduleNameMapper": {
"^src/(.*)$": "<rootDir>/src/$1"
}
}
}
2 changes: 1 addition & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { ConfigModule } from '@nestjs/config';
import { DatabaseModule } from './database/database.module';
import { AuthModule } from './auth/auth.module';
import { UsersModule } from './users/users.module';
import { MailModule } from './modules/mail/mail.module';
import configuration from './database/config';
import { LoggerModule } from './logger/logger.module';
import { ProjectsModule } from './projects/projects.module';
import { MailModule } from './mail/mail.module';

@Module({
imports: [
Expand Down
123 changes: 0 additions & 123 deletions src/auth/README.md

This file was deleted.

22 changes: 14 additions & 8 deletions src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ import {
ApiUnauthorizedResponse,
ApiNotFoundResponse,
} from '@nestjs/swagger';
import { AuthService } from './auth.service';
import { RegisterDto } from './dtos/register.dto';
import { LoginDto } from './dtos/login.dto';
import { VerifyEmailDto } from './dtos/verify-email.dto';
import { ResendVerificationDto } from './dtos/resend-verification.dto';
import { RefreshTokenDto } from './dtos/refresh-token.dto';
import { AuthResponseDto } from './dtos/auth-response.dto';
import { RegisterDto } from './dto/register.dto';
import { LoginDto } from './dto/login.dto';
import { VerifyEmailDto } from './dto/verify-email.dto';
import { ResendVerificationDto } from './dto/resend-verification.dto';
import { RefreshTokenDto } from './dto/refresh-token.dto';
import { AuthResponseDto } from './dto/auth-response.dto';
import { AuthService } from './providers/auth.service';

@ApiTags('auth')
@ApiBearerAuth()
@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}

//_____________________Endpoint to register a new user
@Post('register')
@ApiOperation({ summary: 'Register a new user' })
@ApiCreatedResponse({
Expand All @@ -47,6 +48,7 @@ export class AuthController {
return this.authService.register(registerDto);
}

//_________________________ Endpoint to login with email and password
@Post('login')
@ApiOperation({ summary: 'Login with email and password' })
@ApiOkResponse({
Expand All @@ -63,8 +65,9 @@ export class AuthController {
return this.authService.login(loginDto, req);
}

@UseGuards(AuthGuard('jwt'))
//_________________________ Endpoint to get current user profile (JWT required)
@Get('profile')
@UseGuards(AuthGuard('jwt'))
@ApiOperation({ summary: 'Get current user profile (JWT required)' })
@ApiOkResponse({
description: 'Profile retrieved successfully',
Expand All @@ -77,6 +80,7 @@ export class AuthController {
return req.user;
}

//_________________________ Endpoint to verify email with token
@Post('verify-email')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Verify email with token' })
Expand All @@ -92,6 +96,7 @@ export class AuthController {
return this.authService.verifyEmail(verifyEmailDto);
}

//_________________________ Endpoint to resend email verification
@Post('resend-verification')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Resend email verification' })
Expand All @@ -107,6 +112,7 @@ export class AuthController {
return this.authService.resendVerification(resendVerificationDto);
}

//_________________________ Endpoint to refresh access token using refresh token (token rotation)
@Post('refresh')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Refresh access token' })
Expand Down
6 changes: 3 additions & 3 deletions src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
RequestMethod,
} from '@nestjs/common';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
Expand All @@ -14,8 +13,9 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from '../users/entities/user.entity';

import { JwtStrategy } from './strategies/jwt.strategy';
import { TokenValidationMiddleware } from './middleware/token-validation.middleware';
import { JwtAuthGuard } from './guard/jwt-auth.guard';
import { TokenValidationMiddleware } from '../common/middleware/token-validation.middleware';
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
import { AuthService } from './providers/auth.service';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { UserRole } from '../../users/entities/user.entity';
import { UserRole } from 'src/common/enums/user-role.enum';

export class UserDto {
@ApiProperty({
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Matches,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { UserRole } from '../../users/entities/user.entity';
import { UserRole } from 'src/common/enums/user-role.enum';

export class RegisterDto {
@ApiProperty({
Expand Down
File renamed without changes.
Loading