Generic API

slick -> technical-architecture -> http-data-layer -> api.md

COPY (LAYER 1)

  • layer 1 means APIs built on top of core
  • COPY = READ from one + insert in other (merge syntax of both APIs)

URL

POST http://localhost:3000/api/generic/copy

BODY

{
read:{
collectionName:'',
$match: {},
$project :{}
},
insert :{
collectionName:'' //above filtered & selected data will be inserted
}
}

GET IDs (LAYER 1)

  • READ API with filters but just return ids & initial (30) some data
  • useful for all summary pages (initial load)

URL

POST http://localhost:3000/api/generic/getIds?initialData=true

BODY

{
$match: {}, //where condition
}

RESPONSE BODY

{
data : {
totalIdCount : 100000,
ids:[1,2,3,500], //(ids to be used on scroll) after that recommend user to fine tune search
initialData :[ //some 30 or configured limit for the table
{
id:1,
key:'value'
},
{
id:30,
key:'value'
}
]
}
}

Bulk operations (layered) multi read , write different collections..etc APIs


(Layer 2 APIs)


Specs

  • https://jsonapi.org/
  • Swagger : auto API documentation
  • API authentication & authorization (role guards)
  • API versioning : "Content-Type: application/vnd.myname.v2+json" (for breaking changes)
  • Other security like on which tables, what operations can be performed by generic APIs
  • API testing + Perf & load testing
  • Encrypt/ Decrypt API data + query params (initial runtime pub-private key handshake)
  • Explore loopback / nest.js

Developer points

  • think more of actions -> DirectAPI configured in UI schema & refresh data in UI + UI alert msg , default page callback
  • create separate security.md