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
18 changes: 9 additions & 9 deletions src/features/admin/api-keys.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
/**
* Admin API key management routes
*/
Expand Down Expand Up @@ -172,16 +172,16 @@ const handleApiDocsGet: TypedRouteHandler<"GET /admin/api-keys/docs"> = (
),
);

export const adminHandlers = handlersFor("apiKeys")({
getApiKeys: handleApiKeysGet,
getApiKeysByApiKeyId: (request, { apiKeyId }) =>
export const adminHandlers = defineRoutes({
"GET /admin/api-keys": handleApiKeysGet,
"GET /admin/api-keys/:apiKeyId": (request, { apiKeyId }) =>
apiKeyPage.renderTab(request, apiKeyId, ""),
getApiKeysByApiKeyIdByTab: (request, { apiKeyId, tab }) =>
"GET /admin/api-keys/:apiKeyId/:tab": (request, { apiKeyId, tab }) =>
apiKeyPage.renderTab(request, apiKeyId, tab),
getApiKeysByApiKeyIdDelete: (request, { apiKeyId }) =>
"GET /admin/api-keys/:apiKeyId/delete": (request, { apiKeyId }) =>
apiKeyDelete.get(request, apiKeyId),
getApiKeysDocs: handleApiDocsGet,
postApiKeys: handleApiKeysPost,
postApiKeysByApiKeyIdDelete: (request, { apiKeyId }) =>
"GET /admin/api-keys/docs": handleApiDocsGet,
"POST /admin/api-keys": handleApiKeysPost,
"POST /admin/api-keys/:apiKeyId/delete": (request, { apiKeyId }) =>
apiKeyDelete.post(request, apiKeyId),
});
4 changes: 2 additions & 2 deletions src/features/admin/area-loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { AdminAreaId } from "#shared/admin-surface/definitions.ts";

type HandlerMap = Record<string, (...args: never[]) => unknown>;

/** One admin area's lazy route-ID handlers and message ownership. */
/** One admin area's lazy routes and message ownership. */
export type AdminAreaLoader = {
load: () => Promise<HandlerMap>;
messageGroupsFor: (segment: string) => readonly MessageGroup[];
Expand All @@ -28,7 +28,7 @@ const messageGroupsBySegment =
return groups[segment]!;
};

/** Declare an area without importing its handlers until that area is requested. */
/** Declare an area without importing its routes until that area is requested. */
const area = <M extends { adminHandlers: HandlerMap }>(
load: () => Promise<M>,
messageGroups: readonly MessageGroup[] = [],
Expand Down
12 changes: 6 additions & 6 deletions src/features/admin/attendee-notes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
/**
* Admin routes for per-attendee operator notes.
*
Expand Down Expand Up @@ -170,9 +170,9 @@ const handleDeleteNotePost: TypedRouteHandler<"POST /admin/attendee/:attendeeId/
);
});

export const adminHandlers = handlersFor("attendeeNotes")({
getAttendeeByAttendeeIdNote: handleAddNoteGet,
getAttendeeByAttendeeIdNoteByNoteIdDelete: handleDeleteNoteGet,
postAttendeeByAttendeeIdNote: handleAddNotePost,
postAttendeeByAttendeeIdNoteByNoteIdDelete: handleDeleteNotePost,
export const adminHandlers = defineRoutes({
"GET /admin/attendee/:attendeeId/note": handleAddNoteGet,
"GET /admin/attendee/:attendeeId/note/:noteId/delete": handleDeleteNoteGet,
"POST /admin/attendee/:attendeeId/note": handleAddNotePost,
"POST /admin/attendee/:attendeeId/note/:noteId/delete": handleDeleteNotePost,
});
12 changes: 6 additions & 6 deletions src/features/admin/attendee-refunds.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
/**
* Admin attendee refund routes (single + bulk)
*/
Expand Down Expand Up @@ -298,9 +298,9 @@ const handleAdminRefundAllPost = createAuthedHandler<ListingRouteParams>({
});

/** Attendee refund routes */
export const adminHandlers = handlersFor("attendeeRefunds")({
getAttendeesByAttendeeIdRefund: handleAdminAttendeeRefundGet,
getListingByIdRefundAll: handleAdminRefundAllGet,
postAttendeesByAttendeeIdRefund: handleAttendeeRefund,
postListingByIdRefundAll: handleAdminRefundAllPost,
export const adminHandlers = defineRoutes({
"GET /admin/attendees/:attendeeId/refund": handleAdminAttendeeRefundGet,
"GET /admin/listing/:id/refund-all": handleAdminRefundAllGet,
"POST /admin/attendees/:attendeeId/refund": handleAttendeeRefund,
"POST /admin/listing/:id/refund-all": handleAdminRefundAllPost,
});
43 changes: 23 additions & 20 deletions src/features/admin/attendees.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* jscpd:ignore-start */
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
/**
* Admin attendee management routes
*/
Expand Down Expand Up @@ -359,26 +359,29 @@ const handleResendNotification = verifiedAttendeeAction(
* Merge: attendees-merge.ts
* Refunds: attendee-refunds.ts
*/
export const adminHandlers = handlersFor("attendees")({
deleteAttendeesByAttendeeIdDelete: handleAttendeeDelete,
getAttendees: handleAttendeesListGet,
getAttendeesByAttendeeId: (request, { attendeeId }) =>
export const adminHandlers = defineRoutes({
"DELETE /admin/attendees/:attendeeId/delete": handleAttendeeDelete,
"GET /admin/attendees": handleAttendeesListGet,
"GET /admin/attendees/:attendeeId": (request, { attendeeId }) =>
attendeePage.renderTab(request, attendeeId, ""),
getAttendeesByAttendeeIdByTab: (request, { attendeeId, tab }) =>
"GET /admin/attendees/:attendeeId/:tab": (request, { attendeeId, tab }) =>
attendeePage.renderTab(request, attendeeId, tab),
getAttendeesByAttendeeIdDelete: handleAdminAttendeeDeleteGet,
getAttendeesByAttendeeIdResendNotification: handleAdminResendNotificationGet,
getAttendeesCsv: handleAttendeesCsvExport,
getAttendeesNew: handleAttendeeNewGet,
postAttendeesByAttendeeId: handleAttendeeEditPost,
postAttendeesByAttendeeIdDelete: handleAttendeeDelete,
postAttendeesByAttendeeIdLogistics: handleAttendeeLogisticsPost,
postAttendeesByAttendeeIdMerge: handleMergePost,
postAttendeesByAttendeeIdRefreshPayment: handleRefreshPayment,
postAttendeesByAttendeeIdResendNotification: handleResendNotification,
postAttendeesNew: handleAttendeeNewPost,
postListingByListingIdAttendee: handleAddAttendee,
postListingByListingIdAttendeeByAttendeeIdCheckin: handleAttendeeCheckin,
postListingByListingIdAttendeeByAttendeeIdDeleteIncomplete:
"GET /admin/attendees/:attendeeId/delete": handleAdminAttendeeDeleteGet,
"GET /admin/attendees/:attendeeId/resend-notification":
handleAdminResendNotificationGet,
"GET /admin/attendees/csv": handleAttendeesCsvExport,
"GET /admin/attendees/new": handleAttendeeNewGet,
"POST /admin/attendees/:attendeeId": handleAttendeeEditPost,
"POST /admin/attendees/:attendeeId/delete": handleAttendeeDelete,
"POST /admin/attendees/:attendeeId/logistics": handleAttendeeLogisticsPost,
"POST /admin/attendees/:attendeeId/merge": handleMergePost,
"POST /admin/attendees/:attendeeId/refresh-payment": handleRefreshPayment,
"POST /admin/attendees/:attendeeId/resend-notification":
handleResendNotification,
"POST /admin/attendees/new": handleAttendeeNewPost,
"POST /admin/listing/:listingId/attendee": handleAddAttendee,
"POST /admin/listing/:listingId/attendee/:attendeeId/checkin":
handleAttendeeCheckin,
"POST /admin/listing/:listingId/attendee/:attendeeId/delete-incomplete":
handleDeleteIncomplete,
});
36 changes: 18 additions & 18 deletions src/features/admin/attributes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
/**
* Admin routes for listing attributes.
*/
Expand Down Expand Up @@ -357,23 +357,23 @@ const handleListingAttributesPost = createListingChoicePost({
tab: "attributes",
});

export const adminHandlers = handlersFor("attributes")({
getAttributes: handleAttributesGet,
getAttributesById: handleAttributeGet,
getAttributesByIdDelete: (request, { id }) =>
export const adminHandlers = defineRoutes({
"GET /admin/attributes": handleAttributesGet,
"GET /admin/attributes/:id": handleAttributeGet,
"GET /admin/attributes/:id/delete": (request, { id }) =>
attributeDelete.get(request, id),
getAttributesByIdOptionsByOptionIdDelete: handleDeleteOptionGet,
getAttributesByIdOptionsByOptionIdEdit: handleEditOptionGet,
postAttributes: handleAttributesPost,
postAttributesByIdDelete: (request, { id }) =>
"GET /admin/attributes/:id/options/:optionId/delete": handleDeleteOptionGet,
"GET /admin/attributes/:id/options/:optionId/edit": handleEditOptionGet,
"POST /admin/attributes": handleAttributesPost,
"POST /admin/attributes/:id/delete": (request, { id }) =>
attributeDelete.post(request, id),
postAttributesByIdEdit: handleAttributeEdit,
postAttributesByIdMoveDown: attributeOrder.down,
postAttributesByIdMoveUp: attributeOrder.up,
postAttributesByIdOptions: handleAddOption,
postAttributesByIdOptionsByOptionIdDelete: handleDeleteOptionPost,
postAttributesByIdOptionsByOptionIdEdit: handleEditOptionPost,
postAttributesByIdOptionsByOptionIdMoveDown: optionOrder.down,
postAttributesByIdOptionsByOptionIdMoveUp: optionOrder.up,
postListingByIdAttributes: handleListingAttributesPost,
"POST /admin/attributes/:id/edit": handleAttributeEdit,
"POST /admin/attributes/:id/move-down": attributeOrder.down,
"POST /admin/attributes/:id/move-up": attributeOrder.up,
"POST /admin/attributes/:id/options": handleAddOption,
"POST /admin/attributes/:id/options/:optionId/delete": handleDeleteOptionPost,
"POST /admin/attributes/:id/options/:optionId/edit": handleEditOptionPost,
"POST /admin/attributes/:id/options/:optionId/move-down": optionOrder.down,
"POST /admin/attributes/:id/options/:optionId/move-up": optionOrder.up,
"POST /admin/listing/:id/attributes": handleListingAttributesPost,
});
12 changes: 6 additions & 6 deletions src/features/admin/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
/**
* Admin authentication routes - login and logout
*/
Expand Down Expand Up @@ -192,9 +192,9 @@ const handleLoginGet = (request: Request): Promise<Response> =>
const handleLogoutGet = anyUserPage((session) => adminLogoutPage(session));

/** Authentication routes */
export const adminHandlers = handlersFor("auth")({
getLogin: handleLoginGet,
getLogout: handleLogoutGet,
postLogin: handleAdminLogin,
postLogout: handleAdminLogout,
export const adminHandlers = defineRoutes({
"GET /admin/login": handleLoginGet,
"GET /admin/logout": handleLogoutGet,
"POST /admin/login": handleAdminLogin,
"POST /admin/logout": handleAdminLogout,
});
14 changes: 7 additions & 7 deletions src/features/admin/backup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
import { namedError } from "#shared/named-error.ts";
/**
* Admin backup/restore routes — owner only
Expand Down Expand Up @@ -315,10 +315,10 @@ const handleBackupRestoreConfirm: TypedRouteHandler<"POST /admin/backup/restore/
});

/** Backup routes */
export const adminHandlers = handlersFor("backup")({
getBackup: handleBackupGet,
getBackupDownloadByFilename: handleBackupDownload,
postBackupCreate: handleBackupCreate,
postBackupRestore: handleBackupRestore,
postBackupRestoreConfirm: handleBackupRestoreConfirm,
export const adminHandlers = defineRoutes({
"GET /admin/backup": handleBackupGet,
"GET /admin/backup/download/:filename": handleBackupDownload,
"POST /admin/backup/create": handleBackupCreate,
"POST /admin/backup/restore": handleBackupRestore,
"POST /admin/backup/restore/confirm": handleBackupRestoreConfirm,
});
8 changes: 4 additions & 4 deletions src/features/admin/builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
/**
* Admin builder routes — create new Tickets instances via Bunny API
* Owner-only access, gated behind CAN_BUILD_SITES=true env var
Expand Down Expand Up @@ -209,8 +209,8 @@ const builderPost = createAuthedFormRoute({
},
});

export const adminHandlers = handlersFor("builder")({
getBuilder: handleBuilderGet,
postBuilder: (r: Request) =>
export const adminHandlers = defineRoutes({
"GET /admin/builder": handleBuilderGet,
"POST /admin/builder": (r: Request) =>
isBuilderEnabled() ? builderPost(r, {}) : notFoundResponse(),
});
37 changes: 19 additions & 18 deletions src/features/admin/built-sites.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mapValues } from "@std/collections";
import { t } from "#i18n";
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
/**
* Admin built site management routes - owner only
*/
Expand Down Expand Up @@ -351,24 +351,25 @@ const gateOnBuilder = <Key extends string>(

/** Built site routes (all gated on CAN_BUILD_SITES via gateOnBuilder). */
export const adminHandlers = gateOnBuilder(
handlersFor("builtSites")({
getBuiltSites: handleBuiltSitesListGet,
getBuiltSitesById: (request, { id }) =>
defineRoutes({
"GET /admin/built-sites": handleBuiltSitesListGet,
"GET /admin/built-sites/:id": (request, { id }) =>
builtSitePage.renderTab(request, id, ""),
getBuiltSitesByIdByTab: (request, { id, tab }) =>
"GET /admin/built-sites/:id/:tab": (request, { id, tab }) =>
builtSitePage.renderTab(request, id, tab),
getBuiltSitesByIdDelete: crud.deleteGet,
getBuiltSitesNew: crud.newGet,
postBuiltSites: crud.createPost,
postBuiltSitesByIdAddSecrets: handleAddSecrets,
postBuiltSitesByIdBumpDeadline: handleBumpDeadline,
postBuiltSitesByIdDelete: crud.deletePost,
postBuiltSitesByIdEdit: crud.editPost,
postBuiltSitesByIdOverrideDeadline: handleOverrideDeadline,
postBuiltSitesByIdProvisionRenewal: handleProvisionRenewal,
postBuiltSitesByIdProvisionScheduler: handleProvisionSiteScheduler,
postBuiltSitesByIdReSyncDeadline: handleReSyncDeadline,
postBuiltSitesByIdRotateRenewalToken: handleRotateToken,
postBuiltSitesByIdUpdate: handleUpdateSite,
"GET /admin/built-sites/:id/delete": crud.deleteGet,
"GET /admin/built-sites/new": crud.newGet,
"POST /admin/built-sites": crud.createPost,
"POST /admin/built-sites/:id/add-secrets": handleAddSecrets,
"POST /admin/built-sites/:id/bump-deadline": handleBumpDeadline,
"POST /admin/built-sites/:id/delete": crud.deletePost,
"POST /admin/built-sites/:id/edit": crud.editPost,
"POST /admin/built-sites/:id/override-deadline": handleOverrideDeadline,
"POST /admin/built-sites/:id/provision-renewal": handleProvisionRenewal,
"POST /admin/built-sites/:id/provision-scheduler":
handleProvisionSiteScheduler,
"POST /admin/built-sites/:id/re-sync-deadline": handleReSyncDeadline,
"POST /admin/built-sites/:id/rotate-renewal-token": handleRotateToken,
"POST /admin/built-sites/:id/update": handleUpdateSite,
}),
);
18 changes: 9 additions & 9 deletions src/features/admin/bulk-actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* jscpd:ignore-start */
import { identity, mapById, requiredMapValue } from "#fp";
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
/* jscpd:ignore-end */
/**
* Bulk actions for groups.
Expand Down Expand Up @@ -350,12 +350,12 @@ const handleDuplicateGroupPost = groupFormPost(async (group, form) => {
});

/** Bulk actions routes */
export const adminHandlers = handlersFor("bulkActions")({
getGroupsByIdBulkActions: handleBulkActionsGet,
getGroupsByIdBulkActionsDeactivate: handleDeactivateGroupGet,
getGroupsByIdBulkActionsDuplicate: handleDuplicateGroupGet,
getGroupsByIdBulkActionsReactivate: handleReactivateGroupGet,
postGroupsByIdBulkActionsDeactivate: handleDeactivateGroupPost,
postGroupsByIdBulkActionsDuplicate: handleDuplicateGroupPost,
postGroupsByIdBulkActionsReactivate: handleReactivateGroupPost,
export const adminHandlers = defineRoutes({
"GET /admin/groups/:id/bulk-actions": handleBulkActionsGet,
"GET /admin/groups/:id/bulk-actions/deactivate": handleDeactivateGroupGet,
"GET /admin/groups/:id/bulk-actions/duplicate": handleDuplicateGroupGet,
"GET /admin/groups/:id/bulk-actions/reactivate": handleReactivateGroupGet,
"POST /admin/groups/:id/bulk-actions/deactivate": handleDeactivateGroupPost,
"POST /admin/groups/:id/bulk-actions/duplicate": handleDuplicateGroupPost,
"POST /admin/groups/:id/bulk-actions/reactivate": handleReactivateGroupPost,
});
18 changes: 9 additions & 9 deletions src/features/admin/bulk-email.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
/**
* Bulk email routes — compose, preview, send, and template management.
* Owner-only.
Expand Down Expand Up @@ -453,14 +453,14 @@ const templateDelete = createConfirmedHandlers<{ id: number; subject: string }>(
},
);

export const adminHandlers = handlersFor("bulkEmail")({
getEmails: handleComposeGet,
getEmailsPreview: handlePreviewGet,
getEmailsTemplatesByIdDelete: (request, { id }) =>
export const adminHandlers = defineRoutes({
"GET /admin/emails": handleComposeGet,
"GET /admin/emails/preview": handlePreviewGet,
"GET /admin/emails/templates/:id/delete": (request, { id }) =>
templateDelete.get(request, id),
postEmailsPreview: handlePreviewPost,
postEmailsSend: handleSendPost,
postEmailsTemplates: handleTemplateSavePost,
postEmailsTemplatesByIdDelete: (request, { id }) =>
"POST /admin/emails/preview": handlePreviewPost,
"POST /admin/emails/send": handleSendPost,
"POST /admin/emails/templates": handleTemplateSavePost,
"POST /admin/emails/templates/:id/delete": (request, { id }) =>
templateDelete.post(request, id),
});
8 changes: 4 additions & 4 deletions src/features/admin/calendar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handlersFor } from "#routes/admin/handlers.ts";
import { defineRoutes } from "#routes/router.ts";
/**
* Admin calendar view routes
*/
Expand Down Expand Up @@ -441,7 +441,7 @@ const handleAdminCalendarExport = (request: Request) =>
});

/** Calendar routes */
export const adminHandlers = handlersFor("calendar")({
getCalendar: handleAdminCalendarGet,
getCalendarExport: handleAdminCalendarExport,
export const adminHandlers = defineRoutes({
"GET /admin/calendar": handleAdminCalendarGet,
"GET /admin/calendar/export": handleAdminCalendarExport,
});
Loading