Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/web/src/server/auth/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const getClientIp = createServerOnlyFn((): string => {

/** Login server function. Unauthenticated by necessity — this *creates* the session. */
export const loginFn = createServerFn({ method: "POST" })
.inputValidator(loginSchema)
.validator(loginSchema)
.handler(async ({ data }) => {
try {
const result = await login(db, realCookies, {
Expand Down Expand Up @@ -78,7 +78,7 @@ export const loginFn = createServerFn({ method: "POST" })
* session for the user it creates.
*/
export const createFirstUserFn = createServerFn({ method: "POST" })
.inputValidator(createFirstUserSchema)
.validator(createFirstUserSchema)
.handler(async ({ data }) => {
try {
const user = await createFirstUser(db, realCookies, {
Expand Down Expand Up @@ -110,7 +110,7 @@ export const logoutFn = createServerFn({ method: "POST" }).handler(async () => {
* carried by the `reset_code` returned from `loginFn`.
*/
export const resetPasswordFn = createServerFn({ method: "POST" })
.inputValidator(resetPasswordSchema)
.validator(resetPasswordSchema)
.handler(async ({ data }) => {
try {
await resetPassword(db, realCookies, {
Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/server/groups/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ export const listGroups = createServerFn({ method: "GET" }).handler(async () =>
);

export const findGroups = createServerFn({ method: "GET" })
.inputValidator(findGroupsSchema)
.validator(findGroupsSchema)
.handler(async ({ data }) =>
findGroupsImpl(data?.term ?? "", data?.page ?? 1, data?.per_page ?? 25),
);

export const getGroup = createServerFn({ method: "GET" })
.inputValidator(groupIdSchema)
.validator(groupIdSchema)
.handler(async ({ data }) => {
try {
return await getGroupImpl(data.groupId);
Expand All @@ -84,7 +84,7 @@ export const getGroup = createServerFn({ method: "GET" })
});

export const createGroup = createServerFn({ method: "POST" })
.inputValidator(createGroupSchema)
.validator(createGroupSchema)
.handler(async ({ data }) => {
try {
const group = await createGroupImpl(data.name);
Expand All @@ -96,7 +96,7 @@ export const createGroup = createServerFn({ method: "POST" })
});

export const updateGroup = createServerFn({ method: "POST" })
.inputValidator(updateGroupSchema)
.validator(updateGroupSchema)
.handler(async ({ data }) => {
const { groupId, ...values } = data;
try {
Expand All @@ -107,7 +107,7 @@ export const updateGroup = createServerFn({ method: "POST" })
});

export const deleteGroup = createServerFn({ method: "POST" })
.inputValidator(groupIdSchema)
.validator(groupIdSchema)
.handler(async ({ data }) => {
try {
await deleteGroupImpl(data.groupId);
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/server/jobs/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ const rethrowAsHttp = createServerOnlyFn((err: unknown): never => {
});

export const findJobs = createServerFn({ method: "GET" })
.inputValidator(findJobsSchema)
.validator(findJobsSchema)
.handler(async ({ data }) => findJobsImpl(db, data));

export const getJob = createServerFn({ method: "GET" })
.inputValidator(jobIdSchema)
.validator(jobIdSchema)
.handler(async ({ data }) => {
try {
return await getJobImpl(db, data.jobId);
Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/server/labels/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ const rethrowAsHttp = createServerOnlyFn((err: unknown): never => {
});

export const findLabels = createServerFn({ method: "GET" })
.inputValidator(findLabelsSchema)
.validator(findLabelsSchema)
.handler(async ({ data }) => findLabelsImpl(db, data?.term ?? ""));

export const getLabel = createServerFn({ method: "GET" })
.inputValidator(labelIdSchema)
.validator(labelIdSchema)
.handler(async ({ data }) => {
try {
return await getLabelImpl(db, data.labelId);
Expand All @@ -70,7 +70,7 @@ export const getLabel = createServerFn({ method: "GET" })
});

export const createLabel = createServerFn({ method: "POST" })
.inputValidator(labelValuesSchema)
.validator(labelValuesSchema)
.handler(async ({ data }) => {
try {
const label = await createLabelImpl(db, normalizeValues(data));
Expand All @@ -82,7 +82,7 @@ export const createLabel = createServerFn({ method: "POST" })
});

export const updateLabel = createServerFn({ method: "POST" })
.inputValidator(labelIdSchema.extend(labelValuesSchema.partial().shape))
.validator(labelIdSchema.extend(labelValuesSchema.partial().shape))
.handler(async ({ data }) => {
const { labelId, ...values } = data;
try {
Expand All @@ -93,7 +93,7 @@ export const updateLabel = createServerFn({ method: "POST" })
});

export const deleteLabel = createServerFn({ method: "POST" })
.inputValidator(labelIdSchema)
.validator(labelIdSchema)
.handler(async ({ data }) => {
try {
await deleteLabelImpl(db, data.labelId);
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/server/messages/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const findMessages = createServerFn({ method: "GET" }).handler(
);

export const createMessage = createServerFn({ method: "POST" })
.inputValidator(createMessageSchema)
.validator(createMessageSchema)
.handler(async ({ data }) => {
const session = await requireSession();
await requireAdminRole(session, "settings");
Expand All @@ -70,7 +70,7 @@ export const createMessage = createServerFn({ method: "POST" })
});

export const updateMessage = createServerFn({ method: "POST" })
.inputValidator(updateMessageSchema)
.validator(updateMessageSchema)
.handler(async ({ data }) => {
const session = await requireSession();
await requireAdminRole(session, "settings");
Expand All @@ -86,7 +86,7 @@ export const updateMessage = createServerFn({ method: "POST" })
});

export const deleteMessage = createServerFn({ method: "POST" })
.inputValidator(idSchema)
.validator(idSchema)
.handler(async ({ data }) => {
const session = await requireSession();
await requireAdminRole(session, "settings");
Expand All @@ -100,7 +100,7 @@ export const deleteMessage = createServerFn({ method: "POST" })
});

export const setActiveMessage = createServerFn({ method: "POST" })
.inputValidator(idSchema)
.validator(idSchema)
.handler(async ({ data }) => {
const session = await requireSession();
await requireAdminRole(session, "settings");
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/server/tasks/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const rethrowAsHttp = createServerOnlyFn((err: unknown): never => {
});

export const getTask = createServerFn({ method: "GET" })
.inputValidator(taskIdSchema)
.validator(taskIdSchema)
.handler(async ({ data }) => {
try {
return await getTaskImpl(data.taskId);
Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/server/users/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const listAdministratorRoles = createServerFn({ method: "GET" }).handler(
);

export const findUsers = createServerFn({ method: "GET" })
.inputValidator(findUsersSchema)
.validator(findUsersSchema)
.handler(async ({ data }) => {
await requireAdminRole(await requireSession(), "users");
return findUsersImpl(db, {
Expand All @@ -115,7 +115,7 @@ export const findUsers = createServerFn({ method: "GET" })
});

export const getUser = createServerFn({ method: "GET" })
.inputValidator(userIdSchema)
.validator(userIdSchema)
.handler(async ({ data }) => {
await requireAdminRole(await requireSession(), "users");
try {
Expand All @@ -128,7 +128,7 @@ export const getUser = createServerFn({ method: "GET" })
});

export const createUser = createServerFn({ method: "POST" })
.inputValidator(createUserSchema)
.validator(createUserSchema)
.handler(async ({ data }) => {
await requireAdminRole(await requireSession(), "users");

Expand All @@ -148,7 +148,7 @@ export const createUser = createServerFn({ method: "POST" })
});

export const updateUser = createServerFn({ method: "POST" })
.inputValidator(updateUserSchema)
.validator(updateUserSchema)
.handler(async ({ data }) => {
const session = await requireSession();
await requireAdminRole(session, "users");
Expand All @@ -172,7 +172,7 @@ export const updateUser = createServerFn({ method: "POST" })
});

export const updateAccountHandle = createServerFn({ method: "POST" })
.inputValidator(accountHandleSchema)
.validator(accountHandleSchema)
.handler(async ({ data }) => {
const session = await requireSession();

Expand All @@ -188,7 +188,7 @@ export const updateAccountHandle = createServerFn({ method: "POST" })
});

export const setAdministratorRole = createServerFn({ method: "POST" })
.inputValidator(setAdministratorRoleSchema)
.validator(setAdministratorRoleSchema)
.handler(async ({ data }) => {
const session = await requireSession();
await requireAdminRole(session, "full");
Expand Down