yes-as-a-service-api-client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ ![yes-hero-banner-illustration](https://github.com/user-attachments/assets/9623e970-e9ba-4847-bb28-8bfc8fb2dea2)
2
+ # Yes As A Service API Client
3
+ A tiny JavaScript/TypeScript client for the Yes As A Service API — fetch random positive affirmations with a single request.
4
+
5
+ ### 📦 Installation
6
+ ```console
7
+ npm install yes-as-a-service-api-client
8
+ ```
9
+
10
+ ### 📜 Design Philosophy
11
+ 1. Zero configuration
12
+ 2. No inputs required
13
+ 3. Minimal surface area
14
+ 4. Predictable API responses
15
+ 5. Native fetch support
16
+ 6. TypeScript-first
17
+
18
+ ### 🔤 Example Usage
19
+ ```javascript
20
+ import { getAYes } from "yes-as-a-service-api-client";
21
+
22
+ async function run() {
23
+ const response = await getAYes();
24
+ if (response.code === "api-ok") {
25
+ console.log(response.payload?.affirmation);
26
+ } else {
27
+ console.error(response.message);
28
+ }
29
+ }
30
+
31
+ run();
32
+
33
+ // Sample Success Response
34
+ /*
35
+ {
36
+ "code": "api-ok",
37
+ "message": "No errors encountered, check payload",
38
+ "payload": {
39
+ "affirmation": "Yes! Everything is working exactly as intended."
40
+ }
41
+ }
42
+ */
43
+
44
+ // Sample Error Response
45
+ /*{
46
+ "code": "api-fail",
47
+ "message": "Something went wrong",
48
+ "payload": null
49
+ }*/
50
+ ```
51
+
52
+ ### 📘 Contributing
53
+ Contributions, suggestions, and improvements are welcome.<br/>
54
+ Feel free to open issues or pull requests.
55
+
56
+ ### ❤️ Support
57
+ Like this project? Support it with a github star, it would mean a lot to me! Cheers and Happy Coding.
@@ -0,0 +1,5 @@
1
+ import { TAPIResponse } from "../types/index.js";
2
+ type TOutput = TAPIResponse;
3
+ declare function getAYes(): Promise<TOutput>;
4
+ export { getAYes };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/get-a-yes/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,KAAK,OAAO,GAAG,YAAY,CAAC;AAG5B,iBAAe,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CA2BzC;AAGD,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,34 @@
1
+ /* app imports */
2
+ import { API_ROOT } from "../shared/index.js";
3
+ /* module */
4
+ async function getAYes() {
5
+ try {
6
+ /* setup */
7
+ const API_URL = `${API_ROOT}/yes`;
8
+ /* fetch */
9
+ const response = await fetch(API_URL);
10
+ /* check and return */
11
+ if (!response.ok) {
12
+ throw new Error("Get A Yes: Sorry, Something Went Wrong");
13
+ }
14
+ else {
15
+ const affirmation = await response.json();
16
+ return {
17
+ code: "api-ok",
18
+ message: "No errors encountered, check payload",
19
+ payload: { affirmation }
20
+ };
21
+ }
22
+ }
23
+ catch (error) {
24
+ console.error(error);
25
+ return {
26
+ code: "api-fail",
27
+ message: "Oops, something went wrong!",
28
+ payload: null,
29
+ };
30
+ }
31
+ }
32
+ /* exports */
33
+ export { getAYes };
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/get-a-yes/index.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAM9C,YAAY;AACZ,KAAK,UAAU,OAAO;IACpB,IAAK,CAAC;QACJ,WAAW;QACX,MAAM,OAAO,GAAG,GAAG,QAAQ,MAAM,CAAC;QAElC,WAAW;QACX,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;QAEtC,sBAAsB;QACtB,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;aAAM,CAAC;YACN,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC1C,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,sCAAsC;gBAC/C,OAAO,EAAE,EAAE,WAAW,EAAE;aACzB,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,6BAA6B;YACtC,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC;AAED,aAAa;AACb,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./get-a-yes/index.js";
2
+ export * from "./types/index.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ /* exports */
2
+ export * from "./get-a-yes/index.js";
3
+ export * from "./types/index.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const API_ROOT = "https://yes.lavx.hu";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,wBAAwB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const API_ROOT = "https://yes.lavx.hu";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,qBAAqB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export type TAPIResponse = {
2
+ code: "api-ok" | "api-fail";
3
+ message: string;
4
+ payload: null | {
5
+ affirmation: string;
6
+ };
7
+ };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,IAAI,GAAG;QACd,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "yes-as-a-service-api-client",
3
+ "description": "A minimal JavaScript/TypeScript client for the Yes As A Service API — an API that always responds with a positive affirmation.",
4
+ "type": "module",
5
+ "version": "1.0.0",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "prepublishOnly": "npm run build"
20
+ },
21
+ "keywords": [
22
+ "yes-as-a-service",
23
+ "affirmation-api",
24
+ "public-api",
25
+ "tiny-api",
26
+ "npm-api-client",
27
+ "positivity",
28
+ "fun-api",
29
+ "fetch",
30
+ "typescript"
31
+ ],
32
+ "license": "MIT",
33
+ "devDependencies": {
34
+ "typescript": "^5.9.3"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/NPM-Workbench/yes-as-a-service-api-client"
39
+ },
40
+ "homepage": "https://github.com/NPM-Workbench/yes-as-a-service-api-client",
41
+ "bugs": {
42
+ "url": "https://github.com/NPM-Workbench/yes-as-a-service-api-client/issues"
43
+ }
44
+ }