A minimal JavaScript/TypeScript client for the Yes As A Service API — an API that always responds with a positive affirmation.
npm install yes-as-a-service-api-client!yes-hero-banner-illustration
!npm
!downloads
!license
A tiny JavaScript/TypeScript client for the Yes As A Service API — fetch random positive affirmations with a single request.
``console`
npm install yes-as-a-service-api-client
1. Zero configuration
2. No inputs required
3. Minimal surface area
4. Predictable API responses
5. Native fetch support
6. TypeScript-first
`javascript
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
}*/
`
``
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 |
----------|---------|----------|---------|---------|-------------------
Contributions, suggestions, and improvements are welcome.
Feel free to open issues or pull requests.
Like this project? Support it with a github star, it would mean a lot to me! Cheers and Happy Coding.