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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@krvinay/express_api

v1.0.5

Published

Node API Application server

Readme

Express API Microservice

A comprehensive Node.js API microservice framework built on Express, MySQL2, and Sequelize. This package provides a complete, production-ready setup to rapidly develop robust APIs for your applications.

✨ Features

  • 🚀 Automated Setup - Get started instantly with zero-configuration defaults
  • 📊 Auto Response Formatting - Consistent API response structure out of the box
  • 🗄️ Flexible Database Support - Compatible with MySQL1, MySQL2, and Sequelize with connection pooling
  • 🛠️ Configurable Error Messages - Customize database error messages to match your needs
  • 🌍 Multilingual Support - Built-in internationalization for response messages
  • 📝 Response Logger Hook - Configurable logging for all API responses
  • ⚡ Thread Support - Execute functions asynchronously with minimal code changes
  • 🔍 Thread Logging - Enhanced debugging capabilities for threaded operations
  • 📚 Helper Function Library - Pre-built utilities to accelerate API development
  • 📄 File Logging - Generate log files instead of console output
  • 🔐 Response Header Management - Built-in CORS and header configuration (no additional packages needed)

📦 Installation

Configure your application using environment variables to specify the source directory and project type.

Environment Variables

| Variable | Description | Default | Options | |-----------|------------------------------------------|---------|----------------| | SRC | Application source directory | src | Any valid path |

Method 1: Using .env File (Recommended)

  1. Create a .env file in your project root:
NODE_ENV=dev
SRC=src
  1. Install the package:
npm install @krvinay/express_api

Method 2: Linux / macOS

SRC=src npm install @krvinay/express_api

Method 3: Windows (CMD or PowerShell)

# Install cross-env (if not already installed)
npm install --save-dev cross-env

npx cross-env SRC=src npm install @krvinay/express_api

🚀 Getting Started

Fresh Installation

  1. Create a new project directory:
mkdir my-api-project
cd my-api-project
  1. Initialize npm:
npm init -y
  1. Install the package using one of the methods above.

  2. Start your application:

node server.js

Integrating with Existing Projects

If you're installing this package in an existing project, you'll need to:

  1. Edit routes/index.js to integrate with your existing route structure
  2. Merge any conflicting configuration files

[!TIP] Set SRC="/" to skip source directory creation. The package will treat your root directory as the source directory.

📁 Project Structure

After installation, the following structure will be generated:

project-root/
├── src/                          # Source directory (configurable)
│   ├── activities/               # Thread-related files and functions
│   │   └── index.js              # Sample thread function
│   ├── config/                   # Configuration files
│   │   └── appConfig.js          # Main configuration file
│   ├── helpers/                  # Utility function library
│   │   └── index.js              # Helper functions
│   ├── lang/                     # Internationalization files
│   │   ├── en.js                 # English translations
│   │   └── hi.js                 # Hindi translations
│   ├── logs/                     # Log files directory
│   ├── models/                   # Database models
│   │   ├── datasource/           # Sequelize table schemas
│   │   └── index.js              # Database connection (MySQL/Sequelize)
│   └── routes/                   # API route definitions
│       └── index.js              # Main route file
├── .env                          # Environment variables
├── .gitignore                    # Git ignore rules
├── README.md                     # Project documentation
└── server.js                     # Application entry point

⚙️ Configuration

For New Projects

The package automatically creates a server.js file. Simply run:

node server.js

For Existing Projects

[!NOTE] If you already have a server.js file, update it with the following code:

require("dotenv").config();
const server = require('express')();
const { json, urlencoded } = require('express');
const default_port = 8080;

// Middleware configuration
server.use(json({ limit: '50mb', extended: true }));
server.use(urlencoded({ limit: '50mb', extended: true }));

// Initialize Express API package
server.use(require("@krvinay/express_api"));

// Start server
server.listen(process.env.PORT || default_port, () => {
    console.log(`Server running on port ${process.env.PORT || default_port}`);
});

🔧 Environment Configuration

Create a .env file in your project root with the following variables:

# Node Application environment
NODE_ENV=dev

# Server Configuration
PORT=8080

# Source Directory (default: src)
SRC=src

# Database Configuration (add your database credentials)
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=
DB_NAME=your_database

📖 Usage

Once installed and configured, you can start building your API by:

  1. Adding Routes - Define your endpoints in src/routes/index.js
  2. Creating Models - Add database models in src/models/
  3. Writing Helpers - Create utility functions in src/helpers/
  4. Configuring Languages - Add translations in src/lang/
  5. Implementing Threads - Add background tasks in src/activities/

👤 Author

Vinay Kumar

🆘 Support

For issues and questions, please visit the GitHub repository or open an issue.