roastify
Version:
A Node.js library that generates sarcastic and roast-style responses for API failures using OpenAI.
75 lines (58 loc) β’ 2.57 kB
Markdown
Roastify is a Node.js middleware that returns sarcastic and roast-style responses for API failures using OpenAI. Instead of boring error messages like "Invalid username or password," Roastify delivers witty burns to keep your API responses entertaining.
- π₯ **Generates dynamic roast responses** using OpenAI.
- π **Customizable failure types** (authentication, validation, general errors, etc.).
- π **Middleware for Express.js** to make integration seamless.
- π **Caller provides their own OpenAI API key** (no key stored in the library).
```sh
npm install roastify
```
```javascript
const express = require("express");
const { roastMiddleware } = require("roastify");
const app = express();
app.use(roastMiddleware("your-openai-api-key"));
app.get("/fail", async (req, res) => {
await res.sendRoast();
});
app.listen(3000, () => console.log("Server running on port 3000"));
```
You can pass a **failure type** to get different styles of roast messages.
```javascript
app.get("/auth-fail", async (req, res) => {
await res.sendRoast("authentication");
});
app.get("/validation-fail", async (req, res) => {
await res.sendRoast("validation");
});
```
1. **Roastify intercepts failed requests** and sends a sarcastic response instead of a standard error message.
2. **Responses are dynamically generated** using OpenAIβs API to keep them fresh and unpredictable.
3. **The caller must provide an OpenAI API key** when initializing the middleware.
| Failure Type | Example Roast Response |
|---------------|----------------------|
| Authentication | "Oh wow, another victim of their own terrible memory. Try again, genius." |
| Validation | "You had ONE job: enter valid data. And you still messed it up." |
| General | "Well, that didn't go as planned. But hey, at least you're consistent at failing!" |
- **API Key:** You must pass an OpenAI API key when initializing the middleware.
- **Max Tokens:** Limited to 30 for concise responses.
- **Temperature:** Set to 0.8 for creative but controlled roasts.
If OpenAI fails to generate a response, Roastify falls back to a default roast:
```json
{
"message": "Even the AI couldn't handle this request. That's how bad it is."
}
```
MIT License
---
π **Turn your boring API errors into brutal roasts with Roastify!** π₯