@programisto/edrm-exams 0.2.0 → 0.2.2

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/dist/bin/www.js CHANGED
@@ -5,5 +5,9 @@ import { fileURLToPath } from 'url';
5
5
  const __filename = fileURLToPath(import.meta.url);
6
6
  const __dirname = path.dirname(__filename);
7
7
  const localAppPath = path.join(__dirname, '../lib/app.js');
8
- const coreAppPath = 'endurance-core/dist/lib/app.js';
9
- fs.existsSync(localAppPath) ? await import(localAppPath) : await import(coreAppPath);
8
+ if (fs.existsSync(localAppPath)) {
9
+ await import(localAppPath);
10
+ }
11
+ else {
12
+ await import('@programisto/endurance-core');
13
+ }
@@ -5,14 +5,14 @@ declare enum UserRole {
5
5
  Recruiter = "recruiter",
6
6
  Candidate = "candidate"
7
7
  }
8
- declare class User extends EnduranceSchema {
8
+ declare class UserExam extends EnduranceSchema {
9
9
  firstName: string;
10
10
  lastName: string;
11
11
  email: string;
12
12
  password: string;
13
13
  role: UserRole;
14
14
  companyId?: typeof Company;
15
- static getModel(): import("@typegoose/typegoose").ReturnModelType<typeof User, import("@typegoose/typegoose/lib/types.js").BeAnObject>;
15
+ static getModel(): import("@typegoose/typegoose").ReturnModelType<typeof UserExam, import("@typegoose/typegoose/lib/types.js").BeAnObject>;
16
16
  }
17
- declare const UserModel: import("@typegoose/typegoose").ReturnModelType<typeof User, import("@typegoose/typegoose/lib/types.js").BeAnObject>;
18
- export default UserModel;
17
+ declare const UserExamModel: import("@typegoose/typegoose").ReturnModelType<typeof UserExam, import("@typegoose/typegoose/lib/types.js").BeAnObject>;
18
+ export default UserExamModel;
@@ -18,7 +18,7 @@ var UserRole;
18
18
  // eslint-disable-next-line no-unused-vars
19
19
  UserRole["Candidate"] = "candidate";
20
20
  })(UserRole || (UserRole = {}));
21
- let User = class User extends EnduranceSchema {
21
+ let UserExam = class UserExam extends EnduranceSchema {
22
22
  firstName;
23
23
  lastName;
24
24
  email;
@@ -26,39 +26,48 @@ let User = class User extends EnduranceSchema {
26
26
  role;
27
27
  companyId;
28
28
  static getModel() {
29
- return UserModel;
29
+ return UserExamModel;
30
30
  }
31
31
  };
32
32
  __decorate([
33
33
  EnduranceModelType.prop({ required: true }),
34
34
  __metadata("design:type", String)
35
- ], User.prototype, "firstName", void 0);
35
+ ], UserExam.prototype, "firstName", void 0);
36
36
  __decorate([
37
37
  EnduranceModelType.prop({ required: true }),
38
38
  __metadata("design:type", String)
39
- ], User.prototype, "lastName", void 0);
39
+ ], UserExam.prototype, "lastName", void 0);
40
40
  __decorate([
41
41
  EnduranceModelType.prop({ required: true, unique: true }),
42
42
  __metadata("design:type", String)
43
- ], User.prototype, "email", void 0);
43
+ ], UserExam.prototype, "email", void 0);
44
44
  __decorate([
45
45
  EnduranceModelType.prop({ required: true }),
46
46
  __metadata("design:type", String)
47
- ], User.prototype, "password", void 0);
47
+ ], UserExam.prototype, "password", void 0);
48
48
  __decorate([
49
49
  EnduranceModelType.prop({ required: true, enum: UserRole }),
50
50
  __metadata("design:type", String)
51
- ], User.prototype, "role", void 0);
51
+ ], UserExam.prototype, "role", void 0);
52
52
  __decorate([
53
53
  EnduranceModelType.prop({ ref: () => Company }),
54
54
  __metadata("design:type", Object)
55
- ], User.prototype, "companyId", void 0);
56
- User = __decorate([
55
+ ], UserExam.prototype, "companyId", void 0);
56
+ UserExam = __decorate([
57
57
  EnduranceModelType.modelOptions({
58
+ schemaOptions: {
59
+ collection: 'users',
60
+ timestamps: true,
61
+ toObject: { virtuals: true },
62
+ toJSON: { virtuals: true },
63
+ _id: true,
64
+ validateBeforeSave: false,
65
+ strict: false
66
+ },
58
67
  options: {
59
68
  allowMixed: EnduranceModelType.Severity.ALLOW
60
69
  }
61
70
  })
62
- ], User);
63
- const UserModel = EnduranceModelType.getModelForClass(User);
64
- export default UserModel;
71
+ ], UserExam);
72
+ const UserExamModel = EnduranceModelType.getModelForClass(UserExam);
73
+ export default UserExamModel;
@@ -1,6 +1,6 @@
1
1
  import { EnduranceRouter, EnduranceAuthMiddleware } from '@programisto/endurance-core';
