Skip to content

Commit 40ed587

Browse files
authored
Merge branch 'development' into Style-manager-access-MUI-Switch-to-match-Figma-design
2 parents be8d5ea + 5fa8828 commit 40ed587

84 files changed

Lines changed: 7174 additions & 5461 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.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ test.db
1414
videos/
1515
screenshots/
1616
vrms.code-workspace
17-
.vscode/
17+
.vscode/
18+
backend/swagger-output.json

backend/app.js

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1-
21
// app.js - Entry point for our application
32

3+
import { createRequire } from 'module';
4+
import cookieParser from 'cookie-parser';
45
// Load in all of our node modules. Their uses are explained below as they are called.
5-
const express = require('express');
6-
const morgan = require('morgan');
7-
const cron = require('node-cron');
8-
const fetch = require('node-fetch');
9-
const cookieParser = require('cookie-parser');
6+
import express from 'express';
7+
import morgan from 'morgan';
8+
import cron from 'node-cron';
9+
import fetch from 'node-fetch';
10+
import swaggerUi from 'swagger-ui-express';
11+
12+
const require = createRequire(import.meta.url);
13+
let swaggerDocument;
14+
try {
15+
swaggerDocument = require('./swagger-output.json');
16+
} catch (e) {
17+
console.warn('swagger-output.json not found. Run "npm run swagger" to generate it.');
18+
swaggerDocument = null;
19+
}
1020

1121
const customRequestHeaderName = 'x-customrequired-header';
12-
const dontCheckCustomRequestHeaderApis = ['GET::/api/recurringevents', 'GET::/api/healthcheck'];
13-
14-
// Import environment variables
15-
const dotenv = require('dotenv');
16-
const dotenvExpand = require('dotenv-expand');
17-
18-
const myEnv = dotenv.config();
19-
dotenvExpand(myEnv);
22+
const dontCheckCustomRequestHeaderApis = [
23+
'GET::/api/recurringevents',
24+
'GET::/api/healthcheck',
25+
'GET::/api-docs',
26+
'GET::/api-docs/',
27+
];
2028

