0.0.7 β€’ Published 5 months ago

roastify v0.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

Roastify

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.

Features

  • πŸ”₯ 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).

Installation

npm install roastify

Usage

Basic Express Setup

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"));

Custom Error Types

You can pass a failure type to get different styles of roast messages.

app.get("/auth-fail", async (req, res) => {
  await res.sendRoast("authentication");
});

app.get("/validation-fail", async (req, res) => {
  await res.sendRoast("validation");
});

How It Works

  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.

Example Responses

Failure TypeExample 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!"

Configuration

  • 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.

Error Handling

If OpenAI fails to generate a response, Roastify falls back to a default roast:

{
  "message": "Even the AI couldn't handle this request. That's how bad it is."
}

License

MIT License


😈 Turn your boring API errors into brutal roasts with Roastify! πŸ”₯

0.0.7

5 months ago

0.0.6

5 months ago

0.0.5

5 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago

1.0.0

3 years ago