@surflux-studio/restful 3.2.10 • Public • Published 2 days ago
bun add @surflux-studio/restful
# ~/.aws/credentials
[default]
aws_access_key_id =
aws_secret_access_key =
# .env
# ## AWS Secrets Manager
AWS_REGION=
AWS_SECRET_NAME=
# ## JWT
JWT_ADMIN=
JWT_TYPE=
JWT_ALGORITHM=
JWT_ISSUER=
JWT_AUDIENCE=
SERVICE_NAME=
# ## Database
PGUSER=
PGHOST=
PGDB=
PGPW=
PGPORT=
Response의 Content-Type은 무조건 application/json
Ok는 딱히 신경 안씀
status 필히 기입
response.json() 은 RestResponseBody 타입입니다.
400 - Zod 유효성 검사 에러, 토큰이 없을때, 잘못된 요청
401 - 유효하지 않은 토큰
403 - 타겟에 대해서 토큰이 권한이 없거나 부족할때
404 - API 가 없을때 (컨텐츠가 없는건 200임)
must set AWS_REGION and AWS_SECRET_NAME env
if NODE_ENV === 'development' return 'hello'
if NODE_ENV === 'production' return secret from AWS Secrets Manager
jwt: server의 JWT를 재시작시 발급합니다.
verifyJwt(jwt: string, condition: { admin?: boolean, type?: "a"|"r", subject?: string }): jwt 를 condition 과 비교해서 일치하지 않을 시에 throw, 일치 할 시에 payload 를 반환합니다.
decodeJwt: jwt의 payload를 확인합니다.
test 파일 확인
Readme Keywords none
Package Sidebar Install npm i @surflux-studio/restful
Downloads Weekly Downloads