2129
// Verify environment variables
22-
require('assert-env')([
30+
import assertEnv from 'assert-env';
31+
assertEnv([
2332
'CUSTOM_REQUEST_HEADER',
2433
'SLACK_OAUTH_TOKEN',
2534
'SLACK_BOT_TOKEN',
@@ -52,37 +61,41 @@ app.use(cookieParser());
5261
// HTTP Request Logger
5362
app.use(morgan('dev'));
5463

55-
// WORKERS
56-
const runOpenCheckinWorker = require('./workers/openCheckins');
57-
runOpenCheckinWorker(cron, fetch);
58-
59-
const runCloseCheckinWorker = require('./workers/closeCheckins');
60-
runCloseCheckinWorker(cron, fetch);
64+
// Swagger API Documentation
65+
if (swaggerDocument) {
66+
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
67+
}
6168

62-
const { createRecurringEvents } = require('./workers/createRecurringEvents');
63-
createRecurringEvents(cron, fetch);
64-
// const runSlackBot = require("./workers/slackbot")(fetch);
69+
import closeCheckins from './workers/closeCheckins.js';
70+
import createRecurringEvents from './workers/createRecurringEvents.js';
71+
// WORKERS
72+
import openCheckins from './workers/openCheckins.js';
73+
const runOpenCheckinWorker = openCheckins(cron, fetch);
74+
const runCloseCheckinWorker = closeCheckins(cron, fetch);
75+
const runCreateRecurringEventsWorker = createRecurringEvents(cron, fetch);
76+
// import slackbot from './workers/slackbot.js';
77+
// const runSlackBot = slackbot(fetch);
6578

6679
// Run cleanup expired refresh token(s) on startup
67-
const { cleanupExpiredTokens } = require('./workers/tokenCleanup');
80+
import { cleanupExpiredTokens } from './workers/tokenCleanup.js';
6881
cleanupExpiredTokens();
6982

7083
// MIDDLEWARE
71-
const errorhandler = require('./middleware/errorhandler.middleware');
84+
import errorhandler from './middleware/errorhandler.middleware.js';
7285

86+
//import slackRouter from './routers/slack.router.js';
87+
import authRouter from './routers/auth.router.js';
88+
import checkInsRouter from './routers/checkIns.router.js';
89+
import checkUserRouter from './routers/checkUser.router.js';
7390
// ROUTES
74-
const eventsRouter = require('./routers/events.router');
75-
const checkInsRouter = require('./routers/checkIns.router');
76-
const usersRouter = require('./routers/users.router');
77-
const questionsRouter = require('./routers/questions.router');
78-
const checkUserRouter = require('./routers/checkUser.router');
79-
const grantPermissionRouter = require('./routers/grantpermission.router');
80-
const projectsRouter = require('./routers/projects.router');
81-
const recurringEventsRouter = require('./routers/recurringEvents.router');
82-
const projectTeamMembersRouter = require('./routers/projectTeamMembers.router');
83-
//const slackRouter = require("./routers/slack.router");
84-
const authRouter = require('./routers/auth.router');
85-
const healthCheckRouter = require('./routers/healthCheck.router');
91+
import eventsRouter from './routers/events.router.js';
92+
import grantPermissionRouter from './routers/grantpermission.router.js';
93+
import healthCheckRouter from './routers/healthCheck.router.js';
94+
import projectTeamMembersRouter from './routers/projectTeamMembers.router.js';
95+
import projectsRouter from './routers/projects.router.js';
96+
import questionsRouter from './routers/questions.router.js';
97+
import recurringEventsRouter from './routers/recurringEvents.router.js';
98+
import usersRouter from './routers/users.router.js';
8699

87100
// Check that clients to the API are sending the custom request header on all methods
88101
// except for ones described in the dontCheckCustomRequestHeaderApis array.
@@ -132,4 +145,4 @@ app.get('*', (req, res, next) => {
132145

133146
app.use(errorhandler);
134147

135-
module.exports = app;
148+
export default app;

backend/config/auth.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
JWT_SECRET: process.env.JWT_SECRET || 'placeholder_secret_key_for_development_only',
33
CUSTOM_REQUEST_HEADER: process.env.CUSTOM_REQUEST_HEADER,
44
// 15 minutes as a string for JWT expiration

backend/config/auth.config.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { describe, it, expect, vi, beforeAll, beforeEach, afterAll, afterEach, test } from 'vitest';
2+
13
test.skip('Environment variables are working as expected', () => {
24
const backendUrl = process.env.REACT_APP_PROXY;
35
expect(backendUrl).toBe(`http://localhost:${process.env.BACKEND_PORT}`);

backend/config/database.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
exports.PORT = process.env.BACKEND_PORT;
2-
exports.DATABASE_URL = process.env.DATABASE_URL;
1+
export default {
2+
PORT: process.env.BACKEND_PORT,
3+
DATABASE_URL: process.env.DATABASE_URL,
4+
};

backend/config/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const CONFIG_AUTH = require('./auth.config');
2-
const CONFIG_DB = require('./database.config');
1+
import CONFIG_AUTH from './auth.config.js';
2+
import CONFIG_DB from './database.config.js';
33

4-
module.exports = {
4+
export {
55
CONFIG_AUTH,
66
CONFIG_DB,
77
};

backend/controllers/email.controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const nodemailer = require('nodemailer');
2-
const { google } = require('googleapis');
1+
import nodemailer from 'nodemailer';
2+
import { google } from 'googleapis';
33

44
const { OAuth2 } = google.auth;
55

@@ -130,4 +130,4 @@ const EmailController = {
130130
sendLoginLink,
131131
sendEmail,
132132
};
133-
module.exports = EmailController;
133+
export default EmailController;

backend/controllers/email.controller.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const EmailController = require('./email.controller');
1+
import { describe, it, expect, vi, beforeAll, beforeEach, afterAll, afterEach, test } from 'vitest';
2+
import EmailController from './email.controller.js';
23

34
test('Can import the email controller', async () => {
45
expect(EmailController).not.toBeUndefined();

backend/controllers/event.controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Event } = require('../models');
1+
import { Event } from '../models/index.js';
22

33
const EventController = {};
44

@@ -79,4 +79,4 @@ EventController.update = async function (req, res) {
7979
}
8080
};
8181

82-
module.exports = EventController;
82+
export default EventController;

backend/controllers/event.controller.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const EventController = require('./event.controller');
1+
import { describe, it, expect, vi, beforeAll, beforeEach, afterAll, afterEach, test } from 'vitest';
2+
import EventController from './event.controller.js';
23

34
test('Can import the email controller', async () => {
45
expect(EventController).not.toBeUndefined();

0 commit comments

Comments
 (0)