tiny-ok-message 0.1.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 +73 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/messages/get-ok-message.d.ts +9 -0
- package/dist/messages/get-ok-message.d.ts.map +1 -0
- package/dist/messages/get-ok-message.js +9 -0
- package/dist/messages/get-ok-message.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
# tiny-ok-message
|
|
9
|
+
An intentionally small, fetch-based package that is useful for quick API-client experiments.
|
|
10
|
+
|
|
11
|
+
### 📦 Installation
|
|
12
|
+
|
|
13
|
+
```console
|
|
14
|
+
npm install tiny-ok-message
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 📘 Features
|
|
18
|
+
|
|
19
|
+
1. One small exported helper: `getOkMessage`
|
|
20
|
+
2. Accepts a typed input object shaped as `{ message: string }`
|
|
21
|
+
3. Calls the DummyJSON HTTP 200 endpoint with a URL-encoded message
|
|
22
|
+
4. Returns a typed response shaped as `{ status: string; message: string }`
|
|
23
|
+
5. TypeScript ready with generated declaration files
|
|
24
|
+
6. ESM package output through `dist`
|
|
25
|
+
7. Unit tested with Jest and `ts-jest`
|
|
26
|
+
|
|
27
|
+
### 🔤 Example Usage
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
/* node modules */
|
|
31
|
+
import { getOkMessage } from 'tiny-ok-message';
|
|
32
|
+
|
|
33
|
+
/* example */
|
|
34
|
+
async function run() {
|
|
35
|
+
const response = await getOkMessage({ message: 'hello world' });
|
|
36
|
+
console.log(response);
|
|
37
|
+
}
|
|
38
|
+
await run();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Expected response shape:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
{ status: "200", message: "hello world" }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 📗 Test Coverage
|
|
48
|
+
|
|
49
|
+
```console
|
|
50
|
+
PASS src/messages/test/get-ok-message.test.ts
|
|
51
|
+
getOkMessage
|
|
52
|
+
✓ fetches the OK message from DummyJSON
|
|
53
|
+
✓ throws when the request fails
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```console
|
|
57
|
+
-------------------|---------|----------|---------|---------|-------------------
|
|
58
|
+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
59
|
+
-------------------|---------|----------|---------|---------|-------------------
|
|
60
|
+
All files | 100 | 100 | 100 | 100 |
|
|
61
|
+
get-ok-message.ts | 100 | 100 | 100 | 100 |
|
|
62
|
+
-------------------|---------|----------|---------|---------|-------------------
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 🔒 Security & Privacy
|
|
66
|
+
|
|
67
|
+
1. This package is open source and designed as a tiny API helper for the public DummyJSON HTTP endpoint. It does not collect, store, sell, rent, trade, monetize, or process personal data for its own purposes.
|
|
68
|
+
2. The package only makes HTTP requests as part of its documented behavior. Any data handled by the package is limited to the `message` value explicitly provided by the consuming application.
|
|
69
|
+
3. This package does not include analytics, tracking, telemetry, advertising, hidden background services, install scripts, or project-owned data collection systems.
|
|
70
|
+
|
|
71
|
+
### ❤️ Support
|
|
72
|
+
|
|
73
|
+
Like this project? Support it with a GitHub star. Cheers and happy coding.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type GetOkMessageProps = {
|
|
2
|
+
message: string;
|
|
3
|
+
};
|
|
4
|
+
export type OkMessageResponse = {
|
|
5
|
+
status: string;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function getOkMessage({ message }: GetOkMessageProps): Promise<OkMessageResponse>;
|
|
9
|
+
//# sourceMappingURL=get-ok-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-ok-message.d.ts","sourceRoot":"","sources":["../../src/messages/get-ok-message.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,YAAY,CAAC,EACjC,OAAO,EACR,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAShD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export async function getOkMessage({ message }) {
|
|
2
|
+
const encodedMessage = encodeURIComponent(message);
|
|
3
|
+
const response = await fetch(`https://dummyjson.com/http/200/${encodedMessage}`);
|
|
4
|
+
if (!response.ok) {
|
|
5
|
+
throw new Error(`Failed to fetch OK message. Status: ${response.status}`);
|
|
6
|
+
}
|
|
7
|
+
return response.json();
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=get-ok-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-ok-message.js","sourceRoot":"","sources":["../../src/messages/get-ok-message.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EACjC,OAAO,EACW;IAClB,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,kCAAkC,cAAc,EAAE,CAAC,CAAC;IAEjF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,EAAgC,CAAC;AACvD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tiny-ok-message",
|
|
3
|
+
"description": "A tiny TypeScript helper for fetching an OK response message from DummyJSON.",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"dummyjson",
|
|
6
|
+
"ok-message",
|
|
7
|
+
"typescript",
|
|
8
|
+
"api-client",
|
|
9
|
+
"fetch",
|
|
10
|
+
"http",
|
|
11
|
+
"utility"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"version": "0.1.0",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"clean": "rm -rf -v ./coverage ./dist",
|
|
30
|
+
"prepublishOnly": "npm run build",
|
|
31
|
+
"test": "jest",
|
|
32
|
+
"test:watch": "jest --watch",
|
|
33
|
+
"test:coverage": "jest --coverage --verbose"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/jest": "^29.5.14",
|
|
37
|
+
"jest": "^29.7.0",
|
|
38
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
39
|
+
"ts-jest": "^29.4.6",
|
|
40
|
+
"typescript": "^5.9.3"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/NPM-Workbench/tiny-ok-message.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/NPM-Workbench/tiny-ok-message/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/NPM-Workbench/tiny-ok-message#readme"
|
|
50
|
+
}
|