-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.ts
650 lines (595 loc) · 22.2 KB
/
server.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
import cors from 'cors';
import dotenv from 'dotenv';
import express, { NextFunction, Request, Response } from 'express';
import cron from 'node-cron';
import { AdminPartnersMentors } from './src/db_queries/admin_partners_mentors';
import { AdminPartnersMentorStats } from './src/db_queries/admin_partners_mentors_stats';
import { AdminPartnersOrganizationCenters } from './src/db_queries/admin_partners_organization_centers';
import { AdminPartnersProjects } from './src/db_queries/admin_partners_projects';
import { AdminPartnersStudents } from './src/db_queries/admin_partners_students';
import { AdminStudentsCertificates } from './src/db_queries/admin_students_certificates';
import { AdminTrainingReminders } from './src/db_queries/admin_training_reminders';
import { ApprovedUsers } from './src/db_queries/approved_users';
import { Auth } from './src/db_queries/auth';
import { CenterExpenses } from './src/db_queries/center_expenses';
import { CenterExpensesPaid } from './src/db_queries/center_expenses_paid';
import { CourseTypes } from './src/db_queries/course_types';
import { Fields } from './src/db_queries/fields';
import { FieldsGoals } from './src/db_queries/fields_goals';
import { FieldsTutorials } from './src/db_queries/fields_tutorials';
import { Logger } from './src/db_queries/logger';
import { MentorsPartnershipRequests } from './src/db_queries/mentors_partnership_requests';
import { MentorsWaitingRequests } from './src/db_queries/mentors_waiting_requests';
import { OrganizationCenters } from './src/db_queries/organization_centers';
import { Organizations } from './src/db_queries/organizations';
import { PartnersDashboardStats } from './src/db_queries/partners_dashboard_stats';
import { QuizzesSettings } from './src/db_queries/quizzes_settings';
import { Skills } from './src/db_queries/skills';
import { SkillsTutorials } from './src/db_queries/skills_tutorials';
import { Subfields } from './src/db_queries/subfields';
import { SubfieldsTutorials } from './src/db_queries/subfields_tutorials';
import { Tutorials } from './src/db_queries/tutorials';
import { TutorialsLessons } from './src/db_queries/tutorials_lessons';
import { Updates } from './src/db_queries/updates';
import { Users } from './src/db_queries/users';
import { UsersAppFlags } from './src/db_queries/users_app_flags';
import { UsersAppVersions } from './src/db_queries/users_app_versions';
import { UsersAvailableMentors } from './src/db_queries/users_available_mentors';
import { UsersBackgroundProcesses } from './src/db_queries/users_background_processes';
import { UsersCertificatesPauses } from './src/db_queries/users_certificates_pauses';
import { UsersCourses } from './src/db_queries/users_courses';
import { UsersGoals } from './src/db_queries/users_goals';
import { UsersInAppMessages } from './src/db_queries/users_in_app_messages';
import { UsersLessonRequests } from './src/db_queries/users_lesson_requests';
import { UsersLessons } from './src/db_queries/users_lessons';
import { UsersNotificationsSettings } from './src/db_queries/users_notifications_settings';
import { UsersPushNotifications } from './src/db_queries/users_push_notifications';
import { UsersQuizzes } from './src/db_queries/users_quizzes';
import { UsersResetPassword } from './src/db_queries/users_reset_password';
import { UsersSendEmails } from './src/db_queries/users_send_emails';
import { UsersSkills } from './src/db_queries/users_skills';
import { UsersSteps } from './src/db_queries/users_steps';
import { UsersSupportRequests } from './src/db_queries/users_support_requests';
import { UsersTimeZones } from './src/db_queries/users_timezones';
import { reqValidator } from './src/middelwares/req_validator';
dotenv.config();
const port = process.env.PORT;
const app = express();
const auth = new Auth();
const users = new Users();
const approvedUsers = new ApprovedUsers();
const usersTimeZones = new UsersTimeZones();
const usersResetPassword = new UsersResetPassword();
const usersPushNotifications = new UsersPushNotifications();
const usersSendEmails = new UsersSendEmails();
const usersGoals = new UsersGoals();
const usersSteps = new UsersSteps();
const usersQuizzes = new UsersQuizzes();
const usersAvailableMentors = new UsersAvailableMentors();
const usersCourses = new UsersCourses();
const usersLessonRequests = new UsersLessonRequests();
const usersLessons = new UsersLessons();
const usersInAppMessages = new UsersInAppMessages();
const usersCertificatesPauses = new UsersCertificatesPauses();
const usersSkills = new UsersSkills();
const usersNotificationsSettings = new UsersNotificationsSettings();
const usersSupportRequests = new UsersSupportRequests();
const usersAppVersions = new UsersAppVersions();
const usersAppFlags = new UsersAppFlags();
const usersBackgroundProcesses = new UsersBackgroundProcesses();
const mentorsWaitingRequests = new MentorsWaitingRequests();
const mentorsPartnershipRequests = new MentorsPartnershipRequests();
const organizations = new Organizations();
const partnersDashboardStats = new PartnersDashboardStats();
const fields = new Fields();
const subfields = new Subfields();
const skills = new Skills();
const fieldsGoals = new FieldsGoals();
const fieldsTutorials = new FieldsTutorials();
const subfieldsTutorials = new SubfieldsTutorials();
const skillsTutorials = new SkillsTutorials();
const tutorialsLessons = new TutorialsLessons();
const tutorials = new Tutorials();
const quizzesSettings = new QuizzesSettings();
const courseTypes = new CourseTypes();
const updates = new Updates();
const logger = new Logger();
const adminStudentsCertificates = new AdminStudentsCertificates();
const adminTrainingReminders = new AdminTrainingReminders();
const adminPartnersMentors = new AdminPartnersMentors();
const adminPartnersMentorStats = new AdminPartnersMentorStats();
const adminPartnersProjects = new AdminPartnersProjects();
const adminPartnersStudents = new AdminPartnersStudents();
const adminPartnersCenters = new AdminPartnersOrganizationCenters();
const centerExpenses = new CenterExpenses();
const centerExpensesPaid = new CenterExpensesPaid();
const organizationCenters = new OrganizationCenters();
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(cors());
app.get('/', (request: express.Request, response: express.Response): void => {
response.json({ info: 'Node.js, Express, and Postgres API' });
});
const verifyAccessTokenFilter = function (
request: Request,
response: Response,
next: NextFunction
): void {
if (request.originalUrl.includes('/logger')) {
if (request.headers.authorization) {
auth.verifyAccessToken(request, response, next);
} else {
next();
}
} else if (
[
'/approved_user',
'/organizations',
'/signup',
'/login',
'/access_token',
'/send_reset_password',
'/reset_password',
'/tutorials',
'/quizzes_settings'
].some((route) => request.originalUrl.includes(route))
) {
next();
} else {
auth.verifyAccessToken(request, response, next);
}
};
app.use(verifyAccessTokenFilter);
// Approved users
app.post('/api/v1/approved_user', approvedUsers.addApprovedUser);
// Authentication
app.post('/api/v1/signup', auth.signUp);
app.post('/api/v1/login', auth.login);
app.post('/api/v1/logout', auth.logout);
app.get('/api/v1/users/:id/access_token', auth.getAccessToken);
// Users reset password
app.post(
'/api/v1/send_reset_password/:email',
usersResetPassword.addUserResetPassword
);
app.post('/api/v1/reset_password', usersResetPassword.resetPassword);
// Users
app.get('/api/v1/user', users.getUser);
app.put('/api/v1/user', users.updateUser);
app.delete('/api/v1/user', users.deleteUser);
// Users FCM tokens
app.post('/api/v1/fcm_tokens', usersPushNotifications.addFCMToken);
// Users timezones
app.put('/api/v1/timezones', usersTimeZones.updateTimeZone);
// Users goals
app.get('/api/v1/goals', usersGoals.getGoals);
app.get('/api/v1/goals/:id', usersGoals.getGoalById);
app.post('/api/v1/goals', usersGoals.addGoal);
app.put('/api/v1/goals/:id', usersGoals.updateGoal);
app.delete('/api/v1/goals/:id', usersGoals.deleteGoal);
app.delete('/api/v1/goals', usersGoals.deleteGoals);
// Users steps
app.get('/api/v1/goals/:id/steps', usersSteps.getSteps);
app.get('/api/v1/steps/all', usersSteps.getAllSteps);
app.get('/api/v1/steps/:id', usersSteps.getStepById);
app.post('/api/v1/goals/:id/steps', usersSteps.addStep);
app.put('/api/v1/steps/:id', usersSteps.updateStep);
app.delete('/api/v1/steps/:id', usersSteps.deleteStep);
app.delete('/api/v1/goals/:id/steps', usersSteps.deleteSteps);
app.get('/api/v1/last_step_added', usersSteps.getLastStepAdded);
// Users quizzes
app.get('/api/v1/quizzes', usersQuizzes.getQuizzes);
app.get('/api/v1/quiz_number', usersQuizzes.getQuizNumber);
app.post('/api/v1/quizzes', usersQuizzes.addQuiz);
// Users courses
app.post('/api/v1/courses', usersCourses.getAvailableCourses);
app.get('/api/v1/courses/fields', usersCourses.getAvailableCoursesFields);
app.get('/api/v1/courses/current', usersCourses.getCurrentCourse);
app.get('/api/v1/courses/previous', usersCourses.getPreviousCourse);
app.get('/api/v1/courses/next_lesson', usersCourses.getNextLesson);
app.get(
'/api/v1/courses/:id/mentor_partnership_schedule',
usersCourses.getCourseLessons
);
app.get('/api/v1/courses/:id/notes', usersCourses.getNotes);
app.post('/api/v1/courses/add', usersCourses.addCourse);
app.put('/api/v1/courses/:id/join', usersCourses.joinCourse);
app.put('/api/v1/courses/:id/meeting_url', usersCourses.setMeetingUrl);
app.put(
'/api/v1/courses/:id/whatsapp_group_url',
usersCourses.setWhatsAppGroupUrl
);
app.put('/api/v1/courses/:id/notes', usersCourses.updateNotes);
app.put('/api/v1/courses/:id/cancel', usersCourses.cancelCourse);
app.put(
'/api/v1/courses/:id/cancel_next_lesson',
usersCourses.cancelNextLesson
);
app.put(
'/api/v1/mentor_partnership_schedule',
usersCourses.updateCourseLessons
);
// Users available mentors
app.post(
'/api/v1/available_mentors',
usersAvailableMentors.getAvailableMentors
);
app.get(
'/api/v1/available_mentors/fields',
usersAvailableMentors.getAvailableMentorsFields
);
// Users lesson requests
app.post('/api/v1/lesson_requests', usersLessonRequests.addLessonRequest);
app.get('/api/v1/lesson_request', usersLessonRequests.getLessonRequest);
app.post(
'/api/v1/lesson_requests/send_custom_lesson_request',
usersLessonRequests.sendCustomLessonRequest
);
app.post(
'/api/v1/lesson_requests/:id/accept_lesson_request',
usersLessonRequests.acceptLessonRequest
);
app.put(
'/api/v1/lesson_requests/:id/reject_lesson_request',
usersLessonRequests.rejectLessonRequest
);
app.put(
'/api/v1/lesson_requests/:id/cancel_lesson_request',
usersLessonRequests.cancelLessonRequest
);
app.put(
'/api/v1/lesson_requests/:id/update_lesson_request',
usersLessonRequests.updateLessonRequest
);
// Users lessons
app.get('/api/v1/next_lesson', usersLessons.getNextLesson);
app.get('/api/v1/previous_lesson', usersLessons.getPreviousLesson);
app.put('/api/v1/lessons/:id/cancel_lesson', usersLessons.cancelLesson);
app.put('/api/v1/lessons/:id/meeting_url', usersLessons.setLessonUrl);
app.put('/api/v1/lessons/:id/recurrence', usersLessons.setLessonRecurrence);
app.put('/api/v1/lessons/:id/skills', usersLessons.addStudentsSkills);
app.post('/api/v1/lessons/:id/notes', usersLessons.addStudentsLessonNotes);
app.get('/api/v1/users/:id/lessons_notes', usersLessons.getStudentLessonNotes);
app.get(
'/api/v1/lessons/:id/guide_tutorials',
usersLessons.getLessonGuideTutorials
);
app.get(
'/api/v1/lessons/:id/guide_recommendations',
usersLessons.getLessonGuideRecommendations
);
app.put(
'/api/v1/lessons/:id/mentor_presence',
usersLessons.setLessonPresenceMentor
);
// Users certificates pauses
app.get(
'/api/v1/certificate_pause',
usersCertificatesPauses.getUserCertificatePause
);
app.post(
'/api/v1/certificate_pause',
usersCertificatesPauses.addUserCertificatePause
);
// Users in-app messages
app.get('/api/v1/in_app_messages', usersInAppMessages.getUserInAppMessage);
app.post('/api/v1/in_app_messages', usersInAppMessages.addUserInAppMessage);
app.delete(
'/api/v1/in_app_messages',
usersInAppMessages.deleteUserInAppMessage
);
// Users skills
app.get(
'/api/v1/users/:user_id/subfields/:subfield_id/skills',
usersSkills.getUserSkills
);
app.post('/api/v1/user/subfields/:id/skills', usersSkills.addUserSkills);
// Users notifications settings
app.get(
'/api/v1/notifications_settings',
usersNotificationsSettings.getNotificationsSettings
);
app.put(
'/api/v1/notifications_settings',
usersNotificationsSettings.updateNotificationsSettings
);
// Users support requests
app.post('/api/v1/support_requests', usersSupportRequests.addSupportRequest);
// Users app flags
app.get('/api/v1/app_flags', usersAppFlags.getAppFlags);
// Mentors waiting requests
app.post(
'/api/v1/mentors_waiting_requests',
mentorsWaitingRequests.getMentorsWaitingRequests
);
app.get(
'/api/v1/mentors_waiting_requests/current',
mentorsWaitingRequests.getCurrentMentorWaitingRequest
);
app.post(
'/api/v1/mentors_waiting_requests/add',
mentorsWaitingRequests.addMentorWaitingRequest
);
app.put(
'/api/v1/mentors_waiting_requests/cancel',
mentorsWaitingRequests.cancelMentorWaitingRequest
);
// Mentors partnership requests
app.get(
'/api/v1/mentors_partnership_requests/current',
mentorsPartnershipRequests.getCurrentMentorPartnershipRequest
);
app.post(
'/api/v1/mentors_partnership_requests',
mentorsPartnershipRequests.sendMentorPartnershipRequest
);
app.post(
'/api/v1/mentors_partnership_requests/:id/accept',
mentorsPartnershipRequests.acceptMentorPartnershipRequest
);
app.put(
'/api/v1/mentors_partnership_requests/:id/reject',
mentorsPartnershipRequests.rejectMentorPartnershipRequest
);
app.put(
'/api/v1/mentors_partnership_requests/:id/cancel',
mentorsPartnershipRequests.cancelMentorPartnershipRequest
);
app.put(
'/api/v1/mentors_partnership_requests/:id/update',
mentorsPartnershipRequests.updateMentorPartnershipRequest
);
// Organizations
app.get('/api/v1/organizations/id/:id', organizations.getOrganizationById);
app.get(
'/api/v1/organizations/name/:name',
organizations.getOrganizationByName
);
// Organizations Centers
app.get(
'/api/v1/organizations/:id/centers',
organizations.getOrganizationCentersByOrganizationId
);
// Partners
app.get(
'/api/v1/partners/dashboard/stats',
partnersDashboardStats.getDashboardStats
);
app.get(
'/api/v1/partners/:partner_id/dashboard/stats',
partnersDashboardStats.getDashboardStatsByPartnerId
);
// Returns the location of the org centers of _all_ the partners
// that have had at least one active student.
// Filtering by date is possible.
app.get(
'/api/v1/partners/dashboard/organization-centers',
adminPartnersCenters.getDashboardOrganizationCenters
);
// Returns the location of the org centers of _a specific_ partner
// that have had at least one active student.
// Filtering by date is possible.
app.get(
'/api/v1/partners/:partner_id/dashboard/organization-centers',
adminPartnersCenters.getDashboardOrganizationCentersByPartnerId
);
// Fields
app.get('/api/v1/fields', fields.getFields);
app.get('/api/v1/fields_goals', fieldsGoals.getFieldsGoals);
app.get('/api/v1/fields/:id', fields.getFieldById);
app.post('/api/v1/fields', fields.addField);
app.put('/api/v1/fields/:id', fields.updateField);
app.delete('/api/v1/fields/:id', fields.deleteField);
// Subfields
app.get('/api/v1/fields/:id/subfields', subfields.getSubfields);
app.get('/api/v1/subfields/:id', subfields.getSubfieldById);
app.post('/api/v1/fields/:id/subfields', subfields.addSubfield);
app.put('/api/v1/subfields/:id', subfields.updateSubfield);
app.delete('/api/v1/subfields/:id', subfields.deleteSubfield);
// Skills
app.get('/api/v1/subfields/:id/skills', skills.getSkills);
app.get('/api/v1/skills/:id', skills.getSkillById);
app.post('/api/v1/subfields/:id/skills', skills.addSkill);
app.put('/api/v1/skills/:id', skills.updateSkill);
app.delete('/api/v1/skills/:id', skills.deleteSkill);
// Fields tutorials
app.get('/api/v1/fields_tutorials', fieldsTutorials.getFieldsTutorials);
app.get('/api/v1/fields_tutorials/:id', fieldsTutorials.getFieldTutorialById);
app.post('/api/v1/fields_tutorials', fieldsTutorials.addFieldTutorial);
app.put('/api/v1/fields_tutorials/:id', fieldsTutorials.updateFieldTutorial);
app.delete('/api/v1/fields_tutorials/:id', fieldsTutorials.deleteFieldTutorial);
// Subfields tutorials
app.get(
'/api/v1/subfields_tutorials',
subfieldsTutorials.getSubfieldsTutorials
);
app.get(
'/api/v1/subfields_tutorials/:id',
subfieldsTutorials.getSubfieldTutorialById
);
app.post('/api/v1/subfields_tutorials', subfieldsTutorials.addSubfieldTutorial);
app.put(
'/api/v1/subfields_tutorials/:id',
subfieldsTutorials.updateSubfieldTutorial
);
app.delete(
'/api/v1/subfields_tutorials/:id',
subfieldsTutorials.deleteSubfieldTutorial
);
// Skills tutorials
app.get('/api/v1/skills_tutorials', skillsTutorials.getSkillsTutorials);
app.get('/api/v1/skills_tutorials/:id', skillsTutorials.getSkillTutorialById);
app.post('/api/v1/skills_tutorials', skillsTutorials.addSkillTutorial);
app.put('/api/v1/skills_tutorials/:id', skillsTutorials.updateSkillTutorial);
app.delete('/api/v1/skills_tutorials/:id', skillsTutorials.deleteSkillTutorial);
// Tutorials lessons
app.get('/api/v1/tutorials_lessons', tutorialsLessons.getTutorialsLessons);
// Tutorials
app.get('/api/v1/tutorials', tutorials.getTutorials);
// Quizzes settings
app.get('/api/v1/quizzes_settings', quizzesSettings.getQuizzesSettings);
// Courses types
app.get('/api/v1/course_types', courseTypes.getCourseTypes);
// Updates
app.get('/api/v1/updates', updates.getUpdates);
// Users app versions
app.post('/api/v1/app_versions', usersAppVersions.addAppVersion);
// Logger
app.post('/api/v1/logger', logger.addLogEntry);
// Users background processes
app.post(
'/api/v1/send_training_reminders',
usersBackgroundProcesses.sendAllTrainingReminders
);
app.post(
'/api/v1/send_course_lesson_reminders',
usersBackgroundProcesses.sendNextCourseLessonReminders
);
app.post(
'/api/v1/send_lesson_request_reminders',
usersBackgroundProcesses.sendAllLessonRequestReminders
);
app.post(
'/api/v1/send_lesson_reminders',
usersBackgroundProcesses.sendAllLessonReminders
);
app.post(
'/api/v1/available_courses/fields',
usersBackgroundProcesses.setAvailableCoursesFields
);
app.post(
'/api/v1/available_mentors/fields',
usersBackgroundProcesses.setAvailableMentorsFields
);
cron.schedule('* * * * *', async () => {
await usersBackgroundProcesses.sendAllTrainingRemindersFromDB();
await usersBackgroundProcesses.sendNextCourseLessonRemindersFromDB();
await usersBackgroundProcesses.sendAllLessonRequestRemindersFromDB();
await usersBackgroundProcesses.sendAllLessonRemindersFromDB();
usersBackgroundProcesses.sendCPUUsage();
});
cron.schedule('*/5 * * * *', function () {
usersCourses.setAvailableCoursesFieldsFromDB();
usersAvailableMentors.setAvailableMentorsFieldsFromDB();
});
// Admin students certificates
app.get(
'/api/v1/admin/students_certificates',
adminStudentsCertificates.getStudentsCertificates
);
app.get(
'/api/v1/admin/students_certificates/certificate_sent',
adminStudentsCertificates.getCertificateSent
);
app.put(
'/api/v1/admin/students_certificates/:student_id/certificate_sent',
adminStudentsCertificates.updateCertificateSent
);
app.post(
'/api/v1/admin/students_certificates/:student_id/create',
adminStudentsCertificates.createCertificate
);
app.post(
'/api/v1/admin/students_certificates/:student_id/send',
adminStudentsCertificates.sendCertificate
);
app.get(
'/api/v1/admin/students_certificates/:student_id/download',
adminStudentsCertificates.downloadCertificate
);
// Admin training reminders
app.get(
'/api/v1/admin/training_reminders',
adminTrainingReminders.getTrainingReminders
);
app.get(
'/api/v1/admin/all_training_reminders',
adminTrainingReminders.getAllTrainingReminders
);
app.get(
'/api/v1/admin/:trainer_id/training_reminders',
adminTrainingReminders.getTrainingReminders
);
app.get(
'/api/v1/admin/:trainer_id/all_training_reminders',
adminTrainingReminders.getAllTrainingReminders
);
app.get('/api/v1/admin/trainers', adminTrainingReminders.getTrainers);
app.post('/api/v1/admin/conversations', adminTrainingReminders.addConversation);
app.put(
'/api/v1/admin/training_reminders/:id/last_contacted',
adminTrainingReminders.updateLastContacted
);
// Admin partners' mentors
app.get(
'/api/v1/partners/:partner_id/mentors',
adminPartnersMentors.getAllMentorsOfOnePartner
);
// Admin partners' mentor stats
app.get(
'/api/v1/partners/:partner_id/mentors/stats',
adminPartnersMentorStats.getAllMentorsStatsOfOnePartner
);
// Mentor details
app.get(
'/api/v1/partners/:partner_id/mentors/:mentor_id',
adminPartnersMentors.getMentorDetails
);
// Admin partners' students
app.get(
'/api/v1/partners/:partner_id/students',
adminPartnersStudents.getAllStudentsOfOnePartner
);
// Admin - Get partner projects
app.get(
'/api/v1/partners/:partner_id/projects',
adminPartnersProjects.getAllProjectsOfOnePartner
);
// Admin - Create partner project
app.post(
'/api/v1/partners/:partner_id/projects',
adminPartnersProjects.createProjectOfOnePartner
);
// Tests notifications
app.post(
'/api/v1/test/:user_id/send_push_notification',
usersPushNotifications.sendPNTest
);
app.post('/api/v1/test/:user_id/send_email', usersSendEmails.sendEmailTest);
// Center expenses paid
app.get(
'/api/v1/centers/:center_id/expenses/paid',
centerExpensesPaid.getCenterExpensesPaid
);
app.patch(
'/api/v1/centers/:center_id/expenses/paid',
reqValidator(centerExpensesPaid.updateCenterExpensesPaidSchema),
centerExpensesPaid.updateCenterExpensesPaid
);
// Center Expenses
app.get(
'/api/v1/centers/:center_id/expenses',
centerExpenses.getCenterExpenses
);
app.post(
'/api/v1/centers/:center_id/expenses',
reqValidator(centerExpenses.createCenterExpensesValidationSchema),
centerExpenses.createCenterExpense
);
app.patch(
'/api/v1/centers/:center_id/expenses/:expense_id',
reqValidator(centerExpenses.updateCenterExpensesValidationSchema),
centerExpenses.updateCenterExpense
);
app.delete(
'/api/v1/centers/:center_id/expenses/:expense_id',
centerExpenses.deleteCenterExpense
);
app.get(
'/api/v1/centers/:center_id/expenses/balance',
centerExpenses.getCenterExpensesBalance
);
app.get('/api/v1/centers', organizationCenters.getOrganizationCenters);
app.listen(port, () => {
console.log(`App running on port ${port}.`);
});