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

eliumm

v1.0.9

Published

eliumm fixes your code on the fly, making a crashless experience for users

Downloads

1

Readme

Eliumm 🔬🧪✅

Eliumm uses A.I. to find out the best solution on-the-fly to redirect users when there is an error or problem in your app making a crashless seamless experience for your users.

Installing the library

npm install eliumm

How to use Eliumm

IMPORTANT!!! Create your Routes

Create a routes.js to add your app routes inside your api folder. ./pages/api/routes.js For example:

// pages/api/routes.js

export default function handler(req, res) {
    const routes = [
        '/',
        '/about', // Add all your static routes here
        // Add more routes as needed
    ];
    res.status(200).json(routes);
}

Wrap your app with Eliumm

Wrap your Next.js app with the ErrorBoundary component:

// pages/_app.js
import React from 'react';
import App from 'next/app';
import { ErrorBoundary } from 'eliumm';

class MyApp extends App {
  render() {
    const { Component, pageProps } = this.props;
    return (
      <ErrorBoundary>
        .
        .
        ...your home page
        <Component {...pageProps} />
        .
        .
      </ErrorBoundary>
    );
  }
}

export default MyApp;

Use it in your pages.

This is an example of a Home page that makes an HTTP request and uses Eliumm to handle errors:

// pages/index.js

import React, { useState } from 'react';

import axios from 'axios';

import { RouteButtons } from 'eliumm';


const Home = () => {
  const [data, setData] = useState(null);
  const [error, setError] = useState(null);
  const [showRouteButtons, setShowRouteButtons] = useState(false);
  const [routes, setRoutes] = useState([]);

  const fetchRoutes = async () => {
    try {
      const response = await axios.get('/api/routes');
      setRoutes(response.data);
    } catch (err) {
      console.error('Error fetching routes:', err);
    }
  };

  const fetchData = async () => {
    try {
      const response = await axios.get('/api/data'); // This will cause an error as per the setup
      setData(response.data);
      setError(null); // Clear any previous errors
      setShowRouteButtons(false); // Hide RouteButtons if data is fetched successfully
    } catch (err) {
      if (err.response && err.response.status === 500) {
        await fetchRoutes();
        setShowRouteButtons(true);
      }
      setError(err);
      setData(null); // Clear any previous data
    }
  };

  return (
    <div className="flex flex-col items-center justify-center min-h-screen bg-gray-50">
      <h1 className="text-3xl font-bold mb-4">Welcome to Eliumm!</h1>
      <button
        onClick={fetchData}
        className="px-4 py-2 mb-4 bg-indigo-600 text-white rounded hover:bg-indigo-700 transition"
      >
        Test Eliumm
      </button>

      {data && <div className="text-lg text-gray-800">Data: {JSON.stringify(data)}</div>}

      {error && <p className="text-black mb-4">
        Instead of your App crashing, showing 404 pages or showing messages like this...      
          <p className="text-red-500 mb-4">
          An error occurred: {error.message}
          </p>
        Eliumm will engage your user to guide them to safe land with something like this...
        </p>}
      
      {showRouteButtons && <RouteButtons routes={routes} />} {/* Render RouteButtons if showRouteButtons is true */}
    </div>
  );
};

export default Home;

If used correctly your home page should render properly:

For Dev. Contributions

Building the code:

npm run build

or npm run build-ts

Publish to NPM:

npm publish

References