🏢 Organization Feature Blocks
Organization feature blocks provide complete, pre-composed functionality for organization management operations in Nodeblocks applications. These features combine schemas, routes, and handlers to create ready-to-use API endpoints for organization CRUD operations, user management, and membership handling.
🎯 Overview
Organization feature blocks are designed to:
- Provide complete organization management with full CRUD operations
- Support user membership and role management within organizations
- Include validation and routing for secure organization operations
- Support filtering and pagination for organization and user listings
- Handle organization-user relationships and access control
📋 Feature Structure
Each organization feature follows a consistent composition pattern:
- Schema: Validates organization input data and parameters
- Route: Provides HTTP endpoint with organization handlers
- Composition: Combines schema and route using
composefunction
🔧 Available Organization Features
createOrganizationFeature
Organization creation feature with schema validation and routing.
Purpose: Handles organization creation with complete validation
Composition:
- Schema:
createOrganizationSchema- validates name, description, contact_email, and optional fields - Route:
createOrganizationRoute- POST/organizationswith creation handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.createOrganizationFeature, [{ dataStores: db }])));
API Endpoint: POST /api/organizations
getOrganizationFeatures
Organization retrieval feature for getting individual organization data.
Purpose: Fetches organization information with proper validation
Composition:
- Schema:
getOrganizationSchema- validates path parameters - Route:
getOrganizationRoute- GET/organizations/:idwith retrieval handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.getOrganizationFeatures, [{ dataStores: db }])));
API Endpoint: GET /api/organizations/:organizationId
findOrganizationsFeatures
Organization search feature with filtering and pagination.
Purpose: Provides organization listing with search capabilities
Composition:
- Schema:
findOrganizationsSchema- validates query parameters for filtering - Route:
findOrganizationsRoute- GET/organizationswith search and pagination
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.findOrganizationsFeatures, [{ dataStores: db }])));
API Endpoint: GET /api/organizations
editOrganizationFeatures
Organization update feature with schema validation and routing.
Purpose: Modifies organization information with proper validation
Composition:
- Schema:
updateOrganizationSchema- validates partial organization properties - Route:
updateOrganizationRoute- PUT/organizations/:idwith update handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.editOrganizationFeatures, [{ dataStores: db }])));
API Endpoint: PUT /api/organizations/:organizationId
deleteOrganizationFeatures
Organization deletion feature with routing.
Purpose: Removes organizations with access control and cleanup
Composition:
- Schema:
deleteOrganizationSchema- validates path parameters - Route:
deleteOrganizationRoute- DELETE/organizations/:idwith deletion handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.deleteOrganizationFeatures, [{ dataStores: db }])));
API Endpoint: DELETE /api/organizations/:organizationId
getOrganizationUserFeatures
Organization user role retrieval feature for getting user roles within organizations.
Purpose: Retrieves user roles within specific organizations
Composition:
- Schema:
getOrganizationUserRoleSchema- validates path parameters - Route:
getOrganizationUserRoleRoute- GET/organizations/:id/users/:userId/rolewith role retrieval handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.getOrganizationUserFeatures, [{ dataStores: db }])));
API Endpoint: GET /api/organizations/:organizationId/users/:userId/role
checkOrganizationUserExistenceFeatures
Organization user existence check feature for validating user membership.
Purpose: Validates user membership in organizations
Composition:
- Schema:
checkOrganizationUserExistenceSchema- validates path parameters - Route:
checkOrganizationUserExistenceRoute- GET/organizations/:id/users/:userId/exists
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.checkOrganizationUserExistenceFeatures, [{ dataStores: db }])));
API Endpoint: GET /api/organizations/:organizationId/users/:userId/exists
findOrganizationUsersFeatures
Organization users search feature with filtering and pagination.
Purpose: Provides organization user listing with search capabilities
Composition:
- Schema:
findOrganizationUsersSchema- validates query parameters for filtering - Route:
findOrganizationUsersRoute- GET/organizations/:id/userswith search and pagination
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.findOrganizationUsersFeatures, [{ dataStores: db }])));
API Endpoint: GET /api/organizations/:organizationId/users
findOrganizationsForUserFeatures
User organizations search feature for finding organizations by user ID.
Purpose: Finds organizations associated with a specific user
Composition:
- Schema:
findOrganizationsForUserSchema- validates path parameters - Route:
findOrganizationsForUserRoute- GET/users/:userId/organizations
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.findOrganizationsForUserFeatures, [{ dataStores: db }])));
API Endpoint: GET /api/users/:userId/organizations
editOrganizationUsersFeatures
Organization user management feature with schema validation for upserting users.
Purpose: Manages user membership and roles within organizations
Composition:
- Schema:
upsertOrganizationUsersSchema- validates array of user objects with id and role - Route:
upsertOrganizationUsersRoute- PUT/organizations/:id/userswith upsert handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.editOrganizationUsersFeatures, [{ dataStores: db }])));
API Endpoint: PUT /api/organizations/:organizationId/users
deleteOrganizationUserFeatures
Organization user deletion feature with routing.
Purpose: Removes users from organizations with proper cleanup
Composition:
- Schema:
deleteOrganizationUserSchema- validates path parameters - Route:
deleteOrganizationUserRoute- DELETE/organizations/:id/users/:userId
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.deleteOrganizationUserFeatures, [{ dataStores: db }])));
API Endpoint: DELETE /api/organizations/:organizationId/users/:userId