apimov
Superheroic NodeJS web API Generator
Last updated a month ago by matheusrabelo .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install apimov 
SYNC missed versions from official npm registry.

Apimov

npm version

Ultra lightweight library to generate internal APIs.

About

From now on, you can create an API just with SQL queries and a single json file.

Usage

Create your own apimov.json with your API spec.

Run the following command:

$ npm install apimov -g
$ apimov

This command will find and mount an API via apimov.json

Creating an apimov.json

The apimov.json has the following structure:

{
    "config": {
        "host": "localhost",
        "user": "admin",
        "database": "invoices-db",
        "port": 5432,
        ...
    },
    "routes": [
        {
            "path": "/invoices/:invoiceId",
            "method": "GET",
            "query": "queries/get-invoice-by-id.sql"
        },
        {
            "path": "/invoices",
            "method": "GET",
            "query": "queries/get-invoices.sql"
        }
        ...
    ]
}

Example

This repo has an usage example, with just the queries/ folder and the apimov.json, you can start an API by running the Apimov CLI. Fork/clone this repo and try to do this on the example/ folder.

Relevant infos

  1. All queries are executed on PostgreSQL. If you are getting started with it, you can try:
https://www.postgresql.org/download/
https://www.pgadmin.org/

or just

https://www.elephantsql.com/
  1. The driver used is pg. Configurations and queries contracts are the same avaiable on it.

  2. Apimov unrolls and concats params, query strings and body (in this order) before querying. Don't forget that your queries should consider it. The apimov source code is:

...
const body = Object.values(reqBody);
const queryParams =
        [].concat(params, queryString, body);

Contribute

Contributions, stars and feedbacks are always welcome

Authors

Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 105
Dependencies (4)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |