Skip to content

Commit 8a4d38d

Browse files
committed
feat(api): add endpoints, tests for backend and front integration of crud for sections, items, templates, ...
1 parent 78aa729 commit 8a4d38d

72 files changed

Lines changed: 4748 additions & 257 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

@apps/backend/src/app/app.router.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import {
22
type AuthModule,
33
type UserModule,
44
type CurriculumModule,
5-
ProposedSectionsModule,
5+
type SectionTemplatesModule,
6+
type SectionsModule,
7+
type SectionItemsModule,
68
} from "@libs/users-backend";
79
import type { FastifyInstanceType } from "./app.js";
810
import { statusRoute } from "./status.route.js";
@@ -11,12 +13,21 @@ interface AppRouterOptions {
1113
authModule: AuthModule;
1214
userModule: UserModule;
1315
curriculumModule: CurriculumModule;
14-
proposedSectionsModule: ProposedSectionsModule;
16+
sectionTemplatesModule: SectionTemplatesModule;
17+
sectionsModule: SectionsModule;
18+
sectionItemsModule: SectionItemsModule;
1519
}
1620

1721
export async function appRouter(
1822
fastify: FastifyInstanceType,
19-
{ authModule, userModule, curriculumModule, proposedSectionsModule }: AppRouterOptions,
23+
{
24+
authModule,
25+
userModule,
26+
curriculumModule,
27+
sectionTemplatesModule,
28+
sectionsModule,
29+
sectionItemsModule,
30+
}: AppRouterOptions,
2031
) {
2132
await fastify.register(
2233
async function (fastify) {
@@ -33,7 +44,9 @@ export async function appRouter(
3344

3445
await userModule.setupRoutes(fastify);
3546
await curriculumModule.setupRoutes(fastify);
36-
await proposedSectionsModule.setupRoutes(fastify);
47+
await sectionTemplatesModule.setupRoutes(fastify);
48+
await sectionsModule.setupRoutes(fastify);
49+
await sectionItemsModule.setupRoutes(fastify);
3750
},
3851
{
3952
prefix: "api/v1",

@apps/backend/src/app/app.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import {
2323
UserModule,
2424
AuthModule,
2525
CurriculumModule,
26-
ProposedSectionsModule,
26+
SectionTemplatesModule,
27+
SectionsModule,
28+
SectionItemsModule,
2729
} from "@libs/users-backend";
2830

2931
export type FastifyInstanceType = FastifyInstance<
@@ -173,7 +175,19 @@ export class App {
173175
jwtSecret: this.context.configuration.JWT_SECRET,
174176
},
175177
}),
176-
proposedSectionsModule: ProposedSectionsModule.init({
178+
sectionTemplatesModule: SectionTemplatesModule.init({
179+
em: this.context.orm.em.fork(),
180+
configuration: {
181+
jwtSecret: this.context.configuration.JWT_SECRET,
182+
},
183+
}),
184+
sectionsModule: SectionsModule.init({
185+
em: this.context.orm.em.fork(),
186+
configuration: {
187+
jwtSecret: this.context.configuration.JWT_SECRET,
188+
},
189+
}),
190+
sectionItemsModule: SectionItemsModule.init({
177191
em: this.context.orm.em.fork(),
178192
configuration: {
179193
jwtSecret: this.context.configuration.JWT_SECRET,

@apps/backend/src/app/database.connection.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import {
44
RefreshTokenEntity,
55
UserEntity,
66
CurriculumEntity,
7-
ProposedSectionEntity,
7+
SectionTemplatesEntity,
8+
SectionsEntity,
9+
SectionItemsEntity,
810
} from "@libs/users-backend";
911

1012
export function databaseConfig(config: Pick<AppConfiguration, "DATABASE_URI">) {
@@ -13,7 +15,14 @@ export function databaseConfig(config: Pick<AppConfiguration, "DATABASE_URI">) {
1315
pathTs: "./src/seeders",
1416
},
1517
clientUrl: config.DATABASE_URI,
16-
entities: [UserEntity, RefreshTokenEntity, CurriculumEntity, ProposedSectionEntity],
18+
entities: [
19+
UserEntity,
20+
RefreshTokenEntity,
21+
CurriculumEntity,
22+
SectionTemplatesEntity,
23+
SectionsEntity,
24+
SectionItemsEntity,
25+
],
1726
});
1827
}
1928

@apps/backend/src/mikro-orm.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@ const config = loadConfiguration();
99
* Important for test reproduction
1010
*/
1111
seed(config.SEED);
12+
defineConfig({
13+
debug: true,
14+
logger: (message) => console.log(message),
15+
});
1216

1317
export default defineConfig(databaseConfig(config));
Lines changed: 137 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
import { hashPassword, ProposedSectionEntity, UserEntity } from "@libs/users-backend";
1+
import {
2+
hashPassword,
3+
SectionTemplatesEntity,
4+
UserEntity,
5+
CurriculumEntity,
6+
SectionsEntity,
7+
SectionItemsEntity,
8+
} from "@libs/users-backend";
29
import type { EntityManager } from "@mikro-orm/core";
310
import { Seeder } from "@mikro-orm/seeder";
11+
import personnalInformationsJsonSchema from "./models/personal-informations.schema.json" with { type: "json" };
12+
import formationsJsonSchema from "./models/formations.schema.json" with { type: "json" };
13+
import langueJsonSchema from "./models/langues.schema.json" with { type: "json" };
14+
import centresInteretsJsonSchema from "./models/centres-interets.schema.json" with { type: "json" };
15+
import competencesJsonSchema from "./models/competences.schema.json" with { type: "json" };
16+
import experiencesJsonSchema from "./models/experiences.schema.json" with { type: "json" };
17+
import profilJsonSchema from "./models/profil.schema.json" with { type: "json" };
18+
import referencesJsonSchema from "./models/references.schema.json" with { type: "json" };
419

520
export class DatabaseSeeder extends Seeder {
621
async run(em: EntityManager) {
@@ -15,22 +30,134 @@ export class DatabaseSeeder extends Seeder {
1530
password: hashedPassword,
1631
});
1732

18-
em.create(ProposedSectionEntity, {
19-
id: "e2e-proposed-section-1",
20-
title: "Informations personnelles",
33+
// Curriculum for e2e tests
34+
em.create(CurriculumEntity, {
35+
id: "e2e-curriculum",
36+
userId: "e2e-login-user",
37+
title: "Mon CV",
38+
createdAt: new Date(),
39+
updatedAt: new Date(),
40+
});
41+
42+
const template1 = em.create(SectionTemplatesEntity, {
43+
id: "e2e-section-template-1",
44+
label: "Informations personnelles",
45+
jsonSchema: personnalInformationsJsonSchema,
2146
position: 1,
2247
});
2348

24-
em.create(ProposedSectionEntity, {
25-
id: "e2e-proposed-section-2",
26-
title: "Expérience professionnelle",
49+
const template2 = em.create(SectionTemplatesEntity, {
50+
id: "e2e-section-template-2",
51+
label: "Formations",
52+
jsonSchema: formationsJsonSchema,
2753
position: 2,
2854
});
2955

30-
em.create(ProposedSectionEntity, {
31-
id: "e2e-proposed-section-3",
32-
title: "Formation et diplômes",
56+
em.create(SectionTemplatesEntity, {
57+
id: "e2e-section-template-3",
58+
label: "Expériences professionnelles",
59+
jsonSchema: experiencesJsonSchema,
60+
position: 3,
61+
});
62+
63+
em.create(SectionTemplatesEntity, {
64+
id: "e2e-section-template-4",
65+
label: "Compétences",
66+
jsonSchema: competencesJsonSchema,
67+
position: 4,
68+
});
69+
70+
em.create(SectionTemplatesEntity, {
71+
id: "e2e-section-template-5",
72+
label: "Centres d'intérêts",
73+
jsonSchema: centresInteretsJsonSchema,
74+
position: 5,
75+
});
76+
77+
em.create(SectionTemplatesEntity, {
78+
id: "e2e-section-template-6",
79+
label: "Profil",
80+
jsonSchema: profilJsonSchema,
81+
position: 6,
82+
});
83+
84+
em.create(SectionTemplatesEntity, {
85+
id: "e2e-section-template-7",
86+
label: "Références",
87+
jsonSchema: referencesJsonSchema,
88+
position: 7,
89+
});
90+
91+
em.create(SectionTemplatesEntity, {
92+
id: "e2e-section-template-3",
93+
label: "Langues",
94+
jsonSchema: langueJsonSchema,
3395
position: 3,
3496
});
97+
98+
const curriculum = em.create(CurriculumEntity, {
99+
id: "e2e-curriculum",
100+
userId: "e2e-login-user",
101+
title: "Mon CV",
102+
createdAt: new Date(),
103+
updatedAt: new Date(),
104+
});
105+
106+
const section1 = em.create(SectionsEntity, {
107+
id: "e2e-section-1",
108+
curriculum,
109+
template: template1,
110+
title: "Informations personnelles",
111+
position: 1,
112+
});
113+
114+
const section2 = em.create(SectionsEntity, {
115+
id: "e2e-section-2",
116+
curriculum,
117+
template: template2,
118+
title: "Formations",
119+
position: 2,
120+
});
121+
122+
em.create(SectionItemsEntity, {
123+
id: "e2e-section-item-1",
124+
section: section1,
125+
position: 1,
126+
jsonData: {
127+
firstName: "Amaury",
128+
lastName: "Deflorenne",
129+
email: "test@gmail.com",
130+
phone: "0601020304",
131+
address: "123 rue de la paix, 75000 Paris",
132+
},
133+
});
134+
135+
em.create(SectionItemsEntity, {
136+
id: "e2e-section-item-2",
137+
section: section2,
138+
position: 1,
139+
jsonData: {
140+
school: "Université de Lyon",
141+
degree: "Master Informatique",
142+
field: "Informatique",
143+
startDate: "2021-09-01",
144+
endDate: "2023-06-30",
145+
description: "Description de ma formation en informatique à l'Université de Lyon.",
146+
},
147+
});
148+
149+
em.create(SectionItemsEntity, {
150+
id: "e2e-section-item-3",
151+
section: section2,
152+
position: 2,
153+
jsonData: {
154+
school: "Université de Paris",
155+
degree: "Licence Informatique",
156+
field: "Informatique",
157+
startDate: "2018-09-01",
158+
endDate: "2021-06-30",
159+
description: "Description de ma formation en informatique à l'Université de Paris.",
160+
},
161+
});
35162
}
36163
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{ "key": "interest", "label": "Centre d'intérêt", "type": "text" }]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
{ "key": "competence", "label": "Compétence", "type": "text" },
3+
{ "key": "level", "label": "Niveau", "type": "text" }
4+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{ "key": "position", "label": "Poste", "type": "text" },
3+
{ "key": "employer", "label": "Employeur", "type": "text" },
4+
{ "key": "city", "label": "Ville", "type": "text" },
5+
{ "key": "startDate", "label": "Date de début", "type": "date" },
6+
{ "key": "endDate", "label": "Date de fin", "type": "date" },
7+
{ "key": "description", "label": "Description", "type": "textarea" }
8+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{ "key": "school", "label": "École / Université", "type": "text" },
3+
{ "key": "degree", "label": "Diplôme", "type": "text" },
4+
{ "key": "field", "label": "Domaine", "type": "text" },
5+
{ "key": "startDate", "label": "Début", "type": "date" },
6+
{ "key": "endDate", "label": "Fin", "type": "date" },
7+
{ "key": "description", "label": "Description", "type": "textarea" }
8+
]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
{ "key": "langue", "label": "Langue", "type": "text" },
3+
{ "key": "niveau", "label": "Niveau", "type": "text" }
4+
]

0 commit comments

Comments
 (0)