Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
palmertab committed Sep 26, 2024
1 parent b1e2e28 commit 07545ba
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 73 deletions.
7 changes: 5 additions & 2 deletions api/controllers/glp/servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,16 @@ export const changeInstanceCount = {
});
}

const resultMessages = [];
const resultMessages = [
`${req.session.person.first} ${req.session.person.last} has initiated a cloud services change:`,
'\n',
];

const destroyMe = [];

while (hostnames.includes(`${config.LINODE.WEBHOST_BASE}${serialNumber}`)) {

const hostname = `${config.LINODE.WEBHOST_BASE}${serialNumber}`;

const matches = tabwebs.filter(
host => host.label === hostname
);
Expand Down
32 changes: 25 additions & 7 deletions api/controllers/user/account/getProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export const getProfile = {
if (!req.session) {
return res.status(201).json({ message: 'You have no active user session' });
}
let result;
let person;

if (req.params.person_id && req.session.site_admin) {
result = await req.db.person.findByPk(
person = await req.db.person.findByPk(
req.params.person_id,
{
include: [{
Expand All @@ -20,7 +20,7 @@ export const getProfile = {
} else if (req.params.person_id ) {
return res.status(201).json({ message: 'Only admin staff may access another profile' });
} else if (req.session.person) {
result = await req.db.person.findByPk(req.session.person,
person = await req.db.person.findByPk(req.session.person,
{
include: [{
model: req.db.personSetting,
Expand All @@ -30,14 +30,32 @@ export const getProfile = {
);
}

if (result.count < 1) {
if (person.count < 1) {
return res.status(400).json({ message: 'User does not exist' });
}

const jsonOutput = result.toJSON();
delete jsonOutput.password;
const personData = person.dataValues;

return res.status(200).json(jsonOutput);
personData.settings = {};

console.log(personData.Settings);

for (const set of personData.Settings) {
const setting = set.dataValues;

if (setting.value === 'text' || setting.value === 'json') {
personData.settings[setting.tag] = setting.alue_text;
} else if (setting.value === 'date') {
personData.settings[setting.tag] = setting.value_date;
} else if (setting.value) {
personData.settings[setting.tag] = setting.value;
}
}

delete personData.Settings;
delete personData.password;

return res.status(200).json(personData);
},
};

Expand Down
4 changes: 1 addition & 3 deletions api/helpers/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const promises = files
);
})
.map((file) => {
return import(join(process.cwd(), 'api/models', file));
return import(join(process.cwd(), `${config.CODE_PATH || '.'}/api/models`, file));
});

const modules = await Promise.all(promises);
Expand Down Expand Up @@ -326,7 +326,6 @@ db.rpool.belongsToMany(db.round, { as: 'Rounds', foreignKey: 'rpool', through: '

// Registration data
db.school.hasMany(db.entry , { as: 'Entries' , foreignKey: 'school' });
db.school.hasMany(db.rating , { as: 'Ratings' , foreignKey: 'school' });
db.school.hasMany(db.fine , { as: 'Fines' , foreignKey: 'school' });
db.school.hasMany(db.strike , { as: 'Strikes' , foreignKey: 'school' });
db.school.hasMany(db.changeLog , { as: 'ChangeLogs' , foreignKey: 'school' });
Expand Down Expand Up @@ -478,7 +477,6 @@ db.invoice.belongsTo(db.school, { as: 'School', foreignKey: 'school' });

// Pref Sheets
db.rating.belongsTo(db.tourn, { as: 'Tourn', foreignKey: 'tourn' });
db.rating.belongsTo(db.school, { as: 'School', foreignKey: 'school' });
db.rating.belongsTo(db.entry, { as: 'Entry', foreignKey: 'entry' });
db.rating.belongsTo(db.ratingTier, { as: 'RatingTier', foreignKey: 'rating_tier' });
db.rating.belongsTo(db.judge, { as: 'Judge', foreignKey: 'judge' });
Expand Down
34 changes: 22 additions & 12 deletions api/models/person.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,33 @@ const person = (sequelize, DataTypes) => {
type: DataTypes.STRING(63),
allowNull: true,
},
phone: {
type: DataTypes.STRING(31),
allowNull: true,
phone : {
type : DataTypes.STRING(31),
allowNull : true,
},
provider: {
type: DataTypes.STRING(63),
allowNull: true,
pass_timestamp : {
type : DataTypes.DATE,
allowNull : true,
},
site_admin: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: '0',
type : DataTypes.BOOLEAN,
allowNull : false,
defaultValue : '0',

},
nsda: {
type: DataTypes.INTEGER(11),
allowNull: true,
unique: true,
type : DataTypes.INTEGER(11),
allowNull : true,
unique : true,
},
accesses: {
type : DataTypes.INTEGER(11),
allowNull : false,
defaultValue : '0',
},
last_access : {
type : DataTypes.DATE,
allowNull : true,
},
});
};
Expand Down
8 changes: 4 additions & 4 deletions api/models/rating.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const rating = (sequelize, DataTypes) => {
return sequelize.define('rating', {
type : {
type: DataTypes.ENUM('school', 'entry', 'coach'),
type: DataTypes.ENUM('entry', 'coach'),
allowNull: true,
},
draft : {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: 0,
type : DataTypes.BOOLEAN,
allowNull : false,
defaultValue : 0,
},
entered : {
type: DataTypes.DATE,
Expand Down
19 changes: 0 additions & 19 deletions api/routes/definitions/schemas/Login.js

This file was deleted.

47 changes: 25 additions & 22 deletions api/routes/definitions/schemas/Person.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
import { mysqlDate } from '../formats';

const Person = {
type : 'object',
properties : {
id : { type : 'integer' },
email : { type : 'string' , nullable : true },
first : { type : 'string' , nullable : true },
middle : { type : 'string' , nullable : true },
last : { type : 'string' , nullable : true },
street : { type : 'string' , nullable : true },
city : { type : 'string' , nullable : true },
state : { type : 'string' , nullable : true },
zip : { type : 'string' , nullable : true },
postal : { type : 'string' , nullable : true },
country : { type : 'string' , nullable : true },
tz : { type : 'string' , nullable : true },
nsda : { type : 'integer' , nullable : true },
phone : { type : 'integer' , nullable : true },
provider : { type : 'string' , nullable : true },
gender : { type : 'string' , nullable : true },
pronoun : { type : 'string' , nullable : true },
no_email : { type : 'boolean' },
site_admin : { type : 'boolean' , nullable : true },
timestamp : { type : 'string' , nullable : true , pattern : mysqlDate },
type : 'object',
properties : {
id : { type : 'integer' },
email : { type : 'string' , nullable : true },
first : { type : 'string' , nullable : true },
middle : { type : 'string' , nullable : true },
last : { type : 'string' , nullable : true },
street : { type : 'string' , nullable : true },
city : { type : 'string' , nullable : true },
state : { type : 'string' , nullable : true },
zip : { type : 'string' , nullable : true },
postal : { type : 'string' , nullable : true },
country : { type : 'string' , nullable : true },
tz : { type : 'string' , nullable : true },
nsda : { type : 'integer' , nullable : true },
phone : { type : 'integer' , nullable : true },
gender : { type : 'string' , nullable : true },
pronoun : { type : 'string' , nullable : true },
password : { type : 'string' , nullable : false },
no_email : { type : 'boolean' },
site_admin : { type : 'boolean' , nullable : true },
accesess : { type : 'integer' , nullable : true },
last_access : { type : 'string' , nullable : true , pattern : mysqlDate },
pass_timstamp : { type : 'string' , nullable : true , pattern : mysqlDate },
timestamp : { type : 'string' , nullable : true , pattern : mysqlDate },
},
};

Expand Down
2 changes: 0 additions & 2 deletions api/routes/definitions/schemas/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Err from './Err';
import Person from './Person';
import Login from './Login';
import LoginRequest from './LoginRequest';
import Session from './Session';
import School from './School';
Expand All @@ -18,7 +17,6 @@ import Ad from './Ad';
export default {
Err,
Person,
Login,
LoginRequest,
Session,
School,
Expand Down
3 changes: 1 addition & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import helmet from 'helmet';
import cors from 'cors';
import rateLimiter from 'express-rate-limit';
import pkg from 'uuid';
const { v4: uuid } = pkg;
import expressWinston from 'express-winston';
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';
Expand Down Expand Up @@ -33,6 +32,7 @@ import db from './api/helpers/db';

import { debugLogger, requestLogger, errorLogger } from './api/helpers/logger.js';

const { v4: uuid } = pkg;
const app = express();

// Startup log message
Expand Down Expand Up @@ -108,7 +108,6 @@ app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json({ type: ['json', 'application/*json'], limit: '10mb' }));
app.use(bodyParser.text({ type: '*/*', limit: '10mb' }));


if (process.env.NODE_ENV === 'development') {
// Pretty print JSON in the dev environment
app.use(bodyParser.json());
Expand Down

0 comments on commit 07545ba

Please sign in to comment.