ci(backend-review.yml): add linter step to the backend review workflow (#625)

* ci(backend-review.yml): add linter step to the backend review workflow

* chore(backend-review.yml): remove prettier from lint-action configuration

* chore: apply new linting workflow

* chore(lint-staged.config.js): reorder lint-staged tasks for JavaScript and TypeScript files

* chore(eslint): update ignorePatterns in .eslintrc.js
chore(lint-action): remove prettier option in backend-review.yml
chore(package.json): add lint and lint:fix scripts

* chore(lint-staged.config.js): remove prettier --write command for js, jsx, ts, tsx files

* chore(titleConvo.js): remove unnecessary console.log statement
chore(titleConvo.js): add missing comma in options object

* chore: apply linting to all files

* chore(lint-staged.config.js): update lint-staged configuration to include prettier formatting
This commit is contained in:
Danny Avila 2023-07-14 09:36:49 -04:00 committed by GitHub
parent 637bb6bc11
commit e5336039fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
231 changed files with 1688 additions and 1526 deletions

View file

@ -12,83 +12,83 @@ function log({ title, parameters }) {
const Session = mongoose.Schema({
refreshToken: {
type: String,
default: ''
}
default: '',
},
});
const userSchema = mongoose.Schema(
{
name: {
type: String
type: String,
},
username: {
type: String,
lowercase: true,
required: [true, "can't be blank"],
required: [true, 'can\'t be blank'],
match: [/^[a-zA-Z0-9_-]+$/, 'is invalid'],
index: true
index: true,
},
email: {
type: String,
required: [true, "can't be blank"],
required: [true, 'can\'t be blank'],
lowercase: true,
unique: true,
match: [/\S+@\S+\.\S+/, 'is invalid'],
index: true
index: true,
},
emailVerified: {
type: Boolean,
required: true,
default: false
default: false,
},
password: {
type: String,
trim: true,
minlength: 8,
maxlength: 128
maxlength: 128,
},
avatar: {
type: String,
required: false
required: false,
},
provider: {
type: String,
required: true,
default: 'local'
default: 'local',
},
role: {
type: String,
default: 'USER'
default: 'USER',
},
googleId: {
type: String,
unique: true,
sparse: true
sparse: true,
},
openidId: {
type: String,
unique: true,
sparse: true
sparse: true,
},
githubId: {
type: String,
unique: true,
sparse: true
sparse: true,
},
discordId: {
type: String,
unique: true,
sparse: true
sparse: true,
},
plugins: {
type: Array,
default: []
default: [],
},
refreshToken: {
type: [Session]
}
type: [Session],
},
},
{ timestamps: true }
{ timestamps: true },
);
//Remove refreshToken from the response
@ -96,7 +96,7 @@ userSchema.set('toJSON', {
transform: function (_doc, ret) {
delete ret.refreshToken;
return ret;
}
},
});
userSchema.methods.toJSON = function () {
@ -111,7 +111,7 @@ userSchema.methods.toJSON = function () {
emailVerified: this.emailVerified,
plugins: this.plugins,
createdAt: this.createdAt,
updatedAt: this.updatedAt
updatedAt: this.updatedAt,
};
};
@ -121,10 +121,10 @@ userSchema.methods.generateToken = function () {
id: this._id,
username: this.username,
provider: this.provider,
email: this.email
email: this.email,
},
process.env.JWT_SECRET,
{ expiresIn: eval(process.env.SESSION_EXPIRY) }
{ expiresIn: eval(process.env.SESSION_EXPIRY) },
);
return token;
};
@ -135,10 +135,10 @@ userSchema.methods.generateRefreshToken = function () {
id: this._id,
username: this.username,
provider: this.provider,
email: this.email
email: this.email,
},
process.env.JWT_REFRESH_SECRET,
{ expiresIn: eval(process.env.REFRESH_TOKEN_EXPIRY) }
{ expiresIn: eval(process.env.REFRESH_TOKEN_EXPIRY) },
);
return refreshToken;
};
@ -164,7 +164,7 @@ module.exports.hashPassword = async (password) => {
module.exports.validateUser = (user) => {
log({
title: 'Validate User',
parameters: [{ name: 'Validate User', value: user }]
parameters: [{ name: 'Validate User', value: user }],
});
const schema = {
avatar: Joi.any(),
@ -174,7 +174,7 @@ module.exports.validateUser = (user) => {
.max(80)
.regex(/^[a-zA-Z0-9_-]+$/)
.required(),
password: Joi.string().min(8).max(128).allow('').allow(null)
password: Joi.string().min(8).max(128).allow('').allow(null),
};
return schema.validate(user);