Why creating simple Rest APIs are too complicated?

Taleh Ibrahimli
2 min readApr 21

--

What do we need to do to have better Rest APIs?

  1. Design our API
  2. Implement
    - Setup Database
    - Create Table
    - Implement our API and Repository codes, etc.
  3. Create Docs for it, Better Swagger docs
  4. Create Tests for it

It should not be that hard

A Solution?

It can be easy with my new open-source project named Data Handler

How?

What you need is just a yaml file and describe what API you need

schema.yml

type: resource
name: country
properties:
- name: name # name of the property
type: STRING # type of the property
length: 255
required: true
unique: true
- name: description # name of the property
type: STRING # type of the property
length: 255
---
type: resource
name: city
properties:
- name: name # name of the property
type: STRING # type of the property
length: 255
required: true
unique: true
- name: country
type: REFERENCE # reference/relation to country
reference:
referencedResource: country
cascade: true
dhctl apply -f schema.yml

How you can use it?

axios.post('http://localhost:9009/country', {
name: 'Country1',
description: 'Sample Country 1'
})

axios.post('http://localhost:9009/city', {
name: 'Country1',
description: 'Sample Country 1',
country: {
"name": "Country1"
}
})

What do we get?

Rest API and its implementation is automatically generated. Everything is ready to use.

It creates Swagger docs for you http://localhost:9009/docs/index.html

It creates a table for you. country and city tables are automatically created. And if you use easy installation or standalone installation, the Postgresql database will come together with Data Handler.

It also has GRPC API for you (on the same port 9009)

What else?

Please open the link to see all features of Data Handler https://github.com/tislib/data-handler/tree/master#features

Installation of Data Handler

curl -L https://raw.githubusercontent.com/tislib/data-handler/master/deploy/easy-install/run.sh | bash

see the link for detailed instructions

If you liked my idea, please star github repository https://github.com/tislib/data-handler

--

--