From 47c0742af5067fc307d10989d321f910bf0138ce Mon Sep 17 00:00:00 2001 From: oof1lab Date: Sun, 29 Oct 2017 22:21:52 +0000 Subject: [PATCH] fix: count url fix and updated readme for ROOT URL --- README.md | 5 +++++ lib/xsql.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a29815baf..fb9ead5144 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,10 @@ Powered by node packages : (express, mysql) => { xmysql } Run HTTP client [Postman](https://www.getpostman.com/) or [similar tools](https://chrome.google.com/webstore/search/http%20client?_category=apps) to invoke REST API calls +## ROOT +Root URL (localhost:3000/) returns all REST API urls for each table in schema. + + ## CRUD APIs Usual Suspects * GET       /api/:tableName * POST      /api/:tableName @@ -139,6 +143,7 @@ xmysql identifies foreign key relations automatically and provides GET api. eg: Customers is parent table and payments is child table. API invocation will result in all payments with customer 103. + ## When to use ? * You need REST APIs without much hassle for (ANY) MySql database * You are learning new frontend frameworks and need REST APIs for your MySql database. diff --git a/lib/xsql.js b/lib/xsql.js index 66ec6ac458..08720e3cfd 100644 --- a/lib/xsql.js +++ b/lib/xsql.js @@ -390,7 +390,7 @@ class Xsql { routes.push(this.prepareRoute('get', apiPrefix, tableName + '/:id')) routes.push(this.prepareRoute('put', apiPrefix, tableName + '/:id')) routes.push(this.prepareRoute('delete', apiPrefix, tableName + '/:id')) - routes.push(this.prepareRoute('get', apiPrefix, tableName + '/:id/count')) + routes.push(this.prepareRoute('get', apiPrefix, tableName + '/count')) routes.push(this.prepareRoute('get', apiPrefix, tableName + '/:id/exists')) for (var j = 0; j < table['foreignKeys'].length; ++j) {