npx skills add smithery/feraudet --skill api-conventions
mx-space/core · Archived
api-conventions
Mix Space API design conventions. Apply when writing controllers, API endpoints, or handling HTTP requests.
Installation
npx skills add mx-space/core --skill api-conventions
Stronger alternatives
This repository is archived — consider an actively maintained alternative.
Mix Space project Zod schema patterns. Apply when creating DTOs, validation schemas, or handlin…
44 installsCreate a new NestJS module with repository, service, controller, schema, and Drizzle table defi…
3 installsRun tests. Supports running all tests, single file, or pattern-matched tests.
3 installsReview code for Mix Space project conventions. Checks NestJS patterns, Drizzle ORM repositories…
3 installsSimilar popular skills
Related neighbors and high-traction skills in the same topics — useful to compare before installing.
Guidance for distinctive, intentional visual design when building new UI or reshaping an existi…
866.4K installsBrowser automation CLI for AI agents. Use when the user needs to interact with websites, includ…
810.4K installsReview UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "chec…
617.3K installsBuild, deploy, evaluate, optimize, fine-tune, and manage Microsoft Foundry agents, models, and …
576.5K installsDebug Azure production issues on Azure using AppLens, Azure Monitor, resource health, and safe …
568.9K installsAlso in this package
Other skills from mx-space/core · top by installs.
npx skills add mx-space/core
More details
Agent compatibility
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
Also listed on
Alternate registries and mirrors of this skill.
Repository health
master
Package contents
Files included with this skill beyond the listing page.
-
skill md
SKILL.md4,692 B -
docs
SUMMARY.md130 B
History
- First seen on skills.sh
- First recorded snapshot · 37 installs
SKILL.md
Mix Space API Design Conventions
Controller Decorators
// Use @ApiController instead of @Controller
// Dev environment has no prefix, production auto-adds /api/v{version} prefix
@ApiController('posts') // ✓
@Controller('posts') // ✗
Authentication
// Endpoints requiring login
@Auth()
async create() {}
// Optional auth (get current user status)
async get(@IsAuthenticated() isAuth: boolean) {}
// Get current user
async get(@CurrentUser() user: UserModel) {}
Response Transformation
ResponseInterceptor (global APP_INTERCEPTOR) wraps every controller return value:
| Return value | Emitted |
|---|---|
bare value T |
{ data: T } |
withMeta(data, meta) |
{ data, meta } |
undefined |
204 No Content |
@HTTPDecorators.RawResponse |
untouched — skips envelope and case conversion |
withMeta (from ~/common/response/envelope.types) is detected by an internal Symbol, not by the presence of a data key — returning an object literal whose top-level keys include data gets double-wrapped. CI enforces this via scripts/check-controller-response-envelope.ts.
transformResponseCase (~/common/response/case-transform.ts) converts the response data/meta to snake_case at the wire boundary:
createdAt→created_atcategoryId→category_id
Opt a field subtree out with @BypassCaseTransform(['items[].rawPayload']).
Pagination
Pagination belongs in meta, never merged into data. Build it with MetaObjectBuilder:
@Get('/')
async list(@Query({ schema: BasicPagerSchema }) query: BasicPagerInput) {
const result = await this.postRepository.list({
page: query.page,
size: query.size,
sortBy: query.sortBy,
sortOrder: query.sortOrder,
})
const metaBuilder = new MetaObjectBuilder().view('card').pagination({
page: result.pagination.currentPage,
size: result.pagination.size,
total: result.pagination.total,
totalPages: result.pagination.totalPage,
})
return withMeta(result.data, metaBuilder.build())
}
For CRUD boilerplate, use BasePgCrudFactory:
@ApiController(paths)
export class LinkControllerCrud extends BasePgCrudFactory({
repository: LinkRepository,
}) {
@Get('/')
async gets(@Query({ schema: BasicPagerSchema }) pager: BasicPagerInput) {
const { size = 10, page = 1 } = pager
return this.repository.list(page, size)
}
}
Parameter Validation
// Path parameters — attach EntityIdSchema for Snowflake entity IDs
@Get('/:id')
async get(@Param({ schema: EntityIdSchema }) params: EntityIdInput) {
return this.service.findById(params.id)
}
// For integer IDs or entity IDs (e.g. notes with nid)
@Get('/:id')
async get(@Param({ schema: IntIdOrEntityIdSchema }) params: IntIdOrEntityIdInput) {}
// Query parameters
@Get('/')
async list(@Query({ schema: BasicPagerSchema }) query: BasicPagerInput) {}
// Request body
@Post('/')
async create(@Body({ schema: CreateSchema }) body: CreateInput) {}
HTTP Methods
| Method | Purpose | Status Code |
|---|---|---|
| GET | Retrieve resource | 200 |
| POST | Create resource | 201 |
| PUT | Full update | 200 |
| PATCH | Partial update | 200 |
| DELETE | Delete resource | 204 |
Error Handling
import { BusinessException } from '~/common/exceptions/biz.exception'
import { ErrorCodeEnum } from '~/constants/error-code.constant'
// Business errors
throw new BusinessException(ErrorCodeEnum.PostNotFound)
throw new BusinessException(ErrorCodeEnum.SlugNotAvailable, slug)
// HTTP errors
throw new BadRequestException('Invalid input')
throw new NotFoundException('Resource not found')
throw new UnauthorizedException('Not logged in')
Idempotency
// Add idempotency protection for create operations
@Post('/')
@HTTPDecorators.Idempotence()
async create() {}
// Custom idempotency key
@HTTPDecorators.Idempotence({ key: 'custom-key' })
Caching
// Disable cache
@Get('/')
@HttpCache.disable
async list() {}
// Custom cache
@HttpCache({ ttl: 60, key: 'my-key' })
async get() {}