defjs
0.3.0
def
define
의 약어이므로 define js
로 읽을 수 있습니다.
Defjs는 세부 사항에 대해 걱정하지 않고 요청을 더 쉽게 정의할 수 있도록 요청을 정의하고 시작하는 데 도움이 되는 라이브러리입니다.
패키지 관리자에 사용
npm install @defjs/core
// or
yarn install @defjs/core
// or
pnpm install @defjs/core
// or
bun install @defjs/core
CDN에 사용
ES 모듈만 사용할 수 있습니다.
import {
createGlobalClient ,
defineRequest ,
field
} from 'https://unpkg.com/@defjs/core/index.min.js' ;
/**
* @title Step 1
* @file src/main.ts
* @description Setting up a global client
*/
createGlobalClient ( {
host : 'https://example.com' ,
} ) ;
/**
* @title Step 2
* @file src/lib/api/user.ts
* @description Define the request api request in the lib/api directory of the project
*/
const useGetUser = defineRequest ( '/v1/user/:id' )
. withField ( {
id : field < number > ( ) . withParam ( )
} )
/**
* @title Step 3
* @file src/pages/home.ts
* @description Use defined requests in business code
*/
const { doRequest } = useGetUser ( ) ;
const { error , body } = await doRequest ( { id : 1 } ) ;
if ( error ) {
console . error ( error ) ;
return ;
}
console . log ( body ) ;
확인해 보세요. defjs.org를 시작하세요.
패키지 | 버전 |
---|---|
@defjs/코어 | |
@defjs/각도 |
MIT