added linting

added linting
This commit is contained in:
2024-05-16 16:59:25 +07:00
parent d125687536
commit 5c4abf24bb
15 changed files with 1759 additions and 71 deletions

View File

@@ -16,7 +16,7 @@ export function createClient() {
export async function createUploadImageUrl(
mc: minio.Client,
objectName: string,
contentType: string
contentType: string,
) {
let policy = mc.newPostPolicy();
policy.setKey(objectName);

View File

@@ -15,7 +15,7 @@ export const runPlayground = async (appRouter: AppRouter) => {
trpcApiEndpoint,
playgroundEndpoint,
router: appRouter,
})
}),
);
app.listen(3001, () => {

View File

@@ -41,7 +41,7 @@ export const user = sqliteTable(
(t) => ({
phone_idx: index("phone_idx").on(t.phone),
image_idx: index("image_idx").on(t.image),
})
}),
);
export const userRelation = relations(user, ({ many, one }) => ({
@@ -98,7 +98,7 @@ export const userOpinion = sqliteTable(
},
(t) => ({
pk: primaryKey({ columns: [t.userId, t.opinionId] }),
})
}),
);
export const userOpinionRelation = relations(userOpinion, ({ one }) => ({
@@ -118,7 +118,7 @@ export const zone = sqliteTable(
.notNull()
.references(() => province.id),
},
(t) => ({ unique_name_province: unique().on(t.name, t.province) })
(t) => ({ unique_name_province: unique().on(t.name, t.province) }),
);
export const zoneRelation = relations(zone, ({ one }) => ({
province: one(province, {
@@ -144,6 +144,6 @@ export const imageToUser = sqliteTable("image_to_user", {
.references(() => user.id),
imageName: text("image_name").notNull(),
createdOn: integer("created_on", { mode: "timestamp" }).default(
sql`CURRENT_TIMESTAMP`
sql`CURRENT_TIMESTAMP`,
),
});

View File

@@ -47,10 +47,10 @@ export const userRoute = router({
.input(
userInsertSchema.omit({ id: true }).extend({
opinions: opinionInsertSchema,
})
}),
)
.mutation(
async ({ input }) => await createUser({ ...input }, input.opinions)
async ({ input }) => await createUser({ ...input }, input.opinions),
),
// changeImage: protectedProcedure
updateUser: protectedProcedure
@@ -60,7 +60,7 @@ export const userRoute = router({
.input(z.object({ userId: z.number() }))
.mutation(async ({ input }) => await getUser(input.userId, false)),
getSelf: protectedProcedure.mutation(
async ({ ctx }) => await getUser(ctx.user.id, true)
async ({ ctx }) => await getUser(ctx.user.id, true),
),
login: publicProcedure
.input(z.object({ cid: z.string(), phone: z.string() }))
@@ -69,7 +69,7 @@ export const userRoute = router({
.input(opinionUpdateSchema)
.mutation(
async ({ input, ctx }) =>
await changeOpinion(input.opinionId, ctx.user.id, input.choice)
await changeOpinion(input.opinionId, ctx.user.id, input.choice),
),
requestChangeImage: protectedProcedure
.input(z.object({ imageName: z.string(), contentType: z.string() }))
@@ -78,11 +78,11 @@ export const userRoute = router({
await requestChangeImage(
ctx.user.id,
input.imageName,
input.contentType
)
input.contentType,
),
),
confirmChangeImage: protectedProcedure.mutation(
async ({ ctx }) => await confirmChangeImage(ctx.user.id, ctx.user.image)
async ({ ctx }) => await confirmChangeImage(ctx.user.id, ctx.user.image),
),
getAllUser: protectedProcedure
.input(
@@ -93,7 +93,7 @@ export const userRoute = router({
zone: z.number().optional(),
opinionCount: z.number().default(3),
province: z.number().optional(),
})
}),
)
.query(
async ({ input }) =>
@@ -103,8 +103,8 @@ export const userRoute = router({
input.opinionCount,
input.group,
input.zone,
input.province
)
input.province,
),
),
getAllUserCount: protectedProcedure
.input(
@@ -112,18 +112,18 @@ export const userRoute = router({
group: z.number().optional(),
zone: z.number().optional(),
province: z.number().optional(),
})
}),
)
.query(
async ({ input }) =>
await getAllUserCount(input.group, input.zone, input.province)
await getAllUserCount(input.group, input.zone, input.province),
),
});
async function getAllUserCount(
group?: number,
zoneId?: number,
provinceId?: number
provinceId?: number,
) {
let zoneIds: number[] = await getZone(provinceId);
if (provinceId && zoneIds.length === 0) {
@@ -152,7 +152,7 @@ async function getAllUser(
opinionLimit: number,
group?: number,
zoneId?: number,
provinceId?: number
provinceId?: number,
) {
let zoneIds: number[] = await getZone(provinceId);
if (provinceId && zoneIds.length === 0) {
@@ -221,7 +221,7 @@ async function getUser(userId: number, showPhone: boolean) {
async function createUser(
newUser: UserInsertSchema,
opinions: OpinionInsertSchema
opinions: OpinionInsertSchema,
) {
try {
let result = (
@@ -264,7 +264,7 @@ async function login(cid: string, phone: string) {
async function changeOpinion(
opinionId: number,
userId: number,
opinionChoice: OpinionInsertSchema[0]["choice"]
opinionChoice: OpinionInsertSchema[0]["choice"],
) {
try {
let thisOpinion = await db
@@ -308,7 +308,7 @@ async function changeOpinion(
async function requestChangeImage(
userId: number,
imageName: string,
contentType: string
contentType: string,
) {
const mc = createClient();
// Check if the image is valid