2
2
  import Company from '../models/company.model.js';
3
- import User from '../models/user.model.js';
3
+ import UserExam from '../models/user.model.js';
4
4
  class CompanyRouter extends EnduranceRouter {
5
5
  constructor() {
6
6
  super(EnduranceAuthMiddleware.getInstance());
@@ -82,7 +82,7 @@ class CompanyRouter extends EnduranceRouter {
82
82
  this.get('/numberOfUser/:id', authenticatedOptions, async (req, res) => {
83
83
  const { id } = req.params;
84
84
  try {
85
- const users = await User.find({ companyId: id });
85
+ const users = await UserExam.find({ companyId: id });
86
86
  const numberOfUser = users.length;
87
87
  res.status(200).json({ data: numberOfUser });
88
88
  }
@@ -1,5 +1,5 @@
1
1
  import { EnduranceRouter, EnduranceAuthMiddleware } from '@programisto/endurance-core';
2
- import User from '../models/user.model.js';
2
+ import UserExam from '../models/user.model.js';
3
3
  class UserRouter extends EnduranceRouter {
4
4
  constructor() {
5
5
  super(EnduranceAuthMiddleware.getInstance());
@@ -12,7 +12,7 @@ class UserRouter extends EnduranceRouter {
12
12
  // Lister tous les utilisateurs
13
13
  this.get('/', authenticatedOptions, async (req, res) => {
14
14
  try {
15
- const users = await User.find();
15
+ const users = await UserExam.find();
16
16
  res.status(200).json({ array: users });
17
17
  }
18
18
  catch (err) {
@@ -27,7 +27,7 @@ class UserRouter extends EnduranceRouter {
27
27
  return res.status(400).json({ message: 'Error, firstName, lastName, email and companyId are required' });
28
28
  }
29
29
  try {
30
- const newUser = new User({ firstName, lastName, email, companyId });
30
+ const newUser = new UserExam({ firstName, lastName, email, companyId });
31
31
  await newUser.save();
32
32
  res.status(201).json({ message: 'user created with sucess', user: newUser });
33
33
  }
@@ -40,7 +40,7 @@ class UserRouter extends EnduranceRouter {
40
40
  this.get('/:id', authenticatedOptions, async (req, res) => {
41
41
  const { id } = req.params;
42
42
  try {
43
- const user = await User.findById(id);
43
+ const user = await UserExam.findById(id);
44
44
  if (!user) {
45
45
  return res.status(404).json({ message: 'no user founded with this id' });
46
46
  }
@@ -56,7 +56,7 @@ class UserRouter extends EnduranceRouter {
56
56
  const { id } = req.params;
57
57
  const { firstName, lastName, email, companyId } = req.body;
58
58
  try {
59
- const user = await User.findById(id);
59
+ const user = await UserExam.findById(id);
60
60
  if (!user) {
61
61
  return res.status(404).json({ message: 'no user founded with this id' });
62
62
  }
@@ -66,8 +66,8 @@ class UserRouter extends EnduranceRouter {
66
66
  email: email || user.email,
67
67
  companyId: companyId || user.companyId
68
68
  };
69
- await User.findByIdAndUpdate(id, updateData, { new: true });
70
- const updatedUser = await User.findById(id);
69
+ await UserExam.findByIdAndUpdate(id, updateData, { new: true });
70
+ const updatedUser = await UserExam.findById(id);
71
71
  res.status(200).json({ message: 'user updated', user: updatedUser });
72
72
  }
73
73
  catch (err) {
@@ -79,7 +79,7 @@ class UserRouter extends EnduranceRouter {
79
79
  this.delete('/:id', authenticatedOptions, async (req, res) => {
80
80
  const { id } = req.params;
81
81
  try {
82
- const user = await User.findByIdAndDelete(id);
82
+ const user = await UserExam.findByIdAndDelete(id);
83
83
  if (!user) {
84
84
  return res.status(404).json({ message: 'no user founded with this id' });
85
85
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@programisto/edrm-exams",
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -17,7 +17,7 @@
17
17
  "prepare": "husky install"
18
18
  },
19
19
  "dependencies": {
20
- "@programisto/endurance-core": "^1.0.0",
20
+ "@programisto/endurance-core": "^1.1.6",
21
21
  "aws-sdk": "^2.1692.0",
22
22
  "debug": "^4.3.7",
23
23
  "fs": "^0.0.1-security",