no-as-a-service-api-client
v1.1.1
Published
A tiny JavaScript client for the “No As A Service” API that delivers random rejection reasons with a consistent, typed response format.
Maintainers
Readme
No As A Service API Client
A tiny JavaScript client for the “No As A Service” API (https://naas.isalman.dev/no) that delivers random rejection reasons with a consistent, typed response format.
📦 Installation
npm install no-as-a-service-api-client📜 Features
- Zero configurations
- Native
fetch(no dependencies) - Fully typed responses
- Consistent API success/error wrapper
- Works in modern browsers and Node.js (ES6 Imports)
🔤 Example Usage
import { getANo } from 'no-as-a-service-api-client';
async function run() {
const response = await getANo();
if (response.code === 'api-ok') {
console.log(response.payload?.reason);
} else {
console.error(response.message);
}
}
run();
// Sample Success Response
/*
{
"code": "api-ok",
"message": "No errors encountered, check payload",
"payload": {
"reason": "I didn’t receive the memo that I was supposed to care."
}
}
*/
// Sample Error Response
/*
{
"code": "api-fail",
"message": "Something went wrong",
"payload": null
}
*/📗 Test Coverage
PASS src/get-a-no/index.test.ts
getANo
✓ 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 reason 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.
