mmuruev / api-node-vanila-rest

Easy Node REST API without any framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App with simplest REST API.

For db setup

db: {
    host: 'localhost', // server name or IP address;
    port: 5432, // PG server port
    database: 'api_platform',
    user: 'api_platform',
    password: 'api_platform'
    }

Node setup.

    $npm install

DB Schema script: ./config/init_migration.sql

    CREATE TABLE client
    (
    	id serial primary key,
    	phone varchar(35) not null,
    	email varchar(255) not null,
    	data json not null
    );

REST INVOCATIONS

    GET  '/api/clients'  search by GET params like "?phone=442071234567"
    POST '/api/client' payload  like
    {
      "phone": "+442071234566",    // required
      "email": "test@email2.com",  // required
      "some": "value",
      "add": "test"
    }
PUT '/api/client/:id' the sayme payload except ID nothing is manadatory;
DELETE '/api/client/:id' only ID required success 204 status;

About

Easy Node REST API without any framework


Languages

Language:JavaScript 93.9%Language:HTML 6.1%