メインコンテンツまでスキップ
バージョン: 0.6.0 (Latest)

📦 Order Route Blocks

Order route blocks provide pre-configured HTTP endpoints for order management operations in Nodeblocks applications. These routes combine handlers, validators, and middleware to create complete API endpoints with proper authentication, authorization, and error handling.


🎯 Overview

Order route blocks are designed to:

  • Provide complete API endpoints for order management operations
  • Combine handlers with validators for secure operations
  • Include authentication and authorization checks
  • Support functional composition patterns
  • Handle logging and error management automatically

📋 Route Structure

Each order route follows a consistent pattern:

  • HTTP Method: Defines the operation type (GET, POST, PATCH, DELETE)
  • Path: Specifies the endpoint URL with parameters
  • Handler: Composed function chain for business logic
  • Validators: Authentication and authorization checks

🔧 Available Order Routes

createOrderRoute

Creates a new order and returns the created resource.

Purpose: Handles order creation with full resource retrieval

Route Details:

  • Method: POST
  • Path: /orders
  • Authentication: Required (Bearer token)

Handlers: createOrder, getOrderById, createOrderTerminator

Validators: isAuthenticated, some(checkIdentityType(['admin']), isSelf(['params', 'requestBody', 'identityId']))

Usage:

import { routes } from '@nodeblocks/backend-sdk';

// Register route with Express app
app.use('/api', routes.createOrderRoute);

getOrderRoute

Retrieves a specific order by ID.

Purpose: Fetches order data with access control

Route Details:

  • Method: GET
  • Path: /orders/:orderId
  • Authentication: Required (Bearer token)

Handlers: getOrderById, normalizeOrderTerminator

Validators: isAuthenticated, some(checkIdentityType(['admin']), ownsOrder(['params', 'requestParams', 'orderId']))

Usage:

import { routes } from '@nodeblocks/backend-sdk';

// Register route with Express app
app.use('/api', routes.getOrderRoute);

findOrdersRoute

Retrieves all orders with normalized list format.

Purpose: Lists orders with pagination and access control

Route Details:

  • Method: GET
  • Path: /orders
  • Authentication: Required (Bearer token)

Handlers: findOrders, normalizeOrdersListTerminator

Validators: isAuthenticated, some(checkIdentityType(['admin']), isSelf(['params', 'requestQuery', 'identityId']))

Usage:

import { routes } from '@nodeblocks/backend-sdk';

// Register route with Express app
app.use('/api', routes.findOrdersRoute);

updateOrderRoute

Updates an existing order and returns the updated resource.

Purpose: Modifies order data with access control

Route Details:

  • Method: PATCH
  • Path: /orders/:orderId
  • Authentication: Required (Bearer token)

Handlers: updateOrder, getOrderById, normalizeOrderTerminator

Validators: isAuthenticated, some(checkIdentityType(['admin']), ownsOrder(['params', 'requestParams', 'orderId']))

Usage:

import { routes } from '@nodeblocks/backend-sdk';

// Register route with Express app
app.use('/api', routes.updateOrderRoute);

deleteOrderRoute

Deletes an order by ID.

Purpose: Removes order with access control

Route Details:

  • Method: DELETE
  • Path: /orders/:orderId
  • Authentication: Required (Bearer token)

Handlers: deleteOrder, deleteOrderTerminator

Validators: isAuthenticated, some(checkIdentityType(['admin']), ownsOrder(['params', 'requestParams', 'orderId']))

Usage:

import { routes } from '@nodeblocks/backend-sdk';

// Register route with Express app
app.use('/api', routes.deleteOrderRoute);