Conversation
lyudad
reviewed
Oct 11, 2025
| synchronize: true, | ||
| entities: globalEntities, | ||
| migrations: ['@src/database/migrations/*.ts', '@dist/database/migrations/*.js'], | ||
| })); No newline at end of file |
There was a problem hiding this comment.
better add evs validation, and show to user that he need to add env, instead of setup the default value
| @ApiOperation({ summary: 'Send magic link to email' }) | ||
| @ApiResponse({ status: 200, description: 'Magic link sent', type: Object }) | ||
| @ApiResponse({ status: 400, description: 'Invalid email' }) | ||
| async sendMagicLink(@Body() body: SendLinkDto) { |
| @ApiOperation({ summary: 'Verify magic link token' }) | ||
| @ApiResponse({ status: 200, description: 'Token verified', type: VerifyTokenResponseDto }) | ||
| @ApiResponse({ status: 401, description: 'Expired or invalid token' }) | ||
| async verifyToken(@Query('token') token: string, @Query('email') email: string) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Auth Module
Added AuthModule (auth.service.ts, auth.controller.ts, DTOs: send-link.dto.ts, verify-token-response.dto.ts).
Endpoints:
POST /auth/send-link — accepts { email: string }, stores user and token, sends a magic link.
GET /auth/verify?token=...&email=... — validates token, returns JWT or an error if expired.
Transactions added for creating/updating User and LoginToken.
Email validation via EMAIL_REGEX.
Database
Added entities: user.entity.ts, login-token.entity.ts.
Added migration AuthMigration-20251007122300.ts for users and login_tokens tables with indexes and foreign keys.
Updated example-global.entities.ts, database.config.js, typeorm.config.js.
Email
Configured Nodemailer with Gmail SMTP using .env (EMAIL_HOST, EMAIL_USER, EMAIL_PASSWORD).
Magic link built from FRONTEND_URL and UPLOAD_PATH in .env.
Swagger
Added documentation for /auth/send-link and /auth/verify with examples and error descriptions.
Dependencies
Installed nodemailer, uuid, @nestjs/jwt, class-transformer, and related types.
Working Functionality
Backend starts via npm run start:dev with no TypeScript errors.
Swagger available at http://localhost:3000/api/docs.
POST /auth/send-link:
saves email and token to DB,
sends email with valid link (e.g., http://localhost:5173/upload?token=...&email=...).
GET /auth/verify:
returns JWT if token is valid,
deletes token after verification,
returns 401 if expired.
Verified DB records in MySQL Workbench — data stored correctly.
esting
Backend launched with npm run start:dev.
Tested via Postman:
POST /auth/send-link with {email } — email successfully sent, data stored in DB;
Next Steps:
add POST request to /auth/send-link in useExampleWorkForm.ts;
implement /upload page with GET /auth/verify handling;