db-tech-uk-lib
v1.0.1
Published
Browser client for DB-TECH UK common API (token / contact)
Readme
db-tech-uk-lib
DB-TECH UK 公開 API 用ブラウザクライアント。
インストール
npm install db-tech-uk-lib使い方
import { CommonClient } from 'db-tech-uk-lib';
// または
import { CommonClient } from 'db-tech-uk-lib/v1';
const client = new CommonClient({
isStage: true,
domainKey: 'your-domain-key',
});
await client.contact.submitContact({
mail: '[email protected]',
name: '山田太郎',
contents: 'お問い合わせ内容',
recaptchaToken: '...',
});API ごとに使う
import { ContactClient } from 'db-tech-uk-lib/v1';
const contact = new ContactClient({ isStage: true, domainKey: 'your-domain-key' });
await contact.submitContact({ ... });構成
src/clients/v1/
BaseClient.ts
TokenClient.ts
ContactClient.ts
CommonClient.ts| クラス | 役割 |
| :-- | :-- |
| BaseClient | 共通 HTTP・トークンキャッシュ |
| TokenClient | POST /v1/token |
| ContactClient | POST /v1/contact |
| CommonClient | 上記を1つにまとめた facade |
v2 API 追加時は clients/v2/ を増やし、db-tech-uk-lib/v2 として export します。
環境
| isStage | API |
| :-- | :-- |
| true | https://stage.d-b-tech.uk |
| false / 未指定 | https://d-b-tech.uk |
注意
- ブラウザ(許可ドメイン上のフロント)からの利用を想定しています
- reCAPTCHA トークンは呼び出し側で取得してください
