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

@gpt-flow/node

v1.0.7

Published

Node.js middleware for logging errors to GPT-Flow

Downloads

2

Readme

@gpt-flow/node

A Node.js package to capture and send logs to the GPT-Flow API for processing and analysis.

Step 1: Installation

Install the package using npm:

npm install @gpt-flow/node

Step 2: Setting Up the Configuration

You have two options for setting up the configuration: using environment variables or configuring it programmatically.

Option 1: Environment Variables

If you prefer to use environment variables, create a .env file in your project’s root directory and add the following variables:

PROJECT_ID=your_project_id
PUBLIC_KEY=your_public_key
PROJECT_URL=https://gpt-flow-llm-api.onrender.com

Make sure to replace the placeholders with your actual project details.

Option 2: Programmatic Configuration

Alternatively, you can directly configure the package in your application code:

const gptFlow = require('@gpt-flow/node');

// Initialize with your project settings
gptFlow.init({
    projectId: 'your_project_id',   // Replace with your project ID
    publicKey: 'your_public_key',   // Replace with your public key
    projectUrl: 'https://gpt-flow-llm-api.onrender.com',  // Replace with GPT-Flow URL
});

Step 3: Using the Package in a Node.js Application

Once your configuration is set, you can use the GPT-Flow package to capture errors or logs in your Node.js application.

Here’s an example of how you could integrate it into an HTTP server:

const http = require('http');
const gptFlow = require('@gpt-flow/node');

// Initialize GPT-Flow with your project configuration
gptFlow.init({
    projectId: process.env.PROJECT_ID || 'your_project_id',   // Replace with your project ID
    publicKey: process.env.PUBLIC_KEY || 'your_public_key',   // Replace with your public key
    projectUrl: process.env.PROJECT_URL || 'https://gpt-flow-llm-api.onrender.com',  // Replace with GPT-Flow URL
});

// Create a basic HTTP server
const server = http.createServer((req, res) => {
    if (req.url === '/') {
        // Simulate an error for logging purposes
        throw new Error('Simulated error for logging');
    }

    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello, World!');
});

// Handle server errors and log them to GPT-Flow
server.on('error', (err) => {
    gptFlow.sendLogs({
        message: err.message,
        stack: err.stack,
        method: 'GET',
        url: '/',
    });
});

// Start the server
server.listen(3000, () => {
    console.log('Server is running on http://localhost:3000');
});

This setup will capture errors from your Node.js application and send the logs to the GPT-Flow API.