diff --git a/cv/src/app.controller.ts b/cv/src/app.controller.ts index 863dbcd..cd657fb 100644 --- a/cv/src/app.controller.ts +++ b/cv/src/app.controller.ts @@ -23,11 +23,11 @@ export class AppController { description: "Returns a list of all skills", schema: { items: { - $ref: getSchemaPath(SkillDto) - } - } + $ref: getSchemaPath(SkillDto), + }, + }, }) getSkills(): ReadonlyArray { - return this.skillsService.getSkills({ }) + return this.skillsService.getMany(); } } diff --git a/cv/src/common/types.ts b/cv/src/common/types.ts new file mode 100644 index 0000000..a423b21 --- /dev/null +++ b/cv/src/common/types.ts @@ -0,0 +1,15 @@ +export function DtoClass, DTO>() { + return class BaseDto { + constructor(type: unknown) {} + + public static asDto(bases: T): DTO[] + public static asDto(types: T): T + public static asDto(types: T): DTO | DTO[] { + if (!Array.isArray(types)) { + return new this(types) as DTO; + } + + return types.map((base) => new this(base) as DTO); + } + } +} diff --git a/cv/src/skills/skills.service.spec.ts b/cv/src/skills/skills.service.spec.ts index 2480bfe..f257ba8 100644 --- a/cv/src/skills/skills.service.spec.ts +++ b/cv/src/skills/skills.service.spec.ts @@ -1,18 +1,28 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { SkillsService } from './skills.service'; +import { Test, TestingModule } from "@nestjs/testing"; +import { SkillsService } from "./skills.service"; -describe('SkillsService', () => { - let service: SkillsService; +describe("SkillsService", () => { + let service: SkillsService; - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - providers: [SkillsService], - }).compile(); + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [SkillsService], + }).compile(); - service = module.get(SkillsService); - }); + service = module.get(SkillsService); + }); + + it("should be defined", () => { + expect(service).toBeDefined(); + }); + + + describe("getMany method", () => { + it("should be defined", () => { expect(service.getMany).toBeDefined(); }); + + it("should return an array", () => { expect(Array.isArray(service.getMany())).toBe(true); }); + + it("should return an array", () => { expect(Array.isArray(service.getMany())).toBe(true); }); + }) - it('should be defined', () => { - expect(service).toBeDefined(); - }); }); diff --git a/cv/src/skills/skills.service.ts b/cv/src/skills/skills.service.ts index 579c801..4503eda 100644 --- a/cv/src/skills/skills.service.ts +++ b/cv/src/skills/skills.service.ts @@ -1,68 +1,18 @@ import { Injectable } from "@nestjs/common"; -import { SkillDto, SkillType } from "src/skills/skills.types"; +import { SkillDto, SkillType } from "@/skills/skills.types"; +import {skills} from "@/skills/skills"; @Injectable() export class SkillsService { private readonly skills: ReadonlyArray; constructor() { - this.skills = SkillDto.asDto([ - { - name: "Git", - description: "Working with git, maintaining repositories, managing pull/merge requests.", - category: "Version control systems", - }, - { - name: "NodeJs, TypeScript, and Javascript", - description: "Building efficient and scalable microservices.", - category: "Programming languages", - }, - { - name: "Docker", - description: "Containerizing and running microservices in a local development environment.", - category: "Containerization", - }, - { - name: "Kubernetes", - description: "Deploying microservices to AWS (EKS).", - category: "Containerization", - }, - { - name: "EKS", - description: "Managing Elastic Kubernetes Service on AWS.", - category: "AWS", - }, - { - name: "API Gateway", - description: "Building and deploying cloud based applications.", - category: "AWS", - }, - { - name: "Lambda", - description: "Building and deploying cloud based applications.", - category: "AWS", - }, - { - name: "CloudWatch", - description: "Monitoring cloud based applications.", - category: "AWS", - }, - { - name: "CI/CD pipelines", - description: "Automating testing, building and deployments.", - category: "DevOps", - }, - { - name: "PHP", - description: "Building Websites and applications in PHP Laravel.", - category: "Programming languages", - }, - ]) + this.skills = SkillDto.asDto(skills) .sort((skillA, skillB) => skillA.category > skillB.category ? 1 : -1); } - getSkills(filter?: Partial) { - const filtersValues = Object.entries(filter).map(([key, filterValue]) => ([key, new RegExp(filterValue, "i")])) as [keyof SkillType, RegExp][]; + getMany(filter?: Partial) { + const filtersValues = Object.entries(filter ?? {}).map(([key, filterValue]) => ([key, new RegExp(filterValue, "i")])) as [keyof SkillType, RegExp][]; if (!filter || filtersValues.length === 0) { return this.skills; } diff --git a/cv/src/skills/skills.ts b/cv/src/skills/skills.ts new file mode 100644 index 0000000..f3c2c06 --- /dev/null +++ b/cv/src/skills/skills.ts @@ -0,0 +1,89 @@ +import { SkillType } from "@/skills/skills.types"; + +export const skills: SkillType[] = [ + { + name: "Git", + description: "Working with git, maintaining repositories, managing pull/merge requests.", + category: "Version control systems", + }, + { + name: "NodeJs, TypeScript, and Javascript", + description: "Building efficient and scalable microservices.", + category: "Programming languages", + }, + { + name: "Docker", + description: "Containerizing and running microservices in a local development environment.", + category: "Containerization", + }, + { + name: "Kubernetes", + description: "Deploying microservices to AWS (EKS).", + category: "Containerization", + }, + { + name: "EKS", + description: "Managing Elastic Kubernetes Service on AWS.", + category: "AWS", + }, + { + name: "API Gateway", + description: "Building and deploying cloud based applications.", + category: "AWS", + }, + { + name: "Lambda", + description: "Building and deploying cloud based applications.", + category: "AWS", + }, + { + name: "CloudWatch", + description: "Monitoring cloud based applications.", + category: "AWS", + }, + { + name: "ElasticSearch, Logstash and Kibana", + description: "Generate statistics from data of a SaaS platform.", + category: "Business Intelligence", + }, + { + name: "CI/CD pipelines", + description: "Automating testing, building and deployments.", + category: "DevOps", + }, + { + name: "Server Management", + description: "Setup and management of a hosting server.", + category: "DevOps", + }, + { + name: "Webhosting", + description: "Setting up hosting for websites & email.", + category: "DevOps", + }, + { + name: "PHP", + description: "Building Websites and applications in PHP Laravel.", + category: "Programming languages", + }, + { + name: "One-on-ones", + description: "Periodic meetings with junior developers and interns in my team to discuss their personal growth progress.", + category: "Team Management", + }, + { + name: "Scrum Master", + description: "Facilitate the meetings, keeping track of the sprint board and refine tickets with the PO." , + category: "Team Management", + }, + { + name: "Finances", + description: "Manage the financial aspect of a student organization" , + category: "Finance", + }, + { + name: "Event Organization", + description: "Organize educational events for students" , + category: "Organization", + } +] satisfies SkillType[]; diff --git a/cv/src/skills/skills.types.ts b/cv/src/skills/skills.types.ts index 4e86cee..181e066 100644 --- a/cv/src/skills/skills.types.ts +++ b/cv/src/skills/skills.types.ts @@ -1,4 +1,5 @@ import { ApiProperty } from "@nestjs/swagger"; +import { DtoClass } from "@/common/types"; export type SkillType = { name: string; @@ -6,8 +7,7 @@ export type SkillType = { description: string; } -type Test = T extends SkillType ? SkillDto : SkillDto[]; -export class SkillDto implements SkillType { +export class SkillDto extends DtoClass() implements SkillType { @ApiProperty() readonly name: string; @ApiProperty() @@ -16,20 +16,11 @@ export class SkillDto implements SkillType { readonly description: string; constructor(skill: SkillType) { + super(skill) Object.assign(this, { name: skill.name, category: skill.category, descriptions: skill.description }); } - - public static asDto(skills: T): SkillDto - public static asDto(skills: T): SkillDto[] - public static asDto(skills: T): SkillDto | SkillDto[] { - if (!Array.isArray(skills)) { - return new SkillDto(skills); - } - - return skills.map((skill) => new SkillDto(skill)); - } }