Skip to content

Commit

Permalink
wip(misc): format files with deno fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Dec 13, 2024
1 parent cbee04a commit 2dd4069
Show file tree
Hide file tree
Showing 18 changed files with 140 additions and 65 deletions.
7 changes: 6 additions & 1 deletion idp/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"tasks": {
"start": "deno run --allow-read --allow-write --allow-env --allow-sys --allow-net src/app.ts",
"dev": "deno run --reload src/app.ts",
"format": "prettier --write .",
"format": "deno fmt .",
"swagger-autogen": "deno run ./swagger.js",
"lint": "eslint"
},
Expand Down Expand Up @@ -46,5 +46,10 @@
"rules": {
"exclude": ["no-explicit-any"]
}
},
"fmt": {
"semiColons": false,
"singleQuote": true,
"exclude": ["./docs"]
}
}
62 changes: 62 additions & 0 deletions idp/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions idp/src/account/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
// the Business Source License, use of this software will be governed
// by the GNU Affero General Public License v3.0 only, included in the file
// AGPL-3.0-only in the root of this repository.
import { Router, Request, Response } from 'express'
import { Request, Response, Router } from 'express'
import { body, validationResult } from 'express-validator'
import { getConfig } from '@/config/config.ts'
import { parseValidationError } from '@/infra/error/index.ts'
import {
confirmEmail,
createUser,
resetPassword,
sendResetPasswordEmail,
AccountConfirmEmailOptions,
AccountCreateOptions,
AccountResetPasswordOptions,
AccountSendResetPasswordEmailOptions,
confirmEmail,
createUser,
getPasswordRequirements,
resetPassword,
sendResetPasswordEmail,
} from './service.ts'

const router = Router()
Expand Down
2 changes: 1 addition & 1 deletion idp/src/account/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { hashPassword } from '@/infra/password.ts'
import search, { USER_SEARCH_INDEX } from '@/infra/search.ts'
import { User } from '@/user/model.ts'
import userRepo from '@/user/repo.ts'
import { UserDTO, mapEntity, getUserCount } from '@/user/service.ts'
import { getUserCount, mapEntity, UserDTO } from '@/user/service.ts'

export type AccountCreateOptions = {
email: string
Expand Down
2 changes: 1 addition & 1 deletion idp/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ export function readSecurity(config: Config) {

function newEnvironmentVariableNotSetError(variable: string) {
return new Error(`${variable} environment variable is not set.`)
}
}
4 changes: 2 additions & 2 deletions idp/src/health/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
// the Business Source License, use of this software will be governed
// by the GNU Affero General Public License v3.0 only, included in the file
// AGPL-3.0-only in the root of this repository.
import { Router, Request, Response } from 'express'
import { Request, Response, Router } from 'express'
import { Client as PgClient } from 'https://deno.land/x/[email protected]/mod.ts'
import { getConfig } from '@/config/config.ts'

const router = Router()

router.get('', async (_: Request, res: Response) => {
let pg: PgClient|undefined
let pg: PgClient | undefined
try {
pg = new PgClient(getConfig().databaseURL)
await pg.connect()
Expand Down
2 changes: 1 addition & 1 deletion idp/src/infra/error/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// the Business Source License, use of this software will be governed
// by the GNU Affero General Public License v3.0 only, included in the file
// AGPL-3.0-only in the root of this repository.
import { Request, Response, NextFunction } from 'express'
import { NextFunction, Request, Response } from 'express'

export enum ErrorCode {
InternalServerError = 'internal_server_error',
Expand Down
4 changes: 2 additions & 2 deletions idp/src/infra/error/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ErrorCode, ErrorData, newError } from './core.ts'

/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export function parseValidationError(result: any): ErrorData {
let message: string|undefined
let userMessage: string|undefined
let message: string | undefined
let userMessage: string | undefined
if (result.errors) {
message = result.errors
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
Expand Down
13 changes: 6 additions & 7 deletions idp/src/infra/mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ const transporter = nodemailer.createTransport({
host: config.host,
port: config.port,
secure: config.secure,
auth:
config.username || config.password
? {
user: config.username,
pass: config.password,
}
: null,
auth: config.username || config.password
? {
user: config.username,
pass: config.password,
}
: null,
})

export function sendTemplateMail(
Expand Down
2 changes: 1 addition & 1 deletion idp/src/infra/password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// the Business Source License, use of this software will be governed
// by the GNU Affero General Public License v3.0 only, included in the file
// AGPL-3.0-only in the root of this repository.
import { scryptSync, randomBytes } from 'node:crypto'
import { randomBytes, scryptSync } from 'node:crypto'

export function hashPassword(password: string): string {
const salt = randomBytes(16).toString('hex')
Expand Down
2 changes: 1 addition & 1 deletion idp/src/infra/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ import { Client } from 'https://deno.land/x/[email protected]/mod.ts'
import { getConfig } from '@/config/config.ts'

export const client = new Client(getConfig().databaseURL)
await client.connect()
await client.connect()
2 changes: 1 addition & 1 deletion idp/src/token/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// the Business Source License, use of this software will be governed
// by the GNU Affero General Public License v3.0 only, included in the file
// AGPL-3.0-only in the root of this repository.
import { Router, Request, Response } from 'express'
import { Request, Response, Router } from 'express'
import { exchange, TokenExchangeOptions } from './service.ts'

const router = Router()
Expand Down
4 changes: 3 additions & 1 deletion idp/src/token/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export async function exchange(options: TokenExchangeOptions): Promise<Token> {
// https://datatracker.ietf.org/doc/html/rfc6749#section-4.3
let user: User
try {
user = await userRepo.findByUsername(options.username!.toLocaleLowerCase())
user = await userRepo.findByUsername(
options.username!.toLocaleLowerCase(),
)
} catch {
throw newInvalidUsernameOrPasswordError()
}
Expand Down
20 changes: 10 additions & 10 deletions idp/src/user/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ export type UpdateOptions = {
fullName?: string
username?: string
email?: string
passwordHash?: string|null
refreshTokenValue?: string|null
refreshTokenExpiry?: string|null
resetPasswordToken?: string|null
emailConfirmationToken?: string|null
passwordHash?: string | null
refreshTokenValue?: string | null
refreshTokenExpiry?: string | null
resetPasswordToken?: string | null
emailConfirmationToken?: string | null
isEmailConfirmed?: boolean
emailUpdateToken?: string|null
emailUpdateValue?: string|null
picture?: string|null
emailUpdateToken?: string | null
emailUpdateValue?: string | null
picture?: string | null
failedAttempts?: number
lockedUntil?: string|null
lockedUntil?: string | null
createTime?: string
updateTime?: string|null
updateTime?: string | null
}

export interface UserRepo {
Expand Down
5 changes: 4 additions & 1 deletion idp/src/user/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
// the Business Source License, use of this software will be governed
// by the GNU Affero General Public License v3.0 only, included in the file
// AGPL-3.0-only in the root of this repository.
import { newInternalServerError, newUserNotFoundError } from '@/infra/error/index.ts'
import {
newInternalServerError,
newUserNotFoundError,
} from '@/infra/error/index.ts'
import { client } from '@/infra/postgres.ts'
import { InsertOptions, UpdateOptions, User } from './model.ts'

Expand Down
Loading

0 comments on commit 2dd4069

Please sign in to comment.