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

minimonolith

v0.27.0

Published

[![codecov](https://codecov.io/gh/DeepHackDev/minimonolith-api/branch/master/graph/badge.svg?token=ORFNKKJRSE)](https://codecov.io/gh/DeepHackDev/minimonolith-lib)

Readme

minimonolith

codecov

minimonolith is a lightweight library designed to help you build serverless APIs using AWS Lambda, with a focus on simplicity and ease of use. The library provides a straightforward structure to organize your API's modules, methods, validation, and models while handling common tasks like database connection and request validation.

In addition to its simplicity, minimonolith enables seamless inter-module communication within your API. This allows modules to call one another's functionality without directly importing them, fostering a modular design. For example, you can call the get method of the todo module from the todoList module using MODULES.todo.get({ id }). By registering modules within the API, you can easily call their methods from other modules, which not only promotes a clean architecture but also paves the way for future support of automated end-to-end testing.

Example Project

Here's an example project using minimonolith:

.
├── package.json
├── .gitignore
├── .env
├── server.js                  // For local development
├── index.js                   // Root of the code in a AWS Lambda
└── todo
    ├── index.js               // Module 'todo' exported methods
    ├── model.js               // Optional: Sequelize model for module
    └── get
        └─── handler.js        // Module 'todo' method 'get' handler

server.js

This file is used for local development. It runs a local server using minimonolith's getServer function:

// server.js

import { getServerFactory } from 'minimonolith';

import dotenv from 'dotenv';
dotenv.config({ path: './.env' })

const { lambdaHandler } = await import('./index.js');

const serverFactory = await getServerFactory();

const server = serverFactory(lambdaHandler);
server.listen(8080);

index.js

This file serves as the root of the code in a deployed AWS Lambda:

// index.js

import { getNewAPI } from 'minimonolith';

import todo from './todo/index.js';

const API = await getNewAPI({ ERROR_LEVEL: 0 });

await API.postModule(todo);
await API.postDatabaseModule({
  DB_DIALECT: process.env.DB_DIALECT,
  DB_HOST: process.env.DB_HOST,
  DB_PORT: process.env.DB_PORT ?
    parseInt(process.env.DB_PORT, 10) : undefined,
  DB_DB: process.env.DB_DB,
  DB_USER: process.env.DB_USER,
  DB_PASS: process.env.DB_PASS,
  DB_STORAGE: process.env.DB_STORAGE,
});

export const lambdaHandler = await API.getSyncedHandler();

ERROR_LEVEL can be:

  • 0: DEBUG logs
  • 1: INFO logs and below (default)
  • 2: ERROR logs and below

todo/index.js

Here, we declare the method handlers for the todo module:

// todo/index.js

import get from './get/handler.js';
import getOne from './getOne/handler.js';
import post from './post/handler.js';
import patch from './patch/handler.js';
import deleteTodo from './delete/handler.js';
import model from './model.js';

export default {
    name: 'todo',
    endpoints: {
        'get': get,
        'post': post,
        'patch:id': patch,·
        'delete:id': deleteTodo,
    },
    model,
};

Modules need to export name, endpoints and model attributes.

todo/model.js

In this file, we define a Sequelize model for the todo module:

// todo/model.js

export default moduleName => (orm, types) => {
  const schema = orm.define(moduleName, {
    name: {
      type: types.STRING,
      allowNull: false
    },
  });

  schema.associate = MODELS => {
    /*
    schema.belongsTo(MODELS.todoList, {
      foreignKey: 'todoListId',
      as: 'todoList'
    });
    */
  };

  return schema;
};

For now every module can have at most one model, which will have the same name as the module.

todo/get/index.js

This file contains the get:id method handler for the todo module. It retrieves a todo item by its ID:

// todo/get/index.js

export default async ({ body, MODELS }) =>  {
  const id = body.id;

  const todo = await MODELS.todo.findOne({ where: { id } });
  const todoJSON = todo.toJSON();

  return { body: todoJSON };
}

Endpoint receive MODELS, MODULES, body and claims, and can return body, cookies, headers and a custom status.

Database Authentication

To set up authentication for the database you need to pass necessary variables to postDatabaseModule as at index.js above. Assuming using same env variable names as at index.js above, the .env file should be like the following.

For MySQL:

DEV_ENV=TRUE
PROD_ENV=FALSE
DB_DIALECT=mysql
DB_HOST=<your_database_endpoint>
DB_PORT=<your_database_port>
DB_DB=<your_database_name>
DB_USER=<your_database_username>
DB_PASS=<your_database_password>

For SQLite in memory:

DB_DIALECT=sqlite
DB_DB=<your_database_name>
DB_STORAGE=:memory: # Need to also pass to API.postDatabaseModule()

Response Codes

Success

  • POST -> 201
  • DELETE -> 204
  • Everything else -> 200
  • Custom -> status value in handler.js return statement

Runtime Error

  • ANY -> 500