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

@krvinay/express_api

v1.0.3

Published

Node API Application server

Downloads

16

Readme

express API

Node Js API Microservice/setup based on NodeJS, express, mysql2, sequelize. This package will generate a complete setup to start writing API for your application.

Feature:

Auto setup

Auto response formating

Mysql connection that support mysql1, mysql2 as well as sequelize with pool connection.

Custom message on database error. (Configurable)

Multilangual response message. (Configurable)

Response Logger hook (Configurable)

Thread Support (i.e Inbuilt function that allows function to run in a thread with a minor change.)

Thread Logging that will help in debug.

Prebuilt function library that will help during developing API.

File Logging support that allows you to generate log file insted of printing on console.

Installation

$ npm i @krvinay/express_api

Documentation :

Fresh installation

  1. Create a project folder.
  2. nevigate to project folder and run below command.
$ npm init
$ npm i @krvinay/express_api

Installation in existing product.

  1. Create/edit .env file to project's root directory. src="new source directory" default is src
  2. Run
$ npm i @krvinay/express_api
  1. Edit route/index.js to use your previous entry routes.

[!TIP] If you put src="/" in .env then source directory will not get created and package will treate root directory as source directory.

This Package will install all required package and generate a source folder named "src" or mention src in .env file with folowing files and directory.

  • src
    • activities /** Contains Thread related files and functions */
      • index.js /** Sample thread Function */
    • config /** Configuration Container */
      • appConfig.js /** initial Configuration file */
    • helpers /** Function liberary */
      • index.js
    • lang /** Language Container */
      • en.js
      • hi.js
    • logs /** Log files container */
    • models /** Models */
      • datasource /** Table scheama container for sequelize */
      • index.js /** Database connection Mysql/Sequelize
    • routes /** API routing container */
      • index.js /** Initial route file */
  • .env
  • .gitignore
  • .redme.md
  • server.js /** this will be your main file */

To start application, you have to run below command.

$ node server.js

[!NOTE] If you already having server.js file as your entry point then you need to edit file as mentioned below.

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

server.use(json({ limit: '50mb', extended: true }));
server.use(urlencoded({ limit: '50mb', extended: true }));
server.use(require("@krvinay/express_api"));

server.listen(process.env.PORT || default_port, () => {
    console.log("Server running on port " + (process.env.PORT || default_port));
});