npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ai-backend-companion

v0.0.3

Published

library to act as a backend, generating code as needed. contact me at https://iammatan.com for any question

Downloads

2

Readme

AI Backend Companion

AI Backend Companion is an HTTP server designed to streamline frontend fast prototyping and mocking. It allows you to send HTTP requests and automatically generates and executes handlers for those requests, making it easier to develop and test your frontend applications without the need for a fully functional backend server. With AI Backend Companion, you can quickly simulate backend behavior and responses for your frontend development.

Installation

To get started, follow these simple installation steps:

  1. Install the package via npm:

    npm i ai-backend-companion
  2. Initialize AI Backend Companion in your code:

    import {AiBackendCompanion} from 'ai-backend-companion';
    
    // Initialize AI Backend Companion with your API key
    const companion = new AIBackendCompanion({ apiKey: 'your-key' });
    
    // Start the companion server
    companion.start();
  3. Alternatively, you can run AI Backend Companion using the following command (replace 'your-key' with your actual API key):

    OPENAI_API_KEY=your-key npx ai-backend-companion

Usage

Once AI Backend Companion is up and running, you can start using it to generate handlers for your HTTP requests. Here's how you can utilize this tool:

Generating Handlers

To generate handlers for your HTTP requests, simply add the doc_should query parameter to your request. For example:

  • POST Request:
    • URL: http://localhost:8055/todo?doc_should=save a todo to db.json, creating it if it doesn't exist
    • Request Body: {"todo": "walk the dog"}

By adding the doc_should query parameter, AI Backend Companion will automatically generate a handler for this request based on the provided description.

Overwriting Generated Files

If you're not satisfied with the generated result or need to make changes, you can use the doc_overwrite query parameter to overwrite the generated files. This allows you to fine-tune the handlers as needed.

Example

Here's an example of how you can use AI Backend Companion to generate a handler for a POST request:

const fetch = require('node-fetch');

// Define the request URL with the 'doc_should' query parameter
const url = 'http://localhost:8055/todo?doc_should=save a todo to db.json, creating it if it doesn\'t exist';

// Define the request options, including the HTTP method and request body
const options = {
  method: 'POST',
  body: JSON.stringify({ todo: 'walk the dog' }),
  headers: {
    'Content-Type': 'application/json',
  },
};

// Send the request using the fetch library
fetch(url, options)
  .then(response => response.json())
  .then(data => {
    // Handle the response data as needed
    console.log('Response:', data);
  })
  .catch(error => {
    // Handle any errors that occur during the request
    console.error('Error:', error);
  });

With AI Backend Companion, you can quickly and easily prototype your frontend applications without the need for a fully developed backend server. This tool simplifies the process of generating request handlers, enabling efficient frontend development and testing.

For more information and options, you may contact me

All URL Parameters:

  • doc_should - What should this request do
  • doc_overwrite - should it always generate a backend file or should it use existing files
  • doc_context - What is the overall context of what you're making

License

This project is licensed under the MIT License.