Skip to content

Commit

Permalink
chore: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Aug 7, 2024
1 parent 34020cd commit dbc44e0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
30 changes: 8 additions & 22 deletions src/server/api/request/requester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ export function createRequesterRoutes<R, M>(requester: Requester<R, M>) {
{
a,
params: {
projectId: Joi.number()
.integer()
.required(),
projectId: Joi.number().integer().required(),
},
},
async (req, res, next) => {
Expand Down Expand Up @@ -99,9 +97,7 @@ export function createRequesterRoutes<R, M>(requester: Requester<R, M>) {
{
a,
params: {
projectId: Joi.number()
.integer()
.required(),
projectId: Joi.number().integer().required(),
},
body: {
token: Joi.string().required(),
Expand Down Expand Up @@ -135,7 +131,7 @@ export function createRequesterRoutes<R, M>(requester: Requester<R, M>) {

let claims = jwt.decode(req.body.token, { complete: true }) as jwt.Jwt | null;
if (!claims) return res.status(422).json({ error: 'Invalid OIDC token provided' });
const key = jwks.data.keys.find(key => key.kid === claims!.header.kid);
const key = jwks.data.keys.find((key) => key.kid === claims!.header.kid);

if (!key) return res.status(422).json({ error: 'Invalid kid found in the token provided' });

Expand Down Expand Up @@ -184,9 +180,7 @@ export function createRequesterRoutes<R, M>(requester: Requester<R, M>) {
{
a,
params: {
projectId: Joi.number()
.integer()
.required(),
projectId: Joi.number().integer().required(),
},
},
async (req, res) => {
Expand Down Expand Up @@ -241,12 +235,8 @@ export function createRequesterRoutes<R, M>(requester: Requester<R, M>) {
{
a,
params: {
projectId: Joi.number()
.integer()
.required(),
requestId: Joi.string()
.uuid({ version: 'uuidv4' })
.required(),
projectId: Joi.number().integer().required(),
requestId: Joi.string().uuid({ version: 'uuidv4' }).required(),
},
},
async (req, res) => {
Expand Down Expand Up @@ -325,12 +315,8 @@ export function createRequesterRoutes<R, M>(requester: Requester<R, M>) {
{
a,
params: {
projectId: Joi.number()
.integer()
.required(),
requestId: Joi.string()
.uuid({ version: 'uuidv4' })
.required(),
projectId: Joi.number().integer().required(),
requestId: Joi.string().uuid({ version: 'uuidv4' }).required(),
},
},
async (req, res) => {
Expand Down
33 changes: 27 additions & 6 deletions src/server/db/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import {
ForeignKey,
Unique,
} from 'sequelize-typescript';
import { CreationOptional, InferAttributes, InferCreationAttributes, QueryInterface, Transaction } from 'sequelize';
import {
CreationOptional,
InferAttributes,
InferCreationAttributes,
QueryInterface,
Transaction,
} from 'sequelize';
import * as url from 'url';

const tableOptions = { freezeTableName: true, timestamps: false };
Expand Down Expand Up @@ -88,7 +94,10 @@ export class Project extends Model<InferAttributes<Project>, InferCreationAttrib
}

@Table(tableOptions)
export class CircleCIRequesterConfig extends Model<InferAttributes<CircleCIRequesterConfig>, InferCreationAttributes<CircleCIRequesterConfig>> {
export class CircleCIRequesterConfig extends Model<
InferAttributes<CircleCIRequesterConfig>,
InferCreationAttributes<CircleCIRequesterConfig>
> {
@PrimaryKey
@Default(DataType.UUIDV4)
@Column(DataType.UUID)
Expand All @@ -100,7 +109,10 @@ export class CircleCIRequesterConfig extends Model<InferAttributes<CircleCIReque
}

@Table(tableOptions)
export class SlackResponderConfig extends Model<InferAttributes<SlackResponderConfig>, InferCreationAttributes<SlackResponderConfig>> {
export class SlackResponderConfig extends Model<
InferAttributes<SlackResponderConfig>,
InferCreationAttributes<SlackResponderConfig>
> {
@PrimaryKey
@Default(DataType.UUIDV4)
@Column(DataType.UUID)
Expand Down Expand Up @@ -139,7 +151,10 @@ export class SlackResponderConfig extends Model<InferAttributes<SlackResponderCo
* Used as a middle-table to create a SlackResponderConfig
*/
@Table(tableOptions)
export class SlackResponderLinker extends Model<InferAttributes<SlackResponderLinker>, InferCreationAttributes<SlackResponderLinker>> {
export class SlackResponderLinker extends Model<
InferAttributes<SlackResponderLinker>,
InferCreationAttributes<SlackResponderLinker>
> {
@PrimaryKey
@Default(DataType.UUIDV4)
@Column(DataType.UUID)
Expand All @@ -155,7 +170,10 @@ export class SlackResponderLinker extends Model<InferAttributes<SlackResponderLi
}

@Table(tableOptions)
export class SlackInstall extends Model<InferAttributes<SlackInstall>, InferCreationAttributes<SlackInstall>> {
export class SlackInstall extends Model<
InferAttributes<SlackInstall>,
InferCreationAttributes<SlackInstall>
> {
@PrimaryKey
@Default(DataType.UUIDV4)
@Column(DataType.UUID)
Expand Down Expand Up @@ -185,7 +203,10 @@ export class SlackInstall extends Model<InferAttributes<SlackInstall>, InferCrea
}

@Table(tableOptions)
export class OTPRequest<Req = unknown, Res = unknown> extends Model<InferAttributes<OTPRequest<Req, Res>>, InferCreationAttributes<OTPRequest<Req, Res>>> {
export class OTPRequest<Req = unknown, Res = unknown> extends Model<
InferAttributes<OTPRequest<Req, Res>>,
InferCreationAttributes<OTPRequest<Req, Res>>
> {
static generateProof() {
return crypto.randomBytes(2048).toString('hex').toLowerCase();
}
Expand Down
5 changes: 4 additions & 1 deletion src/server/responders/Responder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ export type RequestInformation = {
export abstract class Responder<Req = unknown, Res = unknown> {
constructor(protected project: Project) {}

abstract requestOtp(request: OTPRequest<Req, Res>, info: RequestInformation | null): Promise<void>;
abstract requestOtp(
request: OTPRequest<Req, Res>,
info: RequestInformation | null,
): Promise<void>;
}

0 comments on commit dbc44e0

Please sign in to comment.