roast-api 1.0.1

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.
@@ -0,0 +1,37 @@
1
+ name: Deploy to GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ pages: write
11
+ id-token: write
12
+
13
+ concurrency:
14
+ group: "pages"
15
+ cancel-in-progress: false
16
+
17
+ jobs:
18
+ deploy:
19
+ environment:
20
+ name: github-pages
21
+ url: ${{ steps.deployment.outputs.page_url }}
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - name: Checkout
25
+ uses: actions/checkout@v4
26
+
27
+ - name: Setup Pages
28
+ uses: actions/configure-pages@v5
29
+
30
+ - name: Upload artifact
31
+ uses: actions/upload-pages-artifact@v3
32
+ with:
33
+ path: '.'
34
+
35
+ - name: Deploy to GitHub Pages
36
+ id: deployment
37
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,53 @@
1
+ name: Publish Package and Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*.*.*'
7
+
8
+ jobs:
9
+ publish-npm:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: write
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: actions/setup-node@v4
17
+ with:
18
+ node-version: '20.x'
19
+ registry-url: 'https://registry.npmjs.org'
20
+
21
+ - run: npm publish --access public
22
+ env:
23
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
24
+
25
+ - name: Create Release
26
+ uses: softprops/action-gh-release@v1
27
+ with:
28
+ files: |
29
+ api/client.js
30
+ postman/roast-as-a-service.postman_collection.json
31
+
32
+ publish-github-packages:
33
+ runs-on: ubuntu-latest
34
+ permissions:
35
+ contents: read
36
+ packages: write
37
+ steps:
38
+ - uses: actions/checkout@v4
39
+
40
+ - uses: actions/setup-node@v4
41
+ with:
42
+ node-version: '20.x'
43
+ registry-url: 'https://npm.pkg.github.com'
44
+ scope: '@maizied'
45
+
46
+ - name: Update package name for GitHub Packages
47
+ run: |
48
+ sed -i 's/"name": "roast-api"/"name": "@maizied\/roast-api"/' package.json
49
+ cat package.json
50
+
51
+ - run: npm publish
52
+ env:
53
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package/README.md ADDED
@@ -0,0 +1,168 @@
1
+ # 🄵 Roast as a Service (RaaS)
2
+
3
+ <p align="center">
4
+ <img src="https://maijied.github.io/roast-as-a-service/assets/logo.png" width="128" alt="RaaS Logo" />
5
+ </p>
6
+ <p align="center">
7
+ <img src="https://hits.sh/maijied.github.io/roast-as-a-service.svg?view=today-total&style=flat-square&label=visitors&color=ec4899&labelColor=020617" alt="Visitor Count" />
8
+ </p>
9
+
10
+ Random developer roasts, delivered via a blazing‑fast static API on GitHub Pages. Plug it into your apps, bots, terminals, or CI logs when ā€œnice error messagesā€ just aren’t enough.
11
+
12
+ > **Part of the [Lorapok Ecosystem](https://github.com/Maijied/lorapok)** — Building the future of AI-driven developer tools. šŸ›
13
+
14
+ ---
15
+
16
+ ## šŸš€ What is RaaS?
17
+
18
+ Roast as a Service is a GitHub‑hosted, CDN‑backed JSON API that returns developer‑themed roasts in English and Bangla.
19
+ It’s completely static (no servers), but feels dynamic thanks to a smart client SDK that shards, caches, and randomly selects roasts on the fly.
20
+
21
+ Use it when you want your:
22
+
23
+ - CLI tools to roast the user on failure.
24
+ - CI pipeline to roast you when tests fail.
25
+ - Discord/Slack bots to respond with spicy dev insults.
26
+ - Portfolio or landing page to show random roasts on each visit.
27
+
28
+ ---
29
+
30
+ ## 🌐 Live Service
31
+
32
+ - **Website:** https://maijied.github.io/roast-as-a-service/
33
+ - **API Base Path:** https://maijied.github.io/roast-as-a-service/api/
34
+
35
+ ---
36
+
37
+ ## ⚔ Quick Start
38
+
39
+ ### 1. Install via npm
40
+ ```bash
41
+ npm install roast-api
42
+ ```
43
+
44
+ ```javascript
45
+ const RaaS = require('roast-api');
46
+
47
+ RaaS.getRandomRoast({ lang: 'en' })
48
+ .then(r => console.log(r.text));
49
+ ```
50
+
51
+ ### 2. Script Include (Browser)
52
+ Load the client SDK directly in your browser:
53
+
54
+ ```html
55
+ <script src="https://maijied.github.io/roast-as-a-service/api/client.js"></script>
56
+
57
+ <script>
58
+ // Fetch a random Bangla roast with intensity 2
59
+ RaaS.getRandomRoast({ lang: 'bn', intensity: 2 })
60
+ .then(r => console.log(r.text));
61
+ </script>
62
+ ```
63
+
64
+ ### 3. Direct Fetch
65
+ Or just fetch the JSON files directly:
66
+
67
+ ```javascript
68
+ fetch('https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json')
69
+ .then(res => res.json())
70
+ .then(data => {
71
+ const list = data.roasts;
72
+ const pick = list[Math.floor(Math.random() * list.length)];
73
+ console.log(pick.text);
74
+ });
75
+ ```
76
+
77
+ ---
78
+
79
+ ## šŸ›  How it works
80
+
81
+ RaaS exposes sharded JSON datasets over GitHub Pages, then a tiny client SDK picks, filters, and caches roasts in the browser, giving you an API‑like experience with pure static hosting.
82
+
83
+ - **Static API**: Roasts are stored in language‑specific shards (`en`, `bn`) and served as JSON over GitHub Pages’ global CDN for low TTFB.
84
+ - **Smart client**: The bundled client fetches a small shard, caches it, and returns random roasts with optional intensity and length filters.
85
+ - **Zero ops**: No servers, no cold starts, no scaling issues. Push to main, let Pages deploy and cache everything at the edge.
86
+
87
+ ---
88
+
89
+ ## šŸ“¦ API Overview
90
+
91
+ This is a **static** API: data comes from versioned JSON files served over CDN, and a lightweight JS client handles randomness, filtering and caching in the browser.
92
+
93
+ ### Endpoints (static JSON)
94
+
95
+ - **Manifest:**
96
+ `GET https://maijied.github.io/roast-as-a-service/api/manifest.json`
97
+
98
+ - **English Shard #1:**
99
+ `GET https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json`
100
+
101
+ - **Bangla Shard #1:**
102
+ `GET https://maijied.github.io/roast-as-a-service/api/bn/roasts-bn-1.json`
103
+
104
+ ### Example Response Structure
105
+ Each shard looks like:
106
+
107
+ ```json
108
+ {
109
+ "language": "en",
110
+ "shard": 1,
111
+ "total_shards": 5,
112
+ "count": 300,
113
+ "tags": ["dev", "general"],
114
+ "roasts": [
115
+ {
116
+ "id": "en-1-1",
117
+ "text": "Your codebase looks like it was written during a live outage.",
118
+ "intensity": 2,
119
+ "length": 61
120
+ }
121
+ ]
122
+ }
123
+ ```
124
+
125
+ ### Usage Example (curl + jq)
126
+ ```bash
127
+ curl -s https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json \
128
+ | jq '.roasts[0].text'
129
+ ```
130
+
131
+ ---
132
+
133
+ ## 🧬 Why this architecture is ā€œstate of the artā€
134
+
135
+ Roast as a Service is intentionally built as a **static API** on top of GitHub Pages and a CDN, instead of a traditional backend. For this use case (serving pre‑made content), this gives you the same ā€œAPI experienceā€ with less cost, less complexity, and better global latency.
136
+
137
+ Key points:
138
+
139
+ - **Static JSON over CDN**
140
+ All responses are just versioned JSON files served by GitHub Pages’ global edge network, which is highly cache‑friendly and extremely fast for read‑heavy traffic.
141
+
142
+ - **Zero backend, zero cold starts**
143
+ There is no application server to boot, scale, or warm up. Every request hits static content that can be served from edge cache with minimal TTFB.
144
+
145
+ - **Sharded data layout**
146
+ Roasts are split into language‑specific shards (e.g. `en/roasts-en-1.json`) so each response stays small and cacheable even if the total dataset becomes large.
147
+
148
+ - **Client‑side selection and filtering**
149
+ A tiny SDK handles randomness, intensity filters, and length limits in the client, so the ā€œAPIā€ stays read‑only and ultra fast instead of computing on every request.
150
+
151
+ - **Edge‑friendly cache behavior**
152
+ Because the content is static and not personalized, CDN nodes can cache responses aggressively without worrying about user‑specific data. That’s exactly what CDNs are optimized for.
153
+
154
+ - **Version‑controlled API**
155
+ All JSON lives in Git; you can roll back, branch, and review changes like any other codebase while GitHub Pages redeploys and re‑caches automatically.
156
+
157
+ This combination (static JSON + sharding + client‑side logic + CDN caching) is effectively the ā€œfast pathā€ that many dynamic APIs end up approximating with layers of caching—here it’s the default.
158
+
159
+ ---
160
+
161
+ ## šŸ› More from Lorapok
162
+
163
+ RaaS is a proud member of the **Lorapok** family. Check out our other tools:
164
+
165
+ - **[Lorapok CLI](https://github.com/Maijied/lorapok):** The intelligent AI agent framework for developers.
166
+ - **[Lorapok Media Player](https://github.com/Maijied/Lorapok_Media_Player):** A modern, feature-rich media player built for power users.
167
+
168
+ ---