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

addis

v1.0.3

Published

Express SQL api creator, with data validation, token generation, data hashing. It saves time without sacrifing any functionality.

Downloads

5

Readme

Addis

Addis is a super easy and fast node express library that let's you create a professional API with SQL databases.

Installation

$ npm install addis

Features

  • Super easy server configuration, by default basic server configurations are included.
  • Quick and easy connection to database.
  • Router configuration is simple and flexible
  • Different accessories are present to ensure wide range of functionalities, like: - Making a route protected is just adding an object property - Token generation with key specified - Validating request bodies with JOI validator is made easy - Hashing any data that is going to be passed to the database

Development

Here we'll show you everything the package does.

Server configuration

Under route setting an object containing the route name as a key and express router as a value, this libarary handles the route creation too, which will be shown below.

const addis = require("addis");
//take a look at route configuration section below to understand how the routes files are created
const route1 = require("./route1");
const route2 = require("./route2");

addis.connection(
  "localhost",
  "userName",
  "password",
  "databaseName",
  (err, con) => {
    addis.server({
      port: 3000,
      token_key: "honkytonky", //if you need token generation in your app
      connection: con, // callback result of abel.connection
      app_level_middleware: [], //add app level middlewares in the array
      route_setting: { "/route1": route1, "/route2": route2 }, // add routes
    });
  }
);

Route configuration

For example let's there be a table called user, with entries userName, phone, email and Password. A general configuration looks like this:

const addis = require("addis");
const express = require("express");
const router = express();
var routingEngine = addis.routing(router);

var user = null;

//All routes here
user = routingEngine.routing({
  router_type: "get",
  router_path: "/",
  selectors: {
    table_name: "user",
  },
  accesseries: {
    protected: false,
  },
});

module.exports = user;

CRUD Operations

READ

Here are most common read operations in great detail

Get data

routingEngine.routing({
    router_type: 'get',
    router_path: '/',
    selectors: {
        selector: ['*'] // by default it is *, but you can add array of columns to be fetched like [userName, phone]. Then it will only fetch these
        table_name: 'user' // add table name
    },
    accesseries: {
        protected: false //determine if the route is protected or not
    }
})

Get data by id

routingEngine.routing({
  router_type: "get",
  router_path: "/:id_column", //The name of param passed must be as same as the column name on the database.
  selectors: {
    table_name: "user",
  },
});

Get data by "query expression"

// the equivalent statement would be SELECT * FROM table_name WHERE phone='phone' AND password='password'
routingEngine.routing({
  router_type: "get",
  router_path: "/expression/:phone/:password", // the param name should be same as the corresponding table column name
  selectors: {
    table_name: "student",
    expression: ["AND"], // array of query statement binders between the params
  },
});

CREATE

This is the create operation on a database

routingEngine.routing({
  router_type: "post",
  router_path: "/",
  selectors: {
    table_name: "user",
  },
  accesseries: {
    validator: validator, // add Joi validator object here
    protected: false,
    encryption: {
      // here is the hashing section
      round: 1,
      encrypt_column: "userName", // specify which key in request.body to hash
    },
  },
});

Append

Same as CREATE operation but pass id as a params in the route path, but as mentioned above the name of the param must be as same as the id column name.

...
    route_path: '/:user_id'
...

Delete

routingEngine.routing({
  router_type: "delete",
  router_path: "/:user_id", //again the name of param should be identical to the id column name.
  selectors: {
    table_name: "student",
  },
});

Validation

This library uses joi object for validation.

accesseries: {
    ...
    validator: Joi_validation_object
    ...
}

Token generation

To generate token, the first part of the path must be "login".

...
router_path: '/login/:userName/:password',
...

Hashing

Addis uses bcryptjs for hashing.

accesseries: {
        ...
        encryption: {
            round: 1,        // rounds of hashing
            encrypt_column: 'password'  // Column to be hashed
        }
        ...
    }

Protected Route

If protected is true, addis checks token set in header based on the token key set on server configuration.

accesseries: {
        ...
        protected: true,
        ...
    }

Examples

$ git clone git://github.com/expressjs/express.git --depth 1
$ cd express
$ npm install

Contact

[email protected]

Coming Soon ...

Soon we'll be adding image and video support.

License

MIT