Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: verify email #249

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion src/middlewares/auth.middleware.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';
import { Response, NextFunction } from 'express';
import * as jwt from 'express-jwt';
import { expressJwtSecret } from 'jwks-rsa';
import { Request } from '🧙‍♂️/types/request';
import Config from '../config';

const secret = expressJwtSecret({
Expand Down
2 changes: 1 addition & 1 deletion src/modules/admin/__tests__/mentors.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { UnauthorizedException, BadRequestException } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { Request } from '🧙‍♂️/types/request';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, what's with the 🧙‍♂️ in the filepath?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was exciting to use tsconfig/paths for the first time :)

"paths": {
"🧙‍♂️/types/*": ["src/types/*"]
}

🧙‍♂️ is our paths root

import { MentorsController } from '../../mentors/mentors.controller';
import { UsersService } from '../../common/users.service';
import { EmailService } from '../../email/email.service';
Expand All @@ -8,7 +9,6 @@ import { User } from '../../common/interfaces/user.interface';
import { Application } from '../../common/interfaces/application.interface';
import { MentorFiltersDto } from '../../common/dto/mentorfilters.dto';
import { ApplicationDto } from '../../common/dto/application.dto';
import { Request } from 'express';

class ServiceMock {}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/admin/admin.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Req,
} from '@nestjs/common';
import { ApiOperation, ApiUseTags } from '@nestjs/swagger';
import { Request } from 'express';
import { Request } from '🧙‍♂️/types/request';
import { MentorsService } from '../common/mentors.service';
import { MentorshipsService } from '../mentorships/mentorships.service';
import { EmailService } from '../email/email.service';
Expand Down
2 changes: 1 addition & 1 deletion src/modules/lists/__tests__/favorites.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BadRequestException, UnauthorizedException } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { Request } from 'express';
import { Request } from '🧙‍♂️/types/request';
import { FavoritesController } from '../favorites.controller';
import { ListsService } from '../lists.service';
import { List } from '../interfaces/list.interface';
Expand Down
2 changes: 1 addition & 1 deletion src/modules/lists/__tests__/lists.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BadRequestException, UnauthorizedException } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { Request } from 'express';
import { Request } from '🧙‍♂️/types/request';
import { ListsController } from '../lists.controller';
import { ListsService } from '../lists.service';
import { List } from '../interfaces/list.interface';
Expand Down
6 changes: 3 additions & 3 deletions src/modules/lists/favorites.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ValidationPipe,
} from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiUseTags } from '@nestjs/swagger';
import { Request } from 'express';
import { Request } from '🧙‍♂️/types/request';
import { Role, User } from '../common/interfaces/user.interface';
import { List } from './interfaces/list.interface';
import { UsersService } from '../common/users.service';
Expand Down Expand Up @@ -101,11 +101,11 @@ export class FavoritesController {
} else {
let listDto: ListDto;

if (list.mentors.find(item => item._id.equals(mentor._id))) {
if (list.mentors.find((item) => item._id.equals(mentor._id))) {
// If the mentor exist in the list we need to remove it
listDto = new ListDto({
_id: list._id,
mentors: list.mentors.filter(item => !item._id.equals(mentor._id)),
mentors: list.mentors.filter((item) => !item._id.equals(mentor._id)),
});
} else {
// If the mentor doesn't exist in the list we need to add it
Expand Down
2 changes: 1 addition & 1 deletion src/modules/lists/lists.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Put,
} from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiUseTags } from '@nestjs/swagger';
import { Request } from 'express';
import { Request } from '🧙‍♂️/types/request';
import { Role, User } from '../common/interfaces/user.interface';
import { List } from './interfaces/list.interface';
import { UsersService } from '../common/users.service';
Expand Down
1 change: 1 addition & 0 deletions src/modules/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { ListsService } from '../lists/lists.service';
import { filterImages } from '../../utils/mimes';
import { MentorshipsService } from '../mentorships/mentorships.service';
import { Status } from '../mentorships/interfaces/mentorship.interface';
import { AccessTokenUser } from '🧙‍♂️/types/request';

@ApiUseTags('/users')
@ApiBearerAuth()
Expand Down
8 changes: 4 additions & 4 deletions src/utils/request.d.ts → src/types/request.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Request as ExpressReqeust } from 'express';

interface AccessTokenUser {
iss: string;
sub: string;
Expand All @@ -10,8 +12,6 @@ interface AccessTokenUser {
email_verified: boolean;
}

declare module 'express-serve-static-core' {
interface Request {
user?: AccessTokenUser;
}
export interface Request extends ExpressReqeust {
user?: AccessTokenUser;
}
11 changes: 9 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"resolveJsonModule": true
"resolveJsonModule": true,
"skipLibCheck": true,
"paths": {
"🧙‍♂️/types/*": ["src/types/*"]
}
},
"include": [
"src/**/*"
],
"files": [
"src/main.ts",
"src/utils/request.d.ts"
"src/types/request.d.ts"
],
"exclude": ["node_modules"]
}