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 🙏

© 2026 – Pkg Stats / Ryan Hefner

fnexpose

v1.0.0

Published

A powerful Node.js package to effortlessly transform your JavaScript functions into accessible CLI commands and HTTP API endpoints.

Downloads

3

Readme

FnExpose

FnExpose is a powerful and flexible Node.js package designed to effortlessly transform your existing JavaScript functions into accessible CLI commands and HTTP API endpoints. This tool is perfect for developers looking to quickly expose utility functions, business logic, or any JavaScript module as a service, enabling rapid prototyping, microservice development, and seamless integration into existing workflows.

Features

  • Function to CLI: Automatically generates CLI commands for your JavaScript functions.
  • Function to Endpoint: Exposes your functions as HTTP API endpoints, ready for consumption.
  • File-based Scanning: Easily expose all functions from a single JavaScript file.
  • Folder-based Scanning: Turn an entire folder of JavaScript files into a collection of CLI commands and API endpoints.
  • Minimal Configuration: Get started quickly with sensible defaults.
  • Extensible: Designed to be integrated into new or existing Node.js projects.

Quick Start

1. Installation

To add function-to-cli-endpoint to your project, run:

npm install fnexpose
# or
yarn add function-to-cli-endpoint

2. Basic Usage (Function to Endpoint)

Let's say you have a file myFunctions.js:

// myFunctions.js
module.exports = {
    greet: (name) => `Hello, ${name}!`, 
    add: (a, b) => a + b
};

You can expose these functions as API endpoints with a few lines of code:

// server.js
const express = require('express');
const { fileToServer } = require('fnexpose');
const path = require('path');

const app = express();
const functionsFilePath = path.resolve(__dirname, './myFunctions.js');

// Create a router from your functions file
const apiRouter = fileToServer.makeRouter(fileToServer.loadFunctionsFromFile(functionsFilePath));

// Mount the router at a specific path
app.use('/api', apiRouter);

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`API server running on http://localhost:${PORT}/api`);
    console.log(`Try: POST http://localhost:${PORT}/api/greet with body { "args": ["World"] }`);
    console.log(`Try: POST http://localhost:${PORT}/api/add with body { "args": [5, 3] }`);
});

Run your server:

node server.js

3. Basic Usage (Function to CLI)

To use your functions as CLI commands, you can create a simple CLI entry point:

// cli.js
const { fileToCli } = require('fnexpose');
const path = require('path');

const functionsFilePath = path.resolve(__dirname, './myFunctions.js');
fileToCli.run(fileToCli.loadFunctionsFromFile(functionsFilePath));

Run your CLI:

node cli.js greet --name World
node cli.js add --a 5 --b 3

(Note: fileToCli is a conceptual example. The actual package structure might require importing from specific sub-modules like fnexpose/function-to-cli-and-endpoint/cli or fnexpose/file-to-function-to-cli-and-endpoint/cli depending on how you structure your CLI integration.)

Why use this tool?

  • Rapid Prototyping: Quickly turn ideas into testable API endpoints or CLI tools.
  • Microservices: Easily expose small, focused functions as independent services.
  • Automation: Automate tasks by calling your JavaScript functions directly from the command line or via HTTP requests.
  • Existing Codebase Integration: Integrate with existing utility functions without extensive refactoring.

About Leumas Tech

This tool is brought to you by Leumas Tech, a company dedicated to building innovative software solutions.

Contributing

We welcome contributions! Please see our CONTRIBUTING.md for details.

License

This project is licensed under the ISC License.