Skip to content

Commit

Permalink
Prettified
Browse files Browse the repository at this point in the history
  • Loading branch information
kobudnik committed Feb 8, 2023
1 parent f294c36 commit 6be61cf
Show file tree
Hide file tree
Showing 92 changed files with 2,422 additions and 2,143 deletions.
29 changes: 10 additions & 19 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,22 @@ module.exports = {
es2021: true,
node: true,
},
plugins: [
'react',
'@typescript-eslint'
],
plugins: ['react', '@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended'
],
ignorePatterns: [
'.eslintrc.js',
'*.config.js',
'dist/*',
'__tests__/*'
],
overrides: [
'plugin:@typescript-eslint/recommended',
],
ignorePatterns: ['.eslintrc.js', '*.config.js', 'dist/*', '__tests__/*'],
overrides: [],
parserOptions: {
ecmaVersion: 12,
sourceType: 'module'
sourceType: 'module',
},
settings: {
react: {
version: 'detect'
}
version: 'detect',
},
},
rules: {
indent: ['warn', 2],
Expand Down Expand Up @@ -65,7 +56,7 @@ module.exports = {

// ---- TYPESCRIPT ---- //
'@typescript-eslint/explicit-function-return-type': 'off',
"@typescript-eslint/no-unused-vars": "error",
'@typescript-eslint/semi': ['warn', 'always']
}
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/semi': ['warn', 'always'],
},
};
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: node_js

node_js:
- 16

env:
global: PATH=/opt/python/3.7.1/bin:$PATH

Expand Down
26 changes: 13 additions & 13 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ root

```js
// .env
TWILIO_NUMBER = "";
TWILIO_ACCOUNT_SID = "";
TWILIO_AUTH_TOKEN = "";
SERVICE_SID = "";
VERIFICATION_SERVICE_SID = "";
SLACK_WEBHOOK = "";
POSTGRES_URI = "";
TWILIO_NUMBER = '';
TWILIO_ACCOUNT_SID = '';
TWILIO_AUTH_TOKEN = '';
SERVICE_SID = '';
VERIFICATION_SERVICE_SID = '';
SLACK_WEBHOOK = '';
POSTGRES_URI = '';
```

5. Create a folder called `security` in the project's top-level directory. Inside of the `security` folder, create two files `email.js` and `sysadmin.js`. These files will store variables related to the email notification service and system admin setup respectively.
Expand All @@ -82,10 +82,10 @@ root
```js
// email.js
module.exports = {
host: "smtp.gmail.com",
host: 'smtp.gmail.com',
port: 465,
username: "[email protected]",
password: "belugas",
username: '[email protected]',
password: 'belugas',
};
```

Expand All @@ -94,8 +94,8 @@ module.exports = {
```js
// sysadmin.js
module.exports = {
phone: "",
email: "",
phone: '',
email: '',
};
```

Expand All @@ -115,11 +115,11 @@ For now, the sign up function will create a System Admin user.

```js
// .env.js
MY_PHONE_NUMBER = "your mobile number";
TWILIO_ACCOUNT_SID = "code from your console";
TWILIO_AUTH_TOKEN = "token from your console";
SERVICE_SID = "code from notify service instance";
VERIFICATION_SERVICE_SID = "code from verify service instance";
MY_PHONE_NUMBER = 'your mobile number';
TWILIO_ACCOUNT_SID = 'code from your console';
TWILIO_AUTH_TOKEN = 'token from your console';
SERVICE_SID = 'code from notify service instance';
VERIFICATION_SERVICE_SID = 'code from verify service instance';
```

4. Verification service was created [here](https://www.twilio.com/console/verify/services); code length and serviceSID can be taken from your Twilio account console.
Expand Down
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module.exports = {
presets: [
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-typescript'
]
'@babel/preset-typescript',
],
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@
"\\.(css|scss)$": "<rootDir>/__mocks__/styleMock.js"
}
}
}
}
23 changes: 13 additions & 10 deletions server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ app.use(cors());

app.use('/test', (req: Request, res: Response) => {
res.status(200).json({
success: true
success: true,
});
});

Expand All @@ -48,15 +48,18 @@ app.use('/', (req: Request, res: Response) => {
return res.status(404).redirect('/');
});

app.get('/', (err: ServerError, req: Request, res: Response, next: NextFunction) => {
const defaultErr = {
log: 'Express error handler caught unknown middleware error',
status: 500,
message: { err: 'An error occured' }
};
const errorObj: ServerError = Object.assign(defaultErr, err);
return res.status(errorObj.status).json(errorObj.message);
});
app.get(
'/',
(err: ServerError, req: Request, res: Response, next: NextFunction) => {
const defaultErr = {
log: 'Express error handler caught unknown middleware error',
status: 500,
message: { err: 'An error occured' },
};
const errorObj: ServerError = Object.assign(defaultErr, err);
return res.status(errorObj.status).json(errorObj.message);
},
);

export default app;

Expand Down
18 changes: 9 additions & 9 deletions server/controllers/apiController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Request, Response, NextFunction } from 'express';
import nodemailer from "nodemailer";
import email from "../../security/email";
import nodemailer from 'nodemailer';
import email from '../../security/email';
import { ApiController, ServerError } from '../../types';

// create transporter object to make sure these values are filled out in email.js
Expand All @@ -26,7 +26,7 @@ const apiController: ApiController = {
const { email, containerName, time, date, stopped } = req.body;
let emailBody;

if (stopped === "true") {
if (stopped === 'true') {
emailBody = `
<h2>Alert: ${containerName} has stopped!</h2>
<h3>Container <b>${containerName}</b> stopped running at <b>${time}</b> on <b>${date}</b>.</h3>
Expand All @@ -47,9 +47,9 @@ const apiController: ApiController = {
}

const mailDetails = {
from: "[email protected]",
from: '[email protected]',
to: email,
subject: "Docketeer: Container Issue",
subject: 'Docketeer: Container Issue',
html: `${emailBody}`,
};

Expand All @@ -62,7 +62,7 @@ const apiController: ApiController = {
return next({
log: `Error in apiController sendEmailAlert: ${err}`,
message: {
err: "An error occured creating new user in database. See apiController.sendEmailAlert.",
err: 'An error occured creating new user in database. See apiController.sendEmailAlert.',
},
});
});
Expand All @@ -73,9 +73,9 @@ const apiController: ApiController = {
const { email, username, password } = req.body;

const mailDetails = {
from: "[email protected]",
from: '[email protected]',
to: email,
subject: "Docketeer: Account Details",
subject: 'Docketeer: Account Details',
html: `
<h1>Welcome to Docketeer</h1>
<p>We are so excited to have you onboard!</p>
Expand All @@ -96,7 +96,7 @@ const apiController: ApiController = {
return next({
log: `Error in apiController signupEmail: ${err}`,
message: {
err: "An error occured creating new user in database. See apiController.signupEmail.",
err: 'An error occured creating new user in database. See apiController.signupEmail.',
},
});
});
Expand Down
22 changes: 11 additions & 11 deletions server/controllers/bcryptController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* @module Bcrypt Controller
* @description Contains middleware that encrypts password before storing in database and compares a user's inputted password to their stored password
*/
import db from "../models/cloudModel";
import bcrypt from "bcryptjs";
import { Request, Response, NextFunction } from "express";
import { BcryptController } from "../../types";
import db from '../models/cloudModel';
import bcrypt from 'bcryptjs';
import { Request, Response, NextFunction } from 'express';
import { BcryptController } from '../../types';

const bcryptController: BcryptController = {
// Hash user password with bCrypt
Expand All @@ -23,7 +23,7 @@ const bcryptController: BcryptController = {
return next({
log: `Error in bcryptController hashPassword: ${err}`,
message: {
err: "An error occured creating hash with bcrypt. See bcryptController.hashPassword.",
err: 'An error occured creating hash with bcrypt. See bcryptController.hashPassword.',
},
});
});
Expand All @@ -32,7 +32,7 @@ const bcryptController: BcryptController = {
// Hash new user password with bCrypt - User updated password
hashNewPassword : async (req: Request, res: Response, next: NextFunction) => {
// if there is an error property on res.locals, return next(). i.e., incorrect password entered
if (Object.prototype.hasOwnProperty.call(res.locals, "error")) {
if (Object.prototype.hasOwnProperty.call(res.locals, 'error')) {
return next();
}
// else bCrypt the new password and move to next middleware
Expand All @@ -49,7 +49,7 @@ const bcryptController: BcryptController = {
return next({
log: `Error in bcryptController hashNewPassword: ${err}`,
message: {
err: "An error occured creating hash with bcrypt. See bcryptController.hashNewPassword.",
err: 'An error occured creating hash with bcrypt. See bcryptController.hashNewPassword.',
},
});
});
Expand All @@ -68,9 +68,9 @@ const bcryptController: BcryptController = {
.then((hash) => {
res.locals.user.token = hash;
db.query(
"ALTER TABLE users ADD COLUMN IF NOT EXISTS token varchar(250)"
'ALTER TABLE users ADD COLUMN IF NOT EXISTS token varchar(250)'
);
db.query("UPDATE users SET token=$1 WHERE username=$2", [
db.query('UPDATE users SET token=$1 WHERE username=$2', [
res.locals.user.token,
username,
]);
Expand All @@ -80,10 +80,10 @@ const bcryptController: BcryptController = {
return next({
log: `Error in bcryptController hashCookeis: ${err}`,
message: {
err: "An error occured creating hash with bcrypt. See bcryptController.hashCookies.",
err: 'An error occured creating hash with bcrypt. See bcryptController.hashCookies.',
},
});
})
});
} else {
return next();
}
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/commandController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @module initDatabase Controller
* @description Contains middleware that creates and runs the local database
*/
import { Request, Response, NextFunction } from "express";
import { CommandController, ServerError } from "../../types";
import { Request, Response, NextFunction } from 'express';
import { CommandController, ServerError } from '../../types';
import { exec } from 'child_process';
import { net } from 'electron';
import { constants } from 'fs/promises';
Expand Down
Loading

0 comments on commit 6be61cf

Please sign in to comment.