Shared apis endpoint service pattern
Skill kjuhwa/skills-hub/skills/frontend/shared-apis-endpoint-service-pattern
Self-correcting knowledge corpus for Claude Code — 9 stable shape clusters, bias-correction pipeline baked into contribution flow. 47 papers, 45 techniques, 1.1k skills.
npx -y skills add kjuhwa/skills-hub --skill shared-apis-endpoint-service-patternAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Module Federation 모노레포에서 REST 엔드포인트를 추가할 때 `endpoint 상수 → services 메서드 → commonApiService 호출` 3계층 레이어링으로 도메인 일관성을 유지하는 패턴.
SKILL.md
2.7 KB, 765 tokens by cl100k_base, as published. Nobody here has run it
Shared APIs: Endpoint + Service Layer Pattern
Purpose
MFA 모노레포의 shared/apis/ 하위에서 각 remote 가 동일한 방식으로 HTTP 호출을 하도록 3계층 규약을 강제한다. URL 하드코딩/중복 axios 인스턴스/타입 드리프트를 제거한다.
When to Activate
- remote 에서 새 REST 엔드포인트 호출이 필요
- "axios.get(...) 직접 호출" 하려는 코드가 PR 에 등장
- 엔드포인트 경로가 여러 파일에 복붙되는 상황
3-Layer Flow
Step 1. shared/apis/endpoint/<domain>EndPoint.ts
→ 경로 상수만 모음 (오타·중복 원천 차단)
예: export const WIDGET_ENDPOINT = {
LIST: '/api/widget/list',
DETAIL: '/api/widget/:id',
} as const
Step 2. shared/apis/<vendor>/<domain>/<domain>Services.ts
→ 엔드포인트 상수를 사용하는 서비스 메서드
- 요청 payload 타입, 응답 타입을 명시
- 공통 axios 인스턴스 재사용 (인터셉터/토큰/에러처리 일원화)
Step 3. 호출 측에서
commonApiService.<domain>Service.myMethod(payload)
→ remote 는 엔드포인트 상수도, axios 도 직접 import 하지 않는다
Rules
- remote 코드가
shared/apis/밖으로 HTTP 호출 우회하면 금지 - 엔드포인트 경로 변경은
endpoint/*.ts한 파일만 수정하면 되도록 유지 - path param 은 함수로 감싸거나 template 사용 (단순 문자열 replace 는 오타 취약)
- 응답 타입은
shared/models/...의 DTO 를 재사용, services 레이어 안에서 새로 선언하지 말 것
Checklist
-
endpoint/<domain>EndPoint.ts에 상수 추가 -
<domain>Services.ts에 메서드 추가 (payload/response 타입 명시) - 호출 측은
commonApiService.<domain>Service.*만 사용 - axios 또는 fetch 를 remote 내부에서 직접 쓰지 않음
- 엔드포인트 문자열이 services 파일 외부에 중복 존재하지 않음
Notes
- 이 레이어링 덕분에 공통 인터셉터(토큰 리프레시, 공용 에러 토스트, 다국어 메시지) 를 한 곳에서 유지 가능
- mocking / 테스트 시
commonApiService레벨에서 stub 하면 충분
Gives 0 of the 12 instructions most apis services skills give in 765 tokens
Counted across 424 of the 426 authors here whose files we hold, read 2026-08-06
- use plural nouns for resource namesin 41 of 424, across 32 files
- use cursor-based pagination for large datasetsin 35 of 424, across 20 files
- include rate limit headers in responsesin 25 of 424, across 13 files
- Use kebab-case for multi-word resourcesin 23 of 424, across 13 files
- version APIs in the URL pathin 19 of 424, across 9 files
- use semantic HTTP status codesin 18 of 424, across 8 files
- verify webhook signaturesin 18 of 424, across 11 files
- use query parameters for filteringin 17 of 424, across 6 files
- use async database operationsin 14 of 424, across 7 files
- wrap successful responses in a data fieldin 13 of 424, across 3 files
- prefix sorting parameters with a hyphen for descending orderin 13 of 424, across 3 files
- set appropriate HTTP status codesin 13 of 424, across 6 files
Said here and by no other author read
- place all endpoint constants in shared endpoint files
- create a service method for each endpoint call
- specify request and response types in service methods
- call only commonApiService in remote code
- reuse shared DTO models for response types
- use template strings or functions for path parameters
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.