Skip to content

Commit

Permalink
Revert "Ran prettier"
Browse files Browse the repository at this point in the history
This reverts commit 1cb07f2.
  • Loading branch information
francisli committed Oct 11, 2024
1 parent 1cb07f2 commit 4e25d79
Show file tree
Hide file tree
Showing 44 changed files with 117 additions and 118 deletions.
8 changes: 4 additions & 4 deletions src/backend/auth/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { InsertObject, Selectable } from "kysely";

const mapStoredUserToAdapterUser = (
user: Selectable<ZapatosTableNameToKyselySchema<"user">>,
user: Selectable<ZapatosTableNameToKyselySchema<"user">>
): AdapterUser => ({
id: user.user_id,
email: user.email,
Expand All @@ -17,7 +17,7 @@ const mapStoredUserToAdapterUser = (
});

const mapStoredSessionToAdapterSession = (
session: Selectable<ZapatosTableNameToKyselySchema<"session">>,
session: Selectable<ZapatosTableNameToKyselySchema<"session">>
): AdapterSession => ({
sessionToken: session.session_token,
userId: session.user_id,
Expand All @@ -32,7 +32,7 @@ const mapStoredSessionToAdapterSession = (
* See https://next-auth.js.org/tutorials/creating-a-database-adapter
*/
export const createPersistedAuthAdapter = (
db: KyselyDatabaseInstance,
db: KyselyDatabaseInstance
): Adapter => ({
async createUser(user) {
const numOfUsers = await db
Expand Down Expand Up @@ -149,7 +149,7 @@ export const createPersistedAuthAdapter = (
.insertInto("account")
.values(data)
.onConflict((b) =>
b.columns(["provider_name", "provider_account_id"]).doUpdateSet(data),
b.columns(["provider_name", "provider_account_id"]).doUpdateSet(data)
)
.execute();
},
Expand Down
2 changes: 1 addition & 1 deletion src/backend/auth/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { KyselyDatabaseInstance } from "../lib";
import type { NextAuthOptions } from "next-auth";

export const getNextAuthOptions = (
db: KyselyDatabaseInstance,
db: KyselyDatabaseInstance
): NextAuthOptions => ({
providers: [
GoogleProvider({
Expand Down
4 changes: 2 additions & 2 deletions src/backend/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type tRPCContext = ReturnType<typeof getDb> & {
};

export const createContext = async (
options: CreateNextContextOptions,
options: CreateNextContextOptions
): Promise<tRPCContext> => {
const env = (options.req.env as unknown as Env) ?? process.env;
const {
Expand All @@ -40,7 +40,7 @@ export const createContext = async (
const session = await getServerSession(
options.req,
options.res,
getNextAuthOptions(db),
getNextAuthOptions(db)
);
if (session && session.user?.email) {
const user = await db
Expand Down
4 changes: 2 additions & 2 deletions src/backend/db/lib/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ interface MigrateOptions {

export const migrate = async (
databaseUrl: string,
{ silent = false, shouldGenerateTypes = true }: MigrateOptions = {},
{ silent = false, shouldGenerateTypes = true }: MigrateOptions = {}
) => {
const migrationsDirectory = path.join(
process.cwd(),
"src/backend/db/migrations",
"src/backend/db/migrations"
);
const zapatosDirectory = path.join(process.cwd(), "src/backend/db");

Expand Down
2 changes: 1 addition & 1 deletion src/backend/db/lib/seed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test("seedfile works with current schema", async (t) => {
t.fail(
`Seedfile execution failed: ${
error instanceof Error ? error.message : String(error)
}`,
}`
);
} finally {
await db.destroy();
Expand Down
14 changes: 7 additions & 7 deletions src/backend/lib/db_helpers/case_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function createPara(
case_manager_id: string,
from_email: string,
to_email: string,
env: Env,
env: Env
): Promise<user.Selectable | undefined> {
const { first_name, last_name, email } = para;

Expand Down Expand Up @@ -48,7 +48,7 @@ export async function createPara(
to_email,
first_name,
case_manager_id,
env,
env
);
}

Expand All @@ -63,7 +63,7 @@ export async function sendInviteEmail(
toEmail: string,
first_name: string,
caseManagerName: string,
env: Env,
env: Env
): Promise<void> {
await getTransporter(env).sendMail({
from: fromEmail,
Expand All @@ -83,7 +83,7 @@ export async function sendInviteEmail(
export async function assignParaToCaseManager(
para_id: string,
case_manager_id: string,
db: KyselyDatabaseInstance,
db: KyselyDatabaseInstance
): Promise<void> {
await db
.insertInto("paras_assigned_to_case_manager")
Expand All @@ -103,10 +103,10 @@ type createStudentProps = {
};

export const STUDENT_ASSIGNED_TO_YOU_ERR = new Error(
"This student is already assigned to you",
"This student is already assigned to you"
);
export const STUDENT_ALREADY_ASSIGNED_ERR = new Error(
"This student is already assigned to another case manager.",
"This student is already assigned to another case manager."
);

/**
Expand Down Expand Up @@ -155,7 +155,7 @@ export async function createAndAssignStudent({
oc
.column("email")
.doUpdateSet({ assigned_case_manager_id: userId })
.where("student.assigned_case_manager_id", "is", null),
.where("student.assigned_case_manager_id", "is", null)
)
.returningAll()
.executeTakeFirstOrThrow();
Expand Down
6 changes: 3 additions & 3 deletions src/backend/lib/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { substituteTransactionOnContext } from "./utils/context";

const deleteFileWithoutTransaction = async (
fileId: string,
ctx: tRPCContext,
ctx: tRPCContext
) => {
if (ctx.auth.type === "none") {
throw new Error("File deletion requires authentication.");
Expand All @@ -21,7 +21,7 @@ const deleteFileWithoutTransaction = async (
new DeleteObjectCommand({
Bucket: ctx.env.S3_USER_UPLOADS_BUCKET_NAME,
Key: ext_s3_path,
}),
})
);
};

Expand All @@ -33,7 +33,7 @@ export const deleteFile = async (fileId: string, ctx: tRPCContext) => {
await ctx.db.transaction().execute(async (trx) => {
await deleteFileWithoutTransaction(
fileId,
substituteTransactionOnContext(trx, ctx),
substituteTransactionOnContext(trx, ctx)
);
});
};
4 changes: 2 additions & 2 deletions src/backend/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const logger = winston.createLogger({
winston.format.timestamp(),
winston.format.printf(
({ level, message, timestamp }) =>
`${timestamp as string} ${level}: ${message as string}`,
),
`${timestamp as string} ${level}: ${message as string}`
)
),
}),
],
Expand Down
2 changes: 1 addition & 1 deletion src/backend/lib/utils/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { KyselySchema } from "../types";

export const substituteTransactionOnContext = (
trx: Transaction<KyselySchema>,
context: tRPCContext,
context: tRPCContext
): tRPCContext => ({
...context,
db: trx,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/routers/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { adminProcedure, router } from "../trpc";
export const admin = router({
getPostgresInfo: adminProcedure.query(async (req) => {
const result = await sql<{ version: string }>`SELECT version()`.execute(
req.ctx.db,
req.ctx.db
);

return result.rows[0].version;
Expand Down
14 changes: 7 additions & 7 deletions src/backend/routers/case_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ test("addStudent - student doesn't exist in db", async (t) => {
.selectFrom("student")
.where("first_name", "=", "Foo")
.selectAll()
.executeTakeFirst(),
.executeTakeFirst()
);

await trpc.case_manager.addStudent.mutate({
Expand All @@ -119,7 +119,7 @@ test("addStudent - student exists in db but is unassigned", async (t) => {
.selectFrom("student")
.where("first_name", "=", seed.student.first_name)
.selectAll()
.executeTakeFirst(),
.executeTakeFirst()
);

await trpc.case_manager.addStudent.mutate({
Expand All @@ -138,7 +138,7 @@ test("addStudent - student exists in db but is unassigned", async (t) => {
.where("student_id", "=", seed.student.student_id)
.where("assigned_case_manager_id", "=", seed.case_manager.user_id)
.selectAll()
.executeTakeFirstOrThrow(),
.executeTakeFirstOrThrow()
);
});

Expand Down Expand Up @@ -167,7 +167,7 @@ test("addStudent - student exists in db and is already assigned to user", async
last_name: seed.student.last_name,
email: seed.student.email,
grade: seed.student.grade,
}),
})
);

t.is(err?.message, STUDENT_ASSIGNED_TO_YOU_ERR.message);
Expand Down Expand Up @@ -221,7 +221,7 @@ test("addStudent - student exists in db but is assigned to another case manager"
last_name: newStudent.last_name,
email: newStudent.email,
grade: newStudent.grade,
}),
})
);

t.is(err?.message, STUDENT_ALREADY_ASSIGNED_ERR.message);
Expand All @@ -241,7 +241,7 @@ test("addStudent - student exists in db but is assigned to another case manager"
last_name: newStudent.last_name,
email: newStudent.email,
grade: newStudent.grade,
}),
})
);

t.is(redundantErr?.message, STUDENT_ASSIGNED_TO_YOU_ERR.message);
Expand All @@ -258,7 +258,7 @@ test("addStudent - invalid email", async (t) => {
last_name: "Bar",
email: "invalid-email",
grade: 6,
}),
})
);
// should be zod error
t.is(typeof err?.message, "string");
Expand Down
2 changes: 1 addition & 1 deletion src/backend/routers/file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test("can upload files", async (t) => {
await db
.selectFrom("file")
.where("ext_s3_path", "=", key)
.executeTakeFirst(),
.executeTakeFirst()
);
});

Expand Down
8 changes: 4 additions & 4 deletions src/backend/routers/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const file = router({
.input(
z.object({
file_id: z.string().uuid(),
}),
})
)
.mutation(async (req) => {
const file = await req.ctx.db
Expand Down Expand Up @@ -54,7 +54,7 @@ export const file = router({
.input(
z.object({
type: z.string(),
}),
})
)
.mutation(async (req) => {
const key = randomUUID();
Expand All @@ -76,7 +76,7 @@ export const file = router({
z.object({
filename: z.string(),
key: z.string(),
}),
})
)
.mutation(async (req) => {
const command = new HeadObjectCommand({
Expand All @@ -103,7 +103,7 @@ export const file = router({
.input(
z.object({
file_id: z.string().uuid(),
}),
})
)
.mutation(async (req) => {
await deleteFile(req.input.file_id, req.ctx);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/routers/iep.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ test("basic flow - add/get goals, subgoals, tasks", async (t) => {
.where("subgoal_id", "=", subgoal2Id)
.where("assignee_id", "=", para_id)
.selectAll()
.executeTakeFirstOrThrow(),
.executeTakeFirstOrThrow()
);
});

Expand Down
Loading

0 comments on commit 4e25d79

Please sign in to comment.