Skip to main content
Version: 0.13.0 (Previous)

⚙️ Organization handlers

Organization handlers are route-pipeline functions, not Express middleware. They read RouteHandlerPayload values from params and context, merge successful values into context.data, or terminate a successful Result with an HTTP response descriptor. These exports are terminators that shape HTTP responses after prior pipeline steps.

Inventory​

HandlerPipeline roleInputs / contextResult / behavior / errorsUsed by routes
normalizeOrganizationTerminatorTerminatorcontext.data.organizationRemoves _id and returns the organization; missing organization is 500.createOrganizationRoute, getOrganizationRoute, updateOrganizationRoute, updateOrganizationAsAdminRoute
normalizeOrganizationsListTerminatorTerminatorcontext.data.organizationsRemoves _id from an array or paginated data; malformed or missing value is 500.findOrganizationsRoute
deleteOrganizationTerminatorTerminatorcontext.data.hasDeletedOrganizationReturns {statusCode: 204} when deletion succeeded; otherwise 500.deleteOrganizationRoute
normalizeOrganizationMemberExistenceTerminatorTerminatorcontext.data.isMemberOfOrganizationReturns {isMemberOfOrganization}; missing value is 500.checkOrganizationMemberExistenceRoute
normalizeOrganizationMembersListTerminatorTerminatorcontext.data.organizationMembersReturns the member array or paginated shape; malformed or missing value is 500.findOrganizationMembersRoute
deleteOrganizationMemberTerminatorTerminatorcontext.data.hasDeletedOrganizationMemberReturns {statusCode: 204} when member deletion succeeded; otherwise 500.deleteOrganizationMemberRoute
upsertOrganizationMembersTerminatorTerminatorcontext.data.hasUpsertedOrganizationMembersReturns {statusCode: 204} when upsert succeeded; otherwise 500.upsertOrganizationMembersRoute

Details​

normalizeOrganizationTerminator​

Implementation

Throws result.error when the pipeline result is an error. On success, reads context.data.organization, removes its database-only _id, and returns the remaining public organization object. Missing organization throws NodeblocksError(500, 'Unknown error normalizing organization', 'normalizeOrganizationTerminator'). Used by createOrganizationRoute, getOrganizationRoute, updateOrganizationRoute, and updateOrganizationAsAdminRoute.

normalizeOrganizationsListTerminator​

Implementation

Throws result.error when the pipeline result is an error. Reads context.data.organizations: for an array, removes _id from each item; for a paginated value, returns {data, metadata: {pagination}} with _id removed from each item. A value that is neither an array nor an object with array data throws NodeblocksError(500, 'Unknown error normalizing organizations list', 'normalizeOrganizationsListTerminator'). Used by findOrganizationsRoute.

deleteOrganizationTerminator​

Implementation

Throws result.error when the pipeline result is an error. Requires truthy context.data.hasDeletedOrganization, then returns {statusCode: 204}. A missing or false value throws NodeblocksError(500, 'Unknown error deleting organization', 'deleteOrganizationTerminator'). Used by deleteOrganizationRoute, where it is the final terminator.

normalizeOrganizationMemberExistenceTerminator​

Implementation

Throws result.error when the pipeline result is an error. Reads context.data.isMemberOfOrganization and returns {isMemberOfOrganization}; false is valid, but a null or undefined value throws NodeblocksError(500, 'Unknown error normalizing organization member existence', 'normalizeOrganizationMemberExistenceTerminator'). Used by checkOrganizationMemberExistenceRoute.

normalizeOrganizationMembersListTerminator​

Implementation

Throws result.error when the pipeline result is an error. Reads context.data.organizationMembers and returns it directly when it is an array; for a paginated value, returns {data, metadata: {pagination}}. A value that is neither form throws NodeblocksError(500, 'Unknown error normalizing organization members', 'normalizeOrganizationMembersListTerminator'). Used by findOrganizationMembersRoute.

deleteOrganizationMemberTerminator​

Implementation

Throws result.error when the pipeline result is an error. Requires truthy context.data.hasDeletedOrganizationMember, then returns {statusCode: 204}. A missing or false value throws NodeblocksError(500, 'Unknown error deleting organization member', 'deleteOrganizationMemberTerminator'). Used by deleteOrganizationMemberRoute, where it is the final terminator.

upsertOrganizationMembersTerminator​

Implementation

Throws result.error when the pipeline result is an error. Requires truthy context.data.hasUpsertedOrganizationMembers, then returns {statusCode: 204}. A missing or false value throws NodeblocksError(500, 'Unknown error when trying to upsert organization members', 'upsertOrganizationMembersTerminator'). Used by upsertOrganizationMembersRoute, where it is the final terminator.