🛣️ Profile Routes
Profile routes provide pre-configured HTTP endpoints for profile relationship management operations in NodeBlocks applications. These routes combine blocks, validators, and middleware to create complete API endpoints with proper authentication, authorization, and error handling.
🎯 Overview
Profile routes are designed to:
- Provide complete API endpoints for profile relationship management operations
- Combine blocks with validators for secure operations
- Include authentication and authorization checks
- Support functional composition patterns
- Handle logging and error management automatically
- Support social relationships including follows, organization follows, and product likes
📋 Route Structure
Each profile route follows a consistent pattern:
- HTTP Method: Defines the operation type (GET, PUT, DELETE)
- Path: Specifies the endpoint URL with parameters
- Handler: Composed function chain for business logic
- Validators: Authentication and authorization checks
🔧 Available Profile Routes
createProfileFollowRoute
Creates a profile follow relationship via PUT /profiles/:profileId/profile-follows/:followProfileId.
Purpose: Provides an API endpoint for creating social follow relationships between profiles, automatically preventing duplicates and ensuring proper authentication and authorization.
Route Details:
- Method:
PUT - Path:
/profiles/:profileId/profile-follows/:followProfileId - Authentication: Required (Bearer token)
Blocks: getUserById, createProfileFollow
Validators: isAuthenticated, some(checkIdentityType(['admin']), ownsProfile(['params', 'requestParams', 'profileId']))
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.createProfileFollowRoute);
deleteProfileFollowRoute
Deletes a profile follow relationship via DELETE /profiles/:profileId/profile-follows/:followProfileId.
Purpose: Provides an API endpoint for removing social follow relationships between profiles (unfollowing), ensuring proper authentication and authorization.
Route Details:
- Method:
DELETE - Path:
/profiles/:profileId/profile-follows/:followProfileId - Authentication: Required (Bearer token)
Blocks: getUserById, deleteProfileFollow
Validators: isAuthenticated, some(checkIdentityType(['admin']), ownsProfile(['params', 'requestParams', 'profileId']))
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.deleteProfileFollowRoute);
getProfileFollowersRoute
Retrieves profile followers via GET /profiles/:profileId/followers.
Purpose: Provides an API endpoint for retrieving a paginated list of followers for a specific profile, with normalized avatar URLs.
Route Details:
- Method:
GET - Path:
/profiles/:profileId/followers - Authentication: Required (Bearer token)
Blocks: getUserById, buildProfileFollowersByFollowProfileIdQuery, findProfiles, normalizeFollowers
Validators: isAuthenticated, some(checkIdentityType(['admin']), ownsProfile(['params', 'requestParams', 'profileId']))
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.getProfileFollowersRoute);
createOrganizationFollowRoute
Creates organization follow relationship via PUT /profiles/:profileId/organization-follows/:followOrganizationId.
Purpose: Provides an API endpoint for creating organization follow relationships, allowing profiles to follow organizations.
Route Details:
- Method:
PUT - Path:
/profiles/:profileId/organization-follows/:followOrganizationId - Authentication: Required (Bearer token)
Blocks: getUserById, getOrganizationById, createOrganizationFollow
Validators: isAuthenticated, some(checkIdentityType(['admin']), ownsProfile(['params', 'requestParams', 'profileId']))
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.createOrganizationFollowRoute);
deleteOrganizationFollowRoute
Deletes organization follow relationship via DELETE /profiles/:profileId/organization-follows/:followOrganizationId.
Purpose: Provides an API endpoint for removing organization follow relationships, allowing profiles to unfollow organizations.
Route Details:
- Method:
DELETE - Path:
/profiles/:profileId/organization-follows/:followOrganizationId - Authentication: Required (Bearer token)
Blocks: getUserById, getOrganizationById, deleteOrganizationFollow
Validators: isAuthenticated, some(checkIdentityType(['admin']), ownsProfile(['params', 'requestParams', 'profileId']))
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.deleteOrganizationFollowRoute);
createProductLikeRoute
Creates a product like relationship for a user profile via PUT /profiles/:profileId/product-likes/:likeProductId.
Purpose: Enables profiles to like or add products to favorites.
Route Details:
- Method:
PUT - Path:
/profiles/:profileId/product-likes/:likeProductId - Authentication: Required (Bearer token)
Blocks: getUserById, getProductById, createProductLike
Validators: isAuthenticated, some(checkIdentityType(['admin']), ownsProfile(['params', 'requestParams', 'profileId']))
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.createProductLikeRoute);
deleteProductLikeRoute
Removes a product like from a user profile via DELETE /profiles/:profileId/product-likes/:likeProductId.
Purpose: Enables profiles to unlike or remove favorites from products.
Route Details:
- Method:
DELETE - Path:
/profiles/:profileId/product-likes/:likeProductId - Authentication: Required (Bearer token)
Blocks: getUserById, getProductById, deleteProductLike
Validators: isAuthenticated, some(checkIdentityType(['admin']), ownsProfile(['params', 'requestParams', 'profileId']))
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.deleteProductLikeRoute);
🔗 Related Documentation
- Profile Schemas - Profile data validation and contracts
- Profile Blocks - Profile business logic functions