-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Code-4-Community/scaffolding
- Loading branch information
Showing
12 changed files
with
348 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
### ℹ️ Issue | ||
|
||
Closes <issue> | ||
|
||
### 📝 Description | ||
|
||
Write a short summary of what you added. Why is it important? Any member of C4C should be able to read this and understand your contribution -- not just your team members. | ||
|
||
Briefly list the changes made to the code: | ||
1. Added support for this. | ||
2. And removed redunant use of that. | ||
3. Also this was included for reasons. | ||
|
||
### ✔️ Verification | ||
|
||
What steps did you take to verify your changes work? These should be clear enough for someone to be able to clone the branch and follow the steps themselves. | ||
|
||
Provide screenshots of any new components, styling changes, or pages. | ||
|
||
### 🏕️ (Optional) Future Work / Notes | ||
|
||
Did you notice anything ugly during the course of this ticket? Any bugs, design challenges, or unexpected behavior? Write it down so we can clean it up in a future ticket! |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// TODO: Probably want these types to be available to both the frontend and backend in a "common" folder | ||
export enum Status { | ||
MEMBER = 'Member', | ||
RECRUITER = 'Recruiter', | ||
ADMIN = 'Admin', | ||
ALUMNI = 'Alumni', | ||
APPLICANT = 'Applicant', | ||
} | ||
|
||
export enum Team { | ||
SFTT = 'Speak For The Trees', | ||
CONSTELLATION = 'Constellation', | ||
JPAL = 'J-PAL', | ||
BREAKTIME = 'Breaktime', | ||
GI = 'Green Infrastructure', | ||
CI = 'Core Infrastructure', | ||
EBOARD = 'E-Board', | ||
} | ||
|
||
export enum Role { | ||
DIRECTOR_OF_ENGINEERING = 'Director of Engineering', | ||
DIRECTOR_OF_PRODUCT = 'Director of Product', | ||
DIRECTOR_OF_FINANCE = 'Director of Finance', | ||
DIRECTOR_OF_MARKETING = 'Director of Marketing', | ||
DIRECTOR_OF_RECRUITMENT = 'Director of Recruitment', | ||
DIRECTOR_OF_OPERATIONS = 'Director of Operations', | ||
DIRECTOR_OF_EVENTS = 'Director of Events', | ||
DIRECTOR_OF_DESIGN = 'Director of Design', | ||
PRODUCT_MANAGER = 'Product Manager', | ||
PRODUCT_DESIGNER = 'Product Designer', | ||
TECH_LEAD = 'Technical Lead', | ||
DEVELOPER = 'Developer', | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Status, Role, Team } from './types'; | ||
import { | ||
IsEmail, | ||
IsOptional, | ||
IsEnum, | ||
IsArray, | ||
ArrayMinSize, | ||
ArrayUnique, | ||
IsUrl, | ||
} from 'class-validator'; | ||
|
||
export class UpdateUserDTO { | ||
@IsOptional() | ||
@IsEnum(Status) | ||
status?: Status; | ||
|
||
@IsOptional() | ||
@IsEmail() | ||
email?: string; | ||
|
||
@IsOptional() | ||
profilePicture?: string; | ||
|
||
@IsOptional() | ||
@IsUrl({ | ||
protocols: ['https'], | ||
require_protocol: true, | ||
host_whitelist: ['www.linkedin.com'], | ||
}) | ||
linkedin?: string; | ||
|
||
@IsOptional() | ||
@IsUrl({ | ||
protocols: ['https'], | ||
require_protocol: true, | ||
host_whitelist: ['github.com'], | ||
}) | ||
github?: string; | ||
|
||
@IsOptional() | ||
@IsEnum(Team) | ||
team?: Team; | ||
|
||
@IsOptional() | ||
@IsArray() | ||
@ArrayMinSize(1) | ||
@ArrayUnique() | ||
@IsEnum(Role, { each: true }) | ||
role?: Role[]; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { IsEmail, IsUrl } from 'class-validator'; | ||
import { Entity, Column } from 'typeorm'; | ||
import { Role, Status, Team } from './types'; | ||
|
||
@Entity() | ||
export class User { | ||
@Column({ primary: true }) | ||
userId: number; | ||
|
||
@Column() | ||
status: Status; | ||
|
||
@Column() | ||
firstName: string; | ||
|
||
@Column() | ||
lastName: string; | ||
|
||
@Column() | ||
@IsEmail() | ||
email: string; | ||
|
||
@Column() | ||
profilePicture: string | null; | ||
|
||
@Column() | ||
@IsUrl() | ||
linkedin: string | null; | ||
|
||
@Column() | ||
github: string | null; | ||
|
||
@Column() | ||
team: Team | null; | ||
|
||
@Column() | ||
role: Role[] | null; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
DefaultValuePipe, | ||
ParseBoolPipe, | ||
ParseIntPipe, | ||
Query, | ||
Body, | ||
Controller, | ||
Get, | ||
Param, | ||
Patch, | ||
} from '@nestjs/common'; | ||
import { UpdateUserDTO } from './update-user.dto'; | ||
import { UsersService } from './users.service'; | ||
import { User } from './user.entity'; | ||
|
||
@Controller('users') | ||
export class UsersController { | ||
constructor(private readonly usersService: UsersService) {} | ||
|
||
@Get() | ||
getAllMembers( | ||
@Query('getAllMembers', new DefaultValuePipe(false), ParseBoolPipe) | ||
getAllMembers: boolean, | ||
) { | ||
return this.usersService.findAll(getAllMembers); | ||
} | ||
|
||
@Get('/:userId') | ||
getUser(@Param('userId', ParseIntPipe) userId: number) { | ||
return this.usersService.findOne(userId); | ||
} | ||
|
||
@Patch(':userId') | ||
async updateUser( | ||
@Body() updateUserDTO: UpdateUserDTO, | ||
@Param('userId', ParseIntPipe) userId: number, | ||
): Promise<User> { | ||
return this.usersService.updateUser(updateUserDTO, userId); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
|
||
import { UsersService } from './users.service'; | ||
import { UsersController } from './users.controller'; | ||
import { User } from './user.entity'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([User])], | ||
providers: [UsersService], | ||
controllers: [UsersController], | ||
}) | ||
export class UsersModule {} |
Oops, something went wrong.