Improvements: remove dead config, fix ESM, add URL validation, unify types, add missing logging
- Remove .prettierrc (dead config, Biome replaces Prettier) - Rename lighthouserc.json to lighthouserc.cjs with module.exports for ESM compat - Add logger.warn to empty catch blocks in auth, register, site-settings, prisma-cache, redis, security, rate-limit - Unify ActionResult type: action-helper.ts uses 'ok' consistent with safe-action-shared.ts - Add noUnusedLocals + noUnusedParameters to tsconfig + fix 25 pre-existing unused vars - Replace barrel export src/types/index.ts with direct @/types/common imports - Make trustHost conditional (development only) in auth.ts - Add pre-flight URL validation to update-Nitrov3.sh to catch image.library.url misconfigurations - Improve NITRO_IMAGE_LIBRARY_URL content validation in pre-flight & post-compute checks
This commit is contained in:
1 parent
b922f6d49f
commit
17847545dd
292 files changed
+69195
-67915
No files matched your search
@@ -1,9 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
createEventSchema,
|
||||
eventTypeSchema,
|
||||
} from "./event";
|
||||
import { createEventSchema, eventTypeSchema } from "./event";
|
||||
|
||||
describe("eventTypeSchema", () => {
|
||||
it("accepts valid type", () => {
|
||||
@@ -19,7 +16,9 @@ describe("eventTypeSchema", () => {
|
||||
});
|
||||
|
||||
it("rejects empty name", () => {
|
||||
expect(eventTypeSchema.safeParse({ name: "", slug: "test" }).success).toBe(false);
|
||||
expect(eventTypeSchema.safeParse({ name: "", slug: "test" }).success).toBe(
|
||||
false,
|
||||
);
|
||||
expect(eventTypeSchema.safeParse({ slug: "test" }).success).toBe(false);
|
||||
});
|
||||
|
||||
@@ -36,12 +35,10 @@ describe("eventTypeSchema", () => {
|
||||
|
||||
it("rejects slug with spaces", () => {
|
||||
expect(
|
||||
eventTypeSchema
|
||||
.safeParse({
|
||||
name: "Test",
|
||||
slug: "test event",
|
||||
})
|
||||
.success,
|
||||
eventTypeSchema.safeParse({
|
||||
name: "Test",
|
||||
slug: "test event",
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -68,14 +65,12 @@ describe("createEventSchema", () => {
|
||||
|
||||
it("rejects missing title", () => {
|
||||
expect(
|
||||
createEventSchema
|
||||
.safeParse({
|
||||
title: "",
|
||||
description: "Has desc",
|
||||
typeId: 1,
|
||||
startsAt: "2025-07-25T10:00:00Z",
|
||||
})
|
||||
.success,
|
||||
createEventSchema.safeParse({
|
||||
title: "",
|
||||
description: "Has desc",
|
||||
typeId: 1,
|
||||
startsAt: "2025-07-25T10:00:00Z",
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
@@ -102,4 +97,4 @@ describe("createEventSchema", () => {
|
||||
expect(result.data.isRecurring).toBe(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -2,9 +2,9 @@ import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
createPollSchema,
|
||||
updatePollSchema,
|
||||
pollQuestionSchema,
|
||||
pollVoteSchema,
|
||||
updatePollSchema,
|
||||
voteOnPollSchema,
|
||||
} from "./poll";
|
||||
|
||||
@@ -61,17 +61,14 @@ describe("pollQuestionSchema", () => {
|
||||
|
||||
it("rejects empty question", () => {
|
||||
expect(
|
||||
pollQuestionSchema
|
||||
.safeParse({ pollId: 1, question: "", options: "Red" })
|
||||
pollQuestionSchema.safeParse({ pollId: 1, question: "", options: "Red" })
|
||||
.success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects missing pollId", () => {
|
||||
expect(
|
||||
pollQuestionSchema
|
||||
.safeParse({ question: "Test?", options: "A" })
|
||||
.success,
|
||||
pollQuestionSchema.safeParse({ question: "Test?", options: "A" }).success,
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -111,9 +108,9 @@ describe("voteOnPollSchema", () => {
|
||||
});
|
||||
|
||||
it("rejects empty votes array", () => {
|
||||
expect(
|
||||
voteOnPollSchema.safeParse({ pollId: 1, votes: [] }).success,
|
||||
).toBe(false);
|
||||
expect(voteOnPollSchema.safeParse({ pollId: 1, votes: [] }).success).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects too many votes (more than 50)", () => {
|
||||
@@ -121,9 +118,9 @@ describe("voteOnPollSchema", () => {
|
||||
questionId: i + 1,
|
||||
answer: `Answer ${i + 1}`,
|
||||
}));
|
||||
expect(
|
||||
voteOnPollSchema.safeParse({ pollId: 1, votes }).success,
|
||||
).toBe(false);
|
||||
expect(voteOnPollSchema.safeParse({ pollId: 1, votes }).success).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -137,4 +134,4 @@ describe("updatePollSchema", () => {
|
||||
const result = updatePollSchema.safeParse({ title: "New Title" });
|
||||
if (result.success) expect(result.data.title).toBe("New Title");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -27,38 +27,26 @@ describe("updateRoomSchema", () => {
|
||||
});
|
||||
|
||||
it("rejects name too long", () => {
|
||||
expect(
|
||||
updateRoomSchema
|
||||
.safeParse({ name: "a".repeat(61) })
|
||||
.success,
|
||||
).toBe(false);
|
||||
expect(updateRoomSchema.safeParse({ name: "a".repeat(61) }).success).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects description too long", () => {
|
||||
expect(
|
||||
updateRoomSchema
|
||||
.safeParse({ description: "b".repeat(513) })
|
||||
.success,
|
||||
updateRoomSchema.safeParse({ description: "b".repeat(513) }).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects invalid state", () => {
|
||||
expect(
|
||||
updateRoomSchema
|
||||
.safeParse({ state: "banana" })
|
||||
.success,
|
||||
).toBe(false);
|
||||
expect(updateRoomSchema.safeParse({ state: "banana" }).success).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects usersMax below 1", () => {
|
||||
expect(
|
||||
updateRoomSchema.safeParse({ usersMax: 0 }).success,
|
||||
).toBe(false);
|
||||
expect(updateRoomSchema.safeParse({ usersMax: 0 }).success).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects usersMax above 100", () => {
|
||||
expect(
|
||||
updateRoomSchema.safeParse({ usersMax: 101 }).success,
|
||||
).toBe(false);
|
||||
expect(updateRoomSchema.safeParse({ usersMax: 101 }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,11 +1,11 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
assignTicketSchema,
|
||||
createTicketSchema,
|
||||
replyTicketSchema,
|
||||
updateTicketStatusSchema,
|
||||
assignTicketSchema,
|
||||
updateTicketPrioritySchema,
|
||||
updateTicketStatusSchema,
|
||||
} from "./ticket";
|
||||
|
||||
describe("createTicketSchema", () => {
|
||||
@@ -20,36 +20,30 @@ describe("createTicketSchema", () => {
|
||||
|
||||
it("rejects short subject (less than 5 chars)", () => {
|
||||
expect(
|
||||
createTicketSchema
|
||||
.safeParse({
|
||||
subject: "Hi",
|
||||
category: "technical",
|
||||
message: "Help",
|
||||
})
|
||||
.success,
|
||||
createTicketSchema.safeParse({
|
||||
subject: "Hi",
|
||||
category: "technical",
|
||||
message: "Help",
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects short message (less than 10 chars)", () => {
|
||||
expect(
|
||||
createTicketSchema
|
||||
.safeParse({
|
||||
subject: "Subject",
|
||||
category: "technical",
|
||||
message: "Hi",
|
||||
})
|
||||
.success,
|
||||
createTicketSchema.safeParse({
|
||||
subject: "Subject",
|
||||
category: "technical",
|
||||
message: "Hi",
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects missing category", () => {
|
||||
expect(
|
||||
createTicketSchema
|
||||
.safeParse({
|
||||
subject: "Subject",
|
||||
message: "Some message",
|
||||
})
|
||||
.success,
|
||||
createTicketSchema.safeParse({
|
||||
subject: "Subject",
|
||||
message: "Some message",
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -87,8 +81,7 @@ describe("updateTicketStatusSchema", () => {
|
||||
|
||||
it("rejects invalid status", () => {
|
||||
expect(
|
||||
updateTicketStatusSchema
|
||||
.safeParse({ ticketId: 1, status: "unknown" })
|
||||
updateTicketStatusSchema.safeParse({ ticketId: 1, status: "unknown" })
|
||||
.success,
|
||||
).toBe(false);
|
||||
});
|
||||
@@ -116,4 +109,4 @@ describe("updateTicketPrioritySchema", () => {
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,10 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
createUserSchema,
|
||||
updateUserSchema,
|
||||
banUserSchema,
|
||||
createUserSchema,
|
||||
giveBadgeSchema,
|
||||
updateUserSchema,
|
||||
} from "./user";
|
||||
|
||||
describe("createUserSchema", () => {
|
||||
@@ -23,61 +23,51 @@ describe("createUserSchema", () => {
|
||||
|
||||
it("rejects short username (< 3 chars)", () => {
|
||||
expect(
|
||||
createUserSchema
|
||||
.safeParse({
|
||||
username: "ab",
|
||||
mail: "[email protected]",
|
||||
password: "secret123",
|
||||
})
|
||||
.success,
|
||||
createUserSchema.safeParse({
|
||||
username: "ab",
|
||||
mail: "[email protected]",
|
||||
password: "secret123",
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects long username (> 20 chars)", () => {
|
||||
expect(
|
||||
createUserSchema
|
||||
.safeParse({
|
||||
username: "a".repeat(21),
|
||||
mail: "[email protected]",
|
||||
password: "secret123",
|
||||
})
|
||||
.success,
|
||||
createUserSchema.safeParse({
|
||||
username: "a".repeat(21),
|
||||
mail: "[email protected]",
|
||||
password: "secret123",
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects invalid username characters", () => {
|
||||
expect(
|
||||
createUserSchema
|
||||
.safeParse({
|
||||
username: "user@name",
|
||||
mail: "[email protected]",
|
||||
password: "secret123",
|
||||
})
|
||||
.success,
|
||||
createUserSchema.safeParse({
|
||||
username: "user@name",
|
||||
mail: "[email protected]",
|
||||
password: "secret123",
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects invalid email", () => {
|
||||
expect(
|
||||
createUserSchema
|
||||
.safeParse({
|
||||
username: "TestUser",
|
||||
mail: "not-an-email",
|
||||
password: "secret123",
|
||||
})
|
||||
.success,
|
||||
createUserSchema.safeParse({
|
||||
username: "TestUser",
|
||||
mail: "not-an-email",
|
||||
password: "secret123",
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects short password (< 6 chars)", () => {
|
||||
expect(
|
||||
createUserSchema
|
||||
.safeParse({
|
||||
username: "TestUser",
|
||||
mail: "[email protected]",
|
||||
password: "12345",
|
||||
})
|
||||
.success,
|
||||
createUserSchema.safeParse({
|
||||
username: "TestUser",
|
||||
mail: "test@example.com",
|
||||
password: "12345",
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -95,9 +85,7 @@ describe("updateUserSchema", () => {
|
||||
});
|
||||
|
||||
it("rejects rank out of range", () => {
|
||||
expect(
|
||||
updateUserSchema.safeParse({ rank: 8 }).success,
|
||||
).toBe(false);
|
||||
expect(updateUserSchema.safeParse({ rank: 8 }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -124,16 +112,13 @@ describe("banUserSchema", () => {
|
||||
|
||||
it("rejects empty reason", () => {
|
||||
expect(
|
||||
banUserSchema
|
||||
.safeParse({ userId: 1, reason: "", duration: 1 })
|
||||
.success,
|
||||
banUserSchema.safeParse({ userId: 1, reason: "", duration: 1 }).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects negative duration", () => {
|
||||
expect(
|
||||
banUserSchema
|
||||
.safeParse({ userId: 1, reason: "Bad", duration: -1 })
|
||||
banUserSchema.safeParse({ userId: 1, reason: "Bad", duration: -1 })
|
||||
.success,
|
||||
).toBe(false);
|
||||
});
|
||||
@@ -153,4 +138,4 @@ describe("giveBadgeSchema", () => {
|
||||
giveBadgeSchema.safeParse({ userId: 1, badgeCode: "" }).success,
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user