Skip to content

NPM-Workbench/yes-as-a-service-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yes-hero-banner-illustration npm downloads license NPM Unpacked Size

Yes As A Service API Client

A tiny JavaScript/TypeScript client for the Yes As A Service API — fetch random positive affirmations with a single request.

📦 Installation

npm install yes-as-a-service-api-client

🐚 Design Philosophy

  1. Zero configuration
  2. No inputs required
  3. Minimal surface area
  4. Predictable API responses
  5. Native fetch support
  6. TypeScript-first

🔤 Example Usage

import { getAYes } from 'yes-as-a-service-api-client';

async function run() {
  const response = await getAYes();
  if (response.code === 'api-ok') {
    console.log(response.payload?.affirmation);
  } else {
    console.error(response.message);
  }
}

run();

// Sample Success Response
/*
{
  "code": "api-ok",
  "message": "No errors encountered, check payload",
  "payload": {
    "affirmation": "Yes! Everything is working exactly as intended."
  }
}
*/

// Sample Error Response
/*{
  "code": "api-fail",
  "message": "Something went wrong",
  "payload": null
}*/

📗 Test Coverage

PASS  src/get-a-yes/index.test.ts
  getAYes
    ✓ returns api-ok and payload when fetch resolves with ok=true
    ✓ returns api-fail when response.ok is false
    ✓ returns api-fail when fetch throws
    ✓ returns api-fail when json parsing fails
    ✓ returns object payload with affirmation on success (payload test)
    ✓ returns null payload on fetch error (payload null test)
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |     100 |      100 |     100 |     100 |
 index.ts |     100 |      100 |     100 |     100 |
----------|---------|----------|---------|---------|-------------------

📘 Contributing

Contributions, suggestions, and improvements are welcome.
Feel free to open issues or pull requests.

❤️ Support

Like this project? Support it with a github star, it would mean a lot to me! Cheers and Happy Coding.

About

Yes As A Service API Client is a lightweight JavaScript/TypeScript wrapper for the Yes As A Service API (https://yes.lavx.hu/). It provides a clean, predictable response structure for fetching random positive affirmations using native fetch

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors