Skip to content

zesty-io/fetch-wrapper

Repository files navigation

zesty logo

Zesty.io API Fetch Wrapper

GitHub package.json version GitHub issues TypeScript Webpack NPM

A javascript fetch wrapper for the Zesty.io APIs for frontend clients. For a backend node wrapper, use the Zesty.io Node SDK

⚡ Getting Started

Include the fetch wrapper into your project

<script
   async
   src="https://cdn.jsdelivr.net/gh/zesty-io/fetch-wrapper@latest/dist/index.js"
></script>

🚀 Example Usage

For this wrapper to run, you need an authenticated Zesty.io user APP_SID and a Instance ZUID

const instanceZUID = "8-xyzxyz-xyz"
const userAppSID = "xxxxxxxxxx"

const ZestyAPI = new Zesty.FetchWrapper(instanceZUID, userAppSID)

console.log(ZestyAPI.getModels())

🎯 Features

API Service the Wrapper can Access

Note all endpoints are ported. If you wish to port any missing endpoints, create a fork and pull request.

💡 Running locally

  • 🙂 Using npm install

npm install && npm start

then add this in the head of Html

<script async src="http://localhost:8080/index.js"></script>
  • 🐳 Using Docker

docker build -t fetchWrapper .
docker run -p 8080:8080 fetchWrapper

then add this in the head of Html

<script async src="http://localhost:8080/index.js"></script>

💡 Use in Development Mode

To access dev and stage api url for zesty development, pass options to the instantation like so:

const instanceZUID = "8-xyzxyz-xyz"
const userAppSID = "xxxxxxxxxx"

const ZestyAPI = new Zesty.FetchWrapper(instanceZUID, userAppSID, {
   sitesServiceURL: "https://svc.dev.zesty.io/sites-service/",
   instancesAPIURL: ".api.dev.zesty.io/v1",
   authAPIURL: "https://auth.api.dev.zesty.io",
   accountsAPIURL: "https://accounts.api.dev.zesty.io/v1",
   mediaAPIURL: "https://svc.dev.zesty.io",
})

console.log(ZestyAPI.getModels())

💡 When commiting to github use

npm run commit

💡 Bulding in Production

  • Automated

    • On successful merge to main will publish new release
  • Manually

git checkout main && npm run build && npm run release

🖥️ Code Contributors