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

apibuildingframeworkexpress

v1.0.42

Published

Fast api building over Express.js

Readme

apibuildingframeworkexpress

Fast API building framework over Express.js with MongoDB integration. Quickly create CRUD endpoints with built-in pagination, filtering, file uploads, and schema validation.

Installation

npm install apibuildingframeworkexpress

Requirements

Quick Start

const express = require('express');
const MongoWrapper = require('mongoclienteasywrapper')(mongoUrl);
const apiBuilder = require('apibuildingframeworkexpress')(MongoWrapper);

const app = express();
app.use(express.json());

// Basic CRUD routes
app.get('/users', apiBuilder.list());
app.get('/users/:_id', apiBuilder.listOne());
app.post('/users', apiBuilder.create());
app.patch('/users/:_id', apiBuilder.updatePatch());
app.delete('/users/:_id', apiBuilder.remove());

app.listen(3000);

API Reference

CRUD Operations

| Method | Description | Parameters | |--------|-------------|------------| | list(params) | List all documents with pagination | Database, Collection, Middleware | | listOne(params) | Get single document by _id | Database, Collection, Middleware | | create(params) | Create new document | Database, Collection, PathBaseFile, URL, AsyncFunctionAfter, Middleware | | updatePatch(params) | Update document by _id | Database, Collection, PathBaseFile, URL, AsyncFunctionAfter, Middleware | | updatePatchMany(params) | Update multiple documents | Database, Collection, Middleware | | remove(params) | Soft delete document | Database, Collection, Middleware |

Filtered Queries

| Method | Description | |--------|-------------| | listFilter(params) | Advanced filtering with aggregation | | listFilter2(params) | Extended filtering with comparison operators |

File Operations

| Method | Description | |--------|-------------| | docUpload(params) | Upload single file/icon | | docRemove(params) | Remove uploaded file | | fileUpload(params) | Upload multiple files | | uploadAdd(params) | Add document to array | | uploadPatch(params) | Update document in array | | uploadRemove(params) | Remove document from array |

Utilities

| Method | Description | |--------|-------------| | distinct(params) | Get distinct values | | removePropertyId(params) | Remove property from document | | pullIdFromArrayManagementDB(params) | Pull ID from array |

Query Parameters

Filtering Operators

Use these suffixes in query parameters for advanced filtering:

GET /users?name_partial=john        # Partial match (regex)
GET /users?status_string=active     # Exact string match
GET /users?active_boolean=true      # Boolean match
GET /users?role_id=507f1f77bcf86cd799439011  # ObjectId match
GET /users?role_neid=507f1f77bcf86cd799439011  # Not equal ObjectId
GET /users?status_nestring=deleted  # Not equal string
GET /users?age_igtei=18             # Integer >= 18
GET /users?age_iltei=65             # Integer < 65
GET /users?createdAt_dgted=2024-01-01  # Date >= 2024-01-01

Pagination

GET /users?page=0&limit=10

Sorting

GET /users?sortMongoAsc=name        # Ascending
GET /users?sortMongoDec=createdAt   # Descending

Projection

GET /users?projectMongo=name&projectMongo=email

Lookup (Populate)

GET /users?lookup=roles

Middleware / Schema Validation

const { Middlewares } = require('apibuildingframeworkexpress')(MongoWrapper);

// With express-validator
app.post('/users', 
  Middlewares.validateSchemaExpress(userSchema),
  apiBuilder.create()
);

// With Yup
app.post('/users',
  Middlewares.validateSchemaYup(yupSchema),
  apiBuilder.create()
);

Advanced Usage

Custom Database/Collection

app.get('/custom', apiBuilder.list({
  Database: 'myDatabase',
  Collection: 'myCollection'
}));

Using as Middleware

app.get('/users', 
  apiBuilder.list({ Middleware: true }),
  (req, res) => {
    // Access response in req.MidResponse
    const data = req.MidResponse;
    res.json({ ...data, customField: 'value' });
  }
);

Assignments (Relations)

// In request body, use _Assign to create relations
POST /users
{
  "name": "John",
  "_Assign": [
    { "roles": ["roleId1", "roleId2"] }
  ]
}

// Use _UnAssign to remove relations (in PATCH)
PATCH /users/:id
{
  "_UnAssign": [
    { "roles": ["roleId1"] }
  ]
}

Async Function After

app.post('/users', apiBuilder.create({
  AsyncFunctionAfter: async (req, res, dbResponse) => {
    // Execute after document creation
    await sendWelcomeEmail(dbResponse.insertedId);
  }
}));

Response Format

All endpoints return consistent response format:

// Success
{
  "status": "ok",
  "message": "completed",
  "data": { /* document(s) */ },
  "rows": 10  // for list operations
}

// Error
{
  "status": "error",
  "message": "db error",
  "data": { /* error details */ }
}

Authors

  • Alberto Martinez
  • Gustavo Luna
  • Taylor Gonzalez
  • Jose Tello

License

MIT

Links