Skip to content

Commit

Permalink
Publish client (#13)
Browse files Browse the repository at this point in the history
* Add client

* Fix unused

* Update version

* Remove deprecated script and use prepare
  • Loading branch information
anxolin authored Apr 17, 2024
1 parent 54e2518 commit 02e2bd2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cowprotocol/cms",
"version": "0.1.0-rc.0",
"version": "0.1.0-rc.4",
"description": "Cow Protocol CMS",
"main": "dist/lib.js",
"types": "dist/lib.d.ts",
Expand All @@ -18,9 +18,11 @@
"build:lib": "npx tsc -p tsconfig.lib.json",
"strapi": "strapi",
"types": "npx openapi-typescript src/extensions/documentation/documentation/1.0.0/full_documentation.json -o src/gen/types.ts",
"prepublish": "npm run build"
"prepare": "npm run build"
},
"dependencies": {
"openapi-fetch": "^0.9.3"
},
"dependencies": {},
"devDependencies": {
"@strapi/plugin-documentation": "4.13.3",
"@strapi/plugin-i18n": "4.13.3",
Expand Down
17 changes: 17 additions & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
export * from "./gen/types";

import createClient from "openapi-fetch";
import type { paths } from "./gen/types";

export interface CmsClientOptions {
url?: string;
}

/**
* Open API Fetch client. See docs for usage https://openapi-ts.pages.dev/openapi-fetch/
*/
export function CmsClient(options: CmsClientOptions = {}) {
const { url = "https://cms.cow.fi/api" } = options;
return createClient<paths>({
baseUrl: url,
});
}
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6392,6 +6392,18 @@ open@^8.0.9:
is-docker "^2.1.1"
is-wsl "^2.2.0"

openapi-fetch@^0.9.3:
version "0.9.3"
resolved "https://registry.yarnpkg.com/openapi-fetch/-/openapi-fetch-0.9.3.tgz#37c1dbde7faec885eaa40f351cab1c231b794761"
integrity sha512-tC1NDn71vJHeCzu+lYdrnIpgRt4GxR0B4eSwXNb15ypWpZcpaEOwHFkoz8FcfG5Fvqkz2P0Fl9zQF1JJwBjuvA==
dependencies:
openapi-typescript-helpers "^0.0.7"

openapi-typescript-helpers@^0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/openapi-typescript-helpers/-/openapi-typescript-helpers-0.0.7.tgz#1d0ead67c35864d189c2cb2d0556854ccbb16c38"
integrity sha512-7nwlAtdA1fULipibFRBWE/rnF114q6ejRYzNvhdA/x+qTWAZhXGLc/368dlwMlyJDvCQMCnADjpzb5BS5ZmNSA==

openapi-typescript@^6.7.5:
version "6.7.5"
resolved "https://registry.yarnpkg.com/openapi-typescript/-/openapi-typescript-6.7.5.tgz#3e7f0d080d540396ef8db3df4ed07e1a4a5bb1d8"
Expand Down

0 comments on commit 02e2bd2

Please sign in to comment.