yes-as-a-service-api-client
v1.1.4
Published
A minimal JavaScript/TypeScript client for the Yes As A Service API — an API that always responds with a positive affirmation.
Maintainers
Readme
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
- Zero configuration
- No inputs required
- Minimal surface area
- Predictable API responses
- Native fetch support
- 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.
🔒 Security & Privacy
- This package is open source and intended to provide reusable utilities for application development. It does not collect, store, transmit, sell, or share user data, and it does not include analytics, tracking, telemetry, cookies, local storage usage, backend services, or project-owned data collection mechanisms.
- For more details, including vulnerability reporting guidance and consumer security recommendations, please see the Security Policy.
❤️ Support
Like this project? Support it with a github star, it would mean a lot to me! Cheers and Happy Coding.
