feat: add slug helper, protocol config endpoint, request ID middleware, and API error formatter#17
Merged
Chucks1093 merged 1 commit intoMar 25, 2026
Conversation
…e, and API error formatter Issue accesslayerorg#11 - Creator slug generation helper (src/utils/slug.utils.ts): - generateSlug() normalizes input to URL-safe lowercase slugs - Handles spaces, special characters, consecutive hyphens - Deterministic: same input always produces same output - generateSlugWithSuffix() appends numeric disambiguator for uniqueness Issue accesslayerorg#14 - Public protocol config endpoint (src/modules/config/): - GET /api/v1/config returns lightweight bootstrap payload - Response includes environment, API version, network, feature flags, and display settings - Safe for unauthenticated use, no sensitive data exposed - Documented response shape in TypeScript interface Issue accesslayerorg#15 - Request ID middleware (src/middlewares/request-id.middleware.ts): - Generates UUID v4 for each request or forwards client X-Request-ID header - Attaches requestId to req object for downstream logging - Returns X-Request-ID in response header for client correlation - Registered early in middleware chain (before CORS/helmet) Issue accesslayerorg#16 - Consistent API error formatter (src/utils/api-response.utils.ts): - Standard error shape: { success, error: { code, message, details? } } - Standard success shape: { success, data, message? } - Typed error codes: VALIDATION_ERROR, NOT_FOUND, UNAUTHORIZED, etc. - Convenience helpers: sendError, sendSuccess, sendValidationError, sendNotFound, sendUnauthorized, sendForbidden, sendConflict Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@Uchechukwu-Ekezie Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/utils/slug.utils.ts) that normalizes names/handles into stable, URL-safe slugs with optional numeric suffix for uniquenessGET /api/v1/config(src/modules/config/) returning lightweight bootstrap data (environment, API version, network, feature flags, display settings) without exposing sensitive informationsrc/middlewares/request-id.middleware.ts) that assigns a UUID v4 to every request (or forwards the clientX-Request-IDheader), attaches it toreq.requestId, and returns it in the response header for tracingsrc/utils/api-response.utils.ts) with a consistent response shape ({ success, error: { code, message, details? } }) and typed error codes so frontend clients can parse errors predictablyFiles changed
src/utils/slug.utils.ts(new) - Slug generation helperssrc/modules/config/config.controllers.ts(new) - Protocol config controllersrc/modules/config/config.routes.ts(new) - Protocol config routesrc/middlewares/request-id.middleware.ts(new) - Request ID middlewaresrc/utils/api-response.utils.ts(new) - API response formatterssrc/app.ts(modified) - Register request ID middlewaresrc/modules/index.ts(modified) - Register config routeTest plan
generateSlug("John Doe")returns"john-doe"generateSlugis deterministic (same input, same output)GET /api/v1/configreturns 200 with expected shapeX-Request-IDheaderX-Request-IDis forwarded throughsendError()produces{ success: false, error: { code, message } }sendSuccess()produces{ success: true, data }Closes #11
Closes #14
Closes #15
Closes #16