@programisto/edrm-exams 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -0
- package/dist/bin/www.d.ts +2 -0
- package/dist/bin/www.js +9 -0
- package/dist/modules/edrm-exams/lib/openai/correctQuestion.txt +10 -0
- package/dist/modules/edrm-exams/lib/openai/createQuestion.txt +68 -0
- package/dist/modules/edrm-exams/lib/openai.d.ts +36 -0
- package/dist/modules/edrm-exams/lib/openai.js +82 -0
- package/dist/modules/edrm-exams/listeners/correct.listener.d.ts +2 -0
- package/dist/modules/edrm-exams/listeners/correct.listener.js +85 -0
- package/dist/modules/edrm-exams/models/candidate.models.d.ts +13 -0
- package/dist/modules/edrm-exams/models/candidate.models.js +59 -0
- package/dist/modules/edrm-exams/models/company.model.d.ts +8 -0
- package/dist/modules/edrm-exams/models/company.model.js +34 -0
- package/dist/modules/edrm-exams/models/test-category.models.d.ts +7 -0
- package/dist/modules/edrm-exams/models/test-category.models.js +29 -0
- package/dist/modules/edrm-exams/models/test-question.model.d.ts +25 -0
- package/dist/modules/edrm-exams/models/test-question.model.js +70 -0
- package/dist/modules/edrm-exams/models/test-result.model.d.ts +26 -0
- package/dist/modules/edrm-exams/models/test-result.model.js +70 -0
- package/dist/modules/edrm-exams/models/test.model.d.ts +52 -0
- package/dist/modules/edrm-exams/models/test.model.js +123 -0
- package/dist/modules/edrm-exams/models/user.model.d.ts +18 -0
- package/dist/modules/edrm-exams/models/user.model.js +64 -0
- package/dist/modules/edrm-exams/routes/company.router.d.ts +7 -0
- package/dist/modules/edrm-exams/routes/company.router.js +108 -0
- package/dist/modules/edrm-exams/routes/exams-candidate.router.d.ts +7 -0
- package/dist/modules/edrm-exams/routes/exams-candidate.router.js +299 -0
- package/dist/modules/edrm-exams/routes/exams.router.d.ts +7 -0
- package/dist/modules/edrm-exams/routes/exams.router.js +1012 -0
- package/dist/modules/edrm-exams/routes/result.router.d.ts +7 -0
- package/dist/modules/edrm-exams/routes/result.router.js +314 -0
- package/dist/modules/edrm-exams/routes/user.router.d.ts +7 -0
- package/dist/modules/edrm-exams/routes/user.router.js +96 -0
- package/package.json +71 -8
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { EnduranceSchema, EnduranceModelType } from '@programisto/endurance-core';
|
|
11
|
+
var QuestionType;
|
|
12
|
+
(function (QuestionType) {
|
|
13
|
+
// eslint-disable-next-line no-unused-vars
|
|
14
|
+
QuestionType["MCQ"] = "MCQ";
|
|
15
|
+
// eslint-disable-next-line no-unused-vars
|
|
16
|
+
QuestionType["FreeQuestion"] = "free question";
|
|
17
|
+
// eslint-disable-next-line no-unused-vars
|
|
18
|
+
QuestionType["Exercise"] = "exercice";
|
|
19
|
+
})(QuestionType || (QuestionType = {}));
|
|
20
|
+
var TextType;
|
|
21
|
+
(function (TextType) {
|
|
22
|
+
// eslint-disable-next-line no-unused-vars
|
|
23
|
+
TextType["Text"] = "text";
|
|
24
|
+
// eslint-disable-next-line no-unused-vars
|
|
25
|
+
TextType["Code"] = "code";
|
|
26
|
+
})(TextType || (TextType = {}));
|
|
27
|
+
let TestQuestion = class TestQuestion extends EnduranceSchema {
|
|
28
|
+
questionType;
|
|
29
|
+
instruction;
|
|
30
|
+
maxScore;
|
|
31
|
+
possibleResponses;
|
|
32
|
+
time;
|
|
33
|
+
textType;
|
|
34
|
+
static getModel() {
|
|
35
|
+
return TestQuestionModel;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
__decorate([
|
|
39
|
+
EnduranceModelType.prop({ required: true, enum: QuestionType }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], TestQuestion.prototype, "questionType", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
EnduranceModelType.prop({ required: true }),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], TestQuestion.prototype, "instruction", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
EnduranceModelType.prop({ required: true }),
|
|
48
|
+
__metadata("design:type", Number)
|
|
49
|
+
], TestQuestion.prototype, "maxScore", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
EnduranceModelType.prop({ type: [Object], required: false }),
|
|
52
|
+
__metadata("design:type", Array)
|
|
53
|
+
], TestQuestion.prototype, "possibleResponses", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
EnduranceModelType.prop({ required: true }),
|
|
56
|
+
__metadata("design:type", Number)
|
|
57
|
+
], TestQuestion.prototype, "time", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
EnduranceModelType.prop({ required: false, enum: TextType, default: TextType.Text }),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], TestQuestion.prototype, "textType", void 0);
|
|
62
|
+
TestQuestion = __decorate([
|
|
63
|
+
EnduranceModelType.modelOptions({
|
|
64
|
+
options: {
|
|
65
|
+
allowMixed: EnduranceModelType.Severity.ALLOW
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
], TestQuestion);
|
|
69
|
+
const TestQuestionModel = EnduranceModelType.getModelForClass(TestQuestion);
|
|
70
|
+
export default TestQuestionModel;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EnduranceSchema, ObjectId } from '@programisto/endurance-core';
|
|
2
|
+
import Test from './test.model.js';
|
|
3
|
+
import User from './user.model.js';
|
|
4
|
+
export declare enum TestState {
|
|
5
|
+
Pending = "pending",
|
|
6
|
+
InProgress = "inProgress",
|
|
7
|
+
Finish = "finish"
|
|
8
|
+
}
|
|
9
|
+
interface Response {
|
|
10
|
+
questionId: ObjectId;
|
|
11
|
+
response: string;
|
|
12
|
+
score?: number;
|
|
13
|
+
comment?: string;
|
|
14
|
+
}
|
|
15
|
+
declare class TestResult extends EnduranceSchema {
|
|
16
|
+
testId: typeof Test;
|
|
17
|
+
candidateId: typeof User;
|
|
18
|
+
state: TestState;
|
|
19
|
+
responses: Response[];
|
|
20
|
+
score?: number;
|
|
21
|
+
startTime?: Date;
|
|
22
|
+
endTime?: Date;
|
|
23
|
+
static getModel(): import("@typegoose/typegoose").ReturnModelType<typeof TestResult, import("@typegoose/typegoose/lib/types.js").BeAnObject>;
|
|
24
|
+
}
|
|
25
|
+
declare const TestResultModel: import("@typegoose/typegoose").ReturnModelType<typeof TestResult, import("@typegoose/typegoose/lib/types.js").BeAnObject>;
|
|
26
|
+
export default TestResultModel;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { EnduranceSchema, EnduranceModelType } from '@programisto/endurance-core';
|
|
11
|
+
import Test from './test.model.js';
|
|
12
|
+
import User from './user.model.js';
|
|
13
|
+
export var TestState;
|
|
14
|
+
(function (TestState) {
|
|
15
|
+
// eslint-disable-next-line no-unused-vars
|
|
16
|
+
TestState["Pending"] = "pending";
|
|
17
|
+
// eslint-disable-next-line no-unused-vars
|
|
18
|
+
TestState["InProgress"] = "inProgress";
|
|
19
|
+
// eslint-disable-next-line no-unused-vars
|
|
20
|
+
TestState["Finish"] = "finish";
|
|
21
|
+
})(TestState || (TestState = {}));
|
|
22
|
+
let TestResult = class TestResult extends EnduranceSchema {
|
|
23
|
+
testId;
|
|
24
|
+
candidateId;
|
|
25
|
+
state;
|
|
26
|
+
responses;
|
|
27
|
+
score;
|
|
28
|
+
startTime;
|
|
29
|
+
endTime;
|
|
30
|
+
static getModel() {
|
|
31
|
+
return TestResultModel;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
__decorate([
|
|
35
|
+
EnduranceModelType.prop({ ref: () => Test, required: true }),
|
|
36
|
+
__metadata("design:type", Object)
|
|
37
|
+
], TestResult.prototype, "testId", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
EnduranceModelType.prop({ ref: () => User, required: true }),
|
|
40
|
+
__metadata("design:type", Object)
|
|
41
|
+
], TestResult.prototype, "candidateId", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
EnduranceModelType.prop({ required: true, enum: TestState, default: TestState.Pending }),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], TestResult.prototype, "state", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
EnduranceModelType.prop({ type: [Object], required: true }),
|
|
48
|
+
__metadata("design:type", Array)
|
|
49
|
+
], TestResult.prototype, "responses", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
EnduranceModelType.prop(),
|
|
52
|
+
__metadata("design:type", Number)
|
|
53
|
+
], TestResult.prototype, "score", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
EnduranceModelType.prop(),
|
|
56
|
+
__metadata("design:type", Date)
|
|
57
|
+
], TestResult.prototype, "startTime", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
EnduranceModelType.prop(),
|
|
60
|
+
__metadata("design:type", Date)
|
|
61
|
+
], TestResult.prototype, "endTime", void 0);
|
|
62
|
+
TestResult = __decorate([
|
|
63
|
+
EnduranceModelType.modelOptions({
|
|
64
|
+
options: {
|
|
65
|
+
allowMixed: EnduranceModelType.Severity.ALLOW
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
], TestResult);
|
|
69
|
+
const TestResultModel = EnduranceModelType.getModelForClass(TestResult);
|
|
70
|
+
export default TestResultModel;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { EnduranceSchema } from '@programisto/endurance-core';
|
|
2
|
+
import Company from './company.model.js';
|
|
3
|
+
import TestQuestion from './test-question.model.js';
|
|
4
|
+
import TestCategory from './test-category.models.js';
|
|
5
|
+
import User from './user.model.js';
|
|
6
|
+
declare enum TestState {
|
|
7
|
+
Draft = "draft",
|
|
8
|
+
Published = "published",
|
|
9
|
+
Archived = "archived"
|
|
10
|
+
}
|
|
11
|
+
declare enum JobType {
|
|
12
|
+
FrontEnd = "front-end",
|
|
13
|
+
BackEnd = "back-end",
|
|
14
|
+
Fullstack = "fullstack",
|
|
15
|
+
DevOps = "devops",
|
|
16
|
+
Data = "data"
|
|
17
|
+
}
|
|
18
|
+
declare enum SeniorityLevel {
|
|
19
|
+
Student = "student",
|
|
20
|
+
Junior = "junior",
|
|
21
|
+
Intermediate = "intermediate",
|
|
22
|
+
Senior = "senior"
|
|
23
|
+
}
|
|
24
|
+
declare enum ExpertiseLevel {
|
|
25
|
+
Beginner = "beginner",
|
|
26
|
+
Intermediate = "intermediate",
|
|
27
|
+
Advanced = "advanced"
|
|
28
|
+
}
|
|
29
|
+
interface TestQuestions {
|
|
30
|
+
questionId: typeof TestQuestion;
|
|
31
|
+
order: number;
|
|
32
|
+
}
|
|
33
|
+
interface TestCategoryWithExpertise {
|
|
34
|
+
categoryId: typeof TestCategory;
|
|
35
|
+
expertiseLevel: ExpertiseLevel;
|
|
36
|
+
}
|
|
37
|
+
declare class Test extends EnduranceSchema {
|
|
38
|
+
title: string;
|
|
39
|
+
description: string;
|
|
40
|
+
companyId: typeof Company;
|
|
41
|
+
userId: typeof User;
|
|
42
|
+
questions: TestQuestions[];
|
|
43
|
+
state: TestState;
|
|
44
|
+
duration?: number;
|
|
45
|
+
passingScore?: number;
|
|
46
|
+
categories?: TestCategoryWithExpertise[];
|
|
47
|
+
targetJob: JobType;
|
|
48
|
+
seniorityLevel: SeniorityLevel;
|
|
49
|
+
static getModel(): import("@typegoose/typegoose").ReturnModelType<typeof Test, import("@typegoose/typegoose/lib/types.js").BeAnObject>;
|
|
50
|
+
}
|
|
51
|
+
declare const TestModel: import("@typegoose/typegoose").ReturnModelType<typeof Test, import("@typegoose/typegoose/lib/types.js").BeAnObject>;
|
|
52
|
+
export default TestModel;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { EnduranceSchema, EnduranceModelType } from '@programisto/endurance-core';
|
|
11
|
+
import Company from './company.model.js';
|
|
12
|
+
import User from './user.model.js';
|
|
13
|
+
var TestState;
|
|
14
|
+
(function (TestState) {
|
|
15
|
+
// eslint-disable-next-line no-unused-vars
|
|
16
|
+
TestState["Draft"] = "draft";
|
|
17
|
+
// eslint-disable-next-line no-unused-vars
|
|
18
|
+
TestState["Published"] = "published";
|
|
19
|
+
// eslint-disable-next-line no-unused-vars
|
|
20
|
+
TestState["Archived"] = "archived";
|
|
21
|
+
})(TestState || (TestState = {}));
|
|
22
|
+
var JobType;
|
|
23
|
+
(function (JobType) {
|
|
24
|
+
// eslint-disable-next-line no-unused-vars
|
|
25
|
+
JobType["FrontEnd"] = "front-end";
|
|
26
|
+
// eslint-disable-next-line no-unused-vars
|
|
27
|
+
JobType["BackEnd"] = "back-end";
|
|
28
|
+
// eslint-disable-next-line no-unused-vars
|
|
29
|
+
JobType["Fullstack"] = "fullstack";
|
|
30
|
+
// eslint-disable-next-line no-unused-vars
|
|
31
|
+
JobType["DevOps"] = "devops";
|
|
32
|
+
// eslint-disable-next-line no-unused-vars
|
|
33
|
+
JobType["Data"] = "data";
|
|
34
|
+
})(JobType || (JobType = {}));
|
|
35
|
+
var SeniorityLevel;
|
|
36
|
+
(function (SeniorityLevel) {
|
|
37
|
+
// eslint-disable-next-line no-unused-vars
|
|
38
|
+
SeniorityLevel["Student"] = "student";
|
|
39
|
+
// eslint-disable-next-line no-unused-vars
|
|
40
|
+
SeniorityLevel["Junior"] = "junior";
|
|
41
|
+
// eslint-disable-next-line no-unused-vars
|
|
42
|
+
SeniorityLevel["Intermediate"] = "intermediate";
|
|
43
|
+
// eslint-disable-next-line no-unused-vars
|
|
44
|
+
SeniorityLevel["Senior"] = "senior";
|
|
45
|
+
})(SeniorityLevel || (SeniorityLevel = {}));
|
|
46
|
+
var ExpertiseLevel;
|
|
47
|
+
(function (ExpertiseLevel) {
|
|
48
|
+
// eslint-disable-next-line no-unused-vars
|
|
49
|
+
ExpertiseLevel["Beginner"] = "beginner";
|
|
50
|
+
// eslint-disable-next-line no-unused-vars
|
|
51
|
+
ExpertiseLevel["Intermediate"] = "intermediate";
|
|
52
|
+
// eslint-disable-next-line no-unused-vars
|
|
53
|
+
ExpertiseLevel["Advanced"] = "advanced";
|
|
54
|
+
})(ExpertiseLevel || (ExpertiseLevel = {}));
|
|
55
|
+
let Test = class Test extends EnduranceSchema {
|
|
56
|
+
title;
|
|
57
|
+
description;
|
|
58
|
+
companyId;
|
|
59
|
+
userId;
|
|
60
|
+
questions;
|
|
61
|
+
state;
|
|
62
|
+
duration;
|
|
63
|
+
passingScore;
|
|
64
|
+
categories;
|
|
65
|
+
targetJob;
|
|
66
|
+
seniorityLevel;
|
|
67
|
+
static getModel() {
|
|
68
|
+
return TestModel;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
__decorate([
|
|
72
|
+
EnduranceModelType.prop({ required: true }),
|
|
73
|
+
__metadata("design:type", String)
|
|
74
|
+
], Test.prototype, "title", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
EnduranceModelType.prop({ required: false }),
|
|
77
|
+
__metadata("design:type", String)
|
|
78
|
+
], Test.prototype, "description", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
EnduranceModelType.prop({ ref: () => Company, required: false }),
|
|
81
|
+
__metadata("design:type", Object)
|
|
82
|
+
], Test.prototype, "companyId", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
EnduranceModelType.prop({ ref: () => User, required: false }),
|
|
85
|
+
__metadata("design:type", Object)
|
|
86
|
+
], Test.prototype, "userId", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
EnduranceModelType.prop({ type: [Object], required: true }),
|
|
89
|
+
__metadata("design:type", Array)
|
|
90
|
+
], Test.prototype, "questions", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
EnduranceModelType.prop({ required: true, enum: TestState, default: TestState.Draft }),
|
|
93
|
+
__metadata("design:type", String)
|
|
94
|
+
], Test.prototype, "state", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
EnduranceModelType.prop(),
|
|
97
|
+
__metadata("design:type", Number)
|
|
98
|
+
], Test.prototype, "duration", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
EnduranceModelType.prop(),
|
|
101
|
+
__metadata("design:type", Number)
|
|
102
|
+
], Test.prototype, "passingScore", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
EnduranceModelType.prop({ type: [Object], required: false }),
|
|
105
|
+
__metadata("design:type", Array)
|
|
106
|
+
], Test.prototype, "categories", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
EnduranceModelType.prop({ required: true, enum: JobType }),
|
|
109
|
+
__metadata("design:type", String)
|
|
110
|
+
], Test.prototype, "targetJob", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
EnduranceModelType.prop({ required: true, enum: SeniorityLevel }),
|
|
113
|
+
__metadata("design:type", String)
|
|
114
|
+
], Test.prototype, "seniorityLevel", void 0);
|
|
115
|
+
Test = __decorate([
|
|
116
|
+
EnduranceModelType.modelOptions({
|
|
117
|
+
options: {
|
|
118
|
+
allowMixed: EnduranceModelType.Severity.ALLOW
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
], Test);
|
|
122
|
+
const TestModel = EnduranceModelType.getModelForClass(Test);
|
|
123
|
+
export default TestModel;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EnduranceSchema } from '@programisto/endurance-core';
|
|
2
|
+
import Company from './company.model.js';
|
|
3
|
+
declare enum UserRole {
|
|
4
|
+
Admin = "admin",
|
|
5
|
+
Recruiter = "recruiter",
|
|
6
|
+
Candidate = "candidate"
|
|
7
|
+
}
|
|
8
|
+
declare class User extends EnduranceSchema {
|
|
9
|
+
firstName: string;
|
|
10
|
+
lastName: string;
|
|
11
|
+
email: string;
|
|
12
|
+
password: string;
|
|
13
|
+
role: UserRole;
|
|
14
|
+
companyId?: typeof Company;
|
|
15
|
+
static getModel(): import("@typegoose/typegoose").ReturnModelType<typeof User, import("@typegoose/typegoose/lib/types.js").BeAnObject>;
|
|
16
|
+
}
|
|
17
|
+
declare const UserModel: import("@typegoose/typegoose").ReturnModelType<typeof User, import("@typegoose/typegoose/lib/types.js").BeAnObject>;
|
|
18
|
+
export default UserModel;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { EnduranceSchema, EnduranceModelType } from '@programisto/endurance-core';
|
|
11
|
+
import Company from './company.model.js';
|
|
12
|
+
var UserRole;
|
|
13
|
+
(function (UserRole) {
|
|
14
|
+
// eslint-disable-next-line no-unused-vars
|
|
15
|
+
UserRole["Admin"] = "admin";
|
|
16
|
+
// eslint-disable-next-line no-unused-vars
|
|
17
|
+
UserRole["Recruiter"] = "recruiter";
|
|
18
|
+
// eslint-disable-next-line no-unused-vars
|
|
19
|
+
UserRole["Candidate"] = "candidate";
|
|
20
|
+
})(UserRole || (UserRole = {}));
|
|
21
|
+
let User = class User extends EnduranceSchema {
|
|
22
|
+
firstName;
|
|
23
|
+
lastName;
|
|
24
|
+
email;
|
|
25
|
+
password;
|
|
26
|
+
role;
|
|
27
|
+
companyId;
|
|
28
|
+
static getModel() {
|
|
29
|
+
return UserModel;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
__decorate([
|
|
33
|
+
EnduranceModelType.prop({ required: true }),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], User.prototype, "firstName", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
EnduranceModelType.prop({ required: true }),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], User.prototype, "lastName", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
EnduranceModelType.prop({ required: true, unique: true }),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], User.prototype, "email", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
EnduranceModelType.prop({ required: true }),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], User.prototype, "password", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
EnduranceModelType.prop({ required: true, enum: UserRole }),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], User.prototype, "role", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
EnduranceModelType.prop({ ref: () => Company }),
|
|
54
|
+
__metadata("design:type", Object)
|
|
55
|
+
], User.prototype, "companyId", void 0);
|
|
56
|
+
User = __decorate([
|
|
57
|
+
EnduranceModelType.modelOptions({
|
|
58
|
+
options: {
|
|
59
|
+
allowMixed: EnduranceModelType.Severity.ALLOW
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
], User);
|
|
63
|
+
const UserModel = EnduranceModelType.getModelForClass(User);
|
|
64
|
+
export default UserModel;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { EnduranceRouter, EnduranceAuthMiddleware } from '@programisto/endurance-core';
|
|
2
|
+
import Company from '../models/company.model.js';
|
|
3
|
+
import User from '../models/user.model.js';
|
|
4
|
+
class CompanyRouter extends EnduranceRouter {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(EnduranceAuthMiddleware.getInstance());
|
|
7
|
+
}
|
|
8
|
+
setupRoutes() {
|
|
9
|
+
const authenticatedOptions = {
|
|
10
|
+
requireAuth: false,
|
|
11
|
+
permissions: []
|
|
12
|
+
};
|
|
13
|
+
// Obtenir une entreprise par son ID
|
|
14
|
+
this.get('/:id', authenticatedOptions, async (req, res) => {
|
|
15
|
+
const { id } = req.params;
|
|
16
|
+
try {
|
|
17
|
+
const company = await Company.findById(id);
|
|
18
|
+
if (!company) {
|
|
19
|
+
return res.status(404).json({ message: 'Aucune entreprise trouvée avec cet ID' });
|
|
20
|
+
}
|
|
21
|
+
res.status(200).json({ data: company });
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
console.error('Erreur lors de la récupération de l\'entreprise : ', err);
|
|
25
|
+
res.status(500).json({ message: 'Erreur interne du serveur' });
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
// Créer une nouvelle entreprise
|
|
29
|
+
this.post('/create', authenticatedOptions, async (req, res) => {
|
|
30
|
+
const { name, logo } = req.body;
|
|
31
|
+
if (!name || !logo) {
|
|
32
|
+
return res.status(400).json({ message: 'Erreur, le nom et le logo sont requis' });
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const newCompany = new Company({ name, logo });
|
|
36
|
+
await newCompany.save();
|
|
37
|
+
res.status(201).json({ message: 'Entreprise créée avec succès', company: newCompany });
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
console.error('Erreur lors de la création de l\'entreprise : ', err);
|
|
41
|
+
res.status(500).json({ message: 'Erreur interne du serveur' });
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
// Mettre à jour une entreprise
|
|
45
|
+
this.put('/:id', authenticatedOptions, async (req, res) => {
|
|
46
|
+
const { id } = req.params;
|
|
47
|
+
const { name, logo } = req.body;
|
|
48
|
+
try {
|
|
49
|
+
const company = await Company.findById(id);
|
|
50
|
+
if (!company) {
|
|
51
|
+
return res.status(404).json({ message: 'Aucune entreprise trouvée avec cet ID' });
|
|
52
|
+
}
|
|
53
|
+
const updateData = {
|
|
54
|
+
name: name || company.name,
|
|
55
|
+
logo: logo || company.logo
|
|
56
|
+
};
|
|
57
|
+
await Company.findByIdAndUpdate(id, updateData, { new: true });
|
|
58
|
+
const updatedCompany = await Company.findById(id);
|
|
59
|
+
res.status(200).json({ message: 'Entreprise mise à jour', company: updatedCompany });
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
console.error('Erreur lors de la mise à jour de l\'entreprise : ', err);
|
|
63
|
+
res.status(500).json({ message: 'Erreur interne du serveur' });
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
// Supprimer une entreprise
|
|
67
|
+
this.delete('/:id', authenticatedOptions, async (req, res) => {
|
|
68
|
+
const { id } = req.params;
|
|
69
|
+
try {
|
|
70
|
+
const company = await Company.findByIdAndDelete(id);
|
|
71
|
+
if (!company) {
|
|
72
|
+
return res.status(404).json({ message: 'Aucune entreprise trouvée avec cet ID' });
|
|
73
|
+
}
|
|
74
|
+
res.status(200).json({ message: 'Entreprise supprimée', company });
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
console.error('Erreur lors de la suppression de l\'entreprise : ', err);
|
|
78
|
+
res.status(500).json({ message: 'Erreur interne du serveur' });
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// Obtenir le nombre d'utilisateurs d'une entreprise
|
|
82
|
+
this.get('/numberOfUser/:id', authenticatedOptions, async (req, res) => {
|
|
83
|
+
const { id } = req.params;
|
|
84
|
+
try {
|
|
85
|
+
const users = await User.find({ companyId: id });
|
|
86
|
+
const numberOfUser = users.length;
|
|
87
|
+
res.status(200).json({ data: numberOfUser });
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
console.error('Erreur lors de la récupération du nombre d\'utilisateurs : ', err);
|
|
91
|
+
res.status(500).json({ message: 'Erreur interne du serveur' });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
// Lister toutes les entreprises
|
|
95
|
+
this.get('/', authenticatedOptions, async (req, res) => {
|
|
96
|
+
try {
|
|
97
|
+
const companies = await Company.find();
|
|
98
|
+
res.status(200).json({ array: companies });
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
console.error('Erreur lors de la récupération des entreprises : ', err);
|
|
102
|
+
res.status(500).json({ message: 'Erreur interne du serveur' });
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const router = new CompanyRouter();
|
|
108
|
+
export default router;
|