-
Notifications
You must be signed in to change notification settings - Fork 2
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
Members #5
Open
LuisFernandoL
wants to merge
4
commits into
Projeto-FrontEnd-Fusion:main
Choose a base branch
from
LuisFernandoL:members
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Members #5
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
import { memberService } from "@/api/member/memberService"; | ||
|
||
import { handleServiceResponse } from "@/common/utils/httpHandlers"; | ||
import type { Request, RequestHandler, Response } from "express"; | ||
|
||
class MemberController { | ||
public createMember: RequestHandler = async (req: Request, res: Response) => { | ||
const serviceResponse = await memberService.create(req.body); | ||
return handleServiceResponse(serviceResponse, res); | ||
}; | ||
|
||
public getMembers: RequestHandler = async (req: Request, res: Response) => { | ||
const ServerResponse = await memberService.findAll(); | ||
return handleServiceResponse(ServerResponse, res); | ||
}; | ||
|
||
public getMember: RequestHandler = async (req: Request, res: Response) => { | ||
const id = Number.parseInt(req.params.id, 10); | ||
const ServiceResponse = await memberService.findById(id); | ||
return handleServiceResponse(ServiceResponse, res); | ||
}; | ||
|
||
public updateMember: RequestHandler = async (req: Request, res: Response) => { | ||
const id = Number.parseInt(req.params.id, 10); | ||
const ServiceResponse = await memberService.update(id, req.body); | ||
return handleServiceResponse(ServiceResponse, res); | ||
}; | ||
|
||
public deleteMember: RequestHandler = async (req: Request, res: Response) => { | ||
const id = Number.parseInt(req.params.id, 10); | ||
const serviceResponse = await memberService.delete(id); | ||
return handleServiceResponse(serviceResponse, res); | ||
}; | ||
} | ||
|
||
export const memberController = new MemberController(); |
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,109 @@ | ||
import { commonValidations, commonValidationsMembers } from "@/common/utils/commonValidation"; | ||
import { z } from "zod"; | ||
|
||
export type Member = z.infer<typeof MemberSchema>; | ||
export const MemberSchema = z.object({ | ||
id: z.number(), | ||
name: z.string().max(50), | ||
professional_profile_url: z.array( | ||
z.object({ | ||
platform: z.string().max(50), | ||
url: z.string().url(), | ||
}), | ||
), | ||
stack: z.enum(["frontend", "backend", "full-stack", "UX Designer"]), | ||
community_level: z.string().max(50), | ||
current_squad: z.string().max(50), | ||
skills: z.array(z.string()), | ||
projects: z.array( | ||
z.object({ | ||
project_cover: z.string(), | ||
project_name: z.string().max(50), | ||
description: z.string().max(500), | ||
technologies_used: z.array(z.string()), | ||
project_url: z.string().url(), | ||
}), | ||
), | ||
softskills: z.array(z.string()), | ||
}); | ||
|
||
export type CreateMemberDto = z.infer<typeof CreateMemberDtoSchema>; | ||
export const CreateMemberDtoSchema = z.object({ | ||
name: z.string().max(50), | ||
professional_profile_url: z.array( | ||
z.object({ | ||
platform: z.string().max(50), | ||
url: z.string().url(), | ||
}), | ||
), | ||
stack: z.enum(["frontend", "backend", "full-stack", "UX Designer"]), | ||
community_level: z.string().max(50), | ||
current_squad: z.string().max(50), | ||
skills: z.array(z.string()), | ||
projects: z.array( | ||
z.object({ | ||
project_cover: z.string(), | ||
project_name: z.string().max(50), | ||
description: z.string().max(500), | ||
technologies_used: z.array(z.string()), | ||
project_url: z.string().url(), | ||
}), | ||
), | ||
softskills: z.array(z.string()), | ||
}); | ||
|
||
export type UpdateMemberDto = z.infer<typeof UpdateMemberDtoSchema>; | ||
export const UpdateMemberDtoSchema = z.object({ | ||
name: z.string().max(50), | ||
professional_profile_url: z.array( | ||
z.object({ | ||
platform: z.string().max(50), | ||
url: z.string().url(), | ||
}), | ||
), | ||
stack: z.enum(["frontend", "backend", "full-stack", "UX Designer"]), | ||
community_level: z.string().max(50), | ||
current_squad: z.string().max(50), | ||
skills: z.array(z.string()), | ||
projects: z.array( | ||
z.object({ | ||
project_cover: z.string(), | ||
project_name: z.string().max(50), | ||
description: z.string().max(500), | ||
technologies_used: z.array(z.string()), | ||
project_url: z.string().url(), | ||
}), | ||
), | ||
softskills: z.array(z.string()), | ||
}); | ||
|
||
export const CreateMemberSchema = z.object({ | ||
body: z.object({ | ||
name: commonValidationsMembers.name, | ||
professional_profile_url: commonValidationsMembers.professional_profile_url, | ||
stack: commonValidationsMembers.stack, | ||
community_level: commonValidationsMembers.community_level, | ||
current_squad: commonValidationsMembers.current_squad, | ||
skills: commonValidationsMembers.skills, | ||
projects: commonValidationsMembers.projects, | ||
softskills: commonValidationsMembers.softskills, | ||
}), | ||
}); | ||
|
||
export const GetMemberSchema = z.object({ | ||
params: z.object({ id: commonValidationsMembers.id }), | ||
}); | ||
|
||
export const UpdateMemberSchema = z.object({ | ||
params: z.object({ id: commonValidationsMembers.id }), | ||
body: z.object({ | ||
name: commonValidationsMembers.name, | ||
professional_profile_url: commonValidationsMembers.professional_profile_url, | ||
stack: commonValidationsMembers.stack, | ||
community_level: commonValidationsMembers.community_level, | ||
current_squad: commonValidationsMembers.current_squad, | ||
skills: commonValidationsMembers.skills, | ||
projects: commonValidationsMembers.projects, | ||
softskills: commonValidationsMembers.softskills, | ||
}), | ||
}); |
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,91 @@ | ||
import type { CreateMemberDto, Member, UpdateMemberDto } from "@/api/member/memberModel"; | ||
|
||
export let members: Member[] = [ | ||
{ | ||
id: 1, | ||
name: "Alice", | ||
professional_profile_url: [ | ||
{ platform: "GitHub", url: "<https://github.com/johndoe>" }, | ||
{ platform: "LinkedIn", url: "<https://linkedin.com/in/johndoe>" }, | ||
], | ||
stack: "backend", | ||
community_level: "code wizard", | ||
current_squad: "X-mens", | ||
skills: ["HTML", "CSS", "JavaScript", "React", "Node.js", "Git", "Docker"], | ||
projects: [ | ||
{ | ||
project_cover: "https://project1.pg", | ||
project_name: "Personal Portfolio", | ||
description: "A personal portfolio website built with React and hosted on GitHub.", | ||
technologies_used: ["React", "CSS", "JavaScript"], | ||
project_url: "<https://github.com/johndoe/portfolio>", | ||
}, | ||
{ | ||
project_cover: "https://project1.pg", | ||
project_name: "E-commerce Website", | ||
description: "An online store platform with payment integration, built with Node.js and MongoDB.", | ||
technologies_used: ["Node.js", "Express", "MongoDB"], | ||
project_url: "<https://github.com/johndoe/ecommerce>", | ||
}, | ||
], | ||
softskills: ["Communication", "Problem-solving", "Teamwork", "Adaptability", "Time management"], | ||
}, | ||
{ | ||
id: 2, | ||
name: "Pedro", | ||
professional_profile_url: [ | ||
{ platform: "GitHub", url: "<https://github.com/johndoe>" }, | ||
{ platform: "LinkedIn", url: "<https://linkedin.com/in/johndoe>" }, | ||
], | ||
stack: "full-stack", | ||
community_level: "code wizard", | ||
current_squad: "marvels", | ||
skills: ["HTML", "CSS", "JavaScript", "React", "Node.js", "Git", "Docker", "Prisma", "NestJS"], | ||
projects: [ | ||
{ | ||
project_cover: "https://project1.pg", | ||
project_name: "Personal Portfolio", | ||
description: "A personal portfolio website built with React and hosted on GitHub.", | ||
technologies_used: ["React", "CSS", "JavaScript"], | ||
project_url: "<https://github.com/johndoe/portfolio>", | ||
}, | ||
{ | ||
project_cover: "https://project1.pg", | ||
project_name: "E-commerce Website", | ||
description: "An online store platform with payment integration, built with Node.js and MongoDB.", | ||
technologies_used: ["Node.js", "Express", "MongoDB"], | ||
project_url: "<https://github.com/johndoe/ecommerce>", | ||
}, | ||
], | ||
softskills: ["Communication", "Problem-solving", "Teamwork", "Adaptability", "Time management"], | ||
}, | ||
]; | ||
|
||
export class MemberRepository { | ||
async createAsync(memberToBeCreated: CreateMemberDto): Promise<Member> { | ||
const newMember: Member = { | ||
id: Date.now(), | ||
...memberToBeCreated, | ||
}; | ||
members.push(newMember); | ||
return newMember; | ||
} | ||
|
||
async findAllAsync(): Promise<Member[] | null> { | ||
return members; | ||
} | ||
|
||
async findByIdAsync(id: number): Promise<Member | null> { | ||
return members.find((member) => member.id === id) || null; | ||
} | ||
|
||
async updateAsync(id: number, newMemberData: UpdateMemberDto) { | ||
members = members.map((member) => | ||
member.id === id ? { ...member, ...newMemberData, updatedAt: new Date() } : member, | ||
); | ||
} | ||
|
||
async deleteAsync(id: number) { | ||
members = members.filter((member) => member.id !== id); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverter a remoção do
.env.template
para que sirva de guia a quem posteriormente for executar o projeto localmente.