The purpose of creating this middleware app or API gateway is to streamline data from multiple API services. In the chem-handler-api-v2, the services included are:
- Self-hosted service (main backend)
- PubChem API
With this setup, the frontend application will be able to connect
to a single source to retrieve the required data.
Currently, the self-hosted service is not connected to a real backend. Instead, it is connected to a mock API that returns a response object of a Compound, structured as follows:
class Compound{ pk: number; trivial_name: string; cas_number: string; inci_name: string; smiles: string; comedogenicity_class: number; }
GET https://chem-handler-api-v2.vercel.app/compounds
GET https://chem-handler-api-v2.vercel.app/compounds/:id
Example: GET https://chem-handler-api-v2.vercel.app/compounds/150
This service primarily returns responses obtained from the request body to the PubChem database. It utilizes an interceptor to transform the original records into a more useful format.
### Get by CID full records POST https://chem-handler-api-v2.vercel.app/pubchem/cid Content-Type: application/json{ "id": 12, "operationType": "fullRecords" }
POST https://chem-handler-api-v2.vercel.app/pubchem/cid Content-Type: application/json
{ "id": 1, "operationType": "property", "propertyName": "MolecularWeight" }
POST https://chem-handler-api-v2.vercel.app/pubchem/cid Content-Type: application/json
{ "id": 1, "operationType": "property", "propertyName": "MolecularWeight,MolecularFormula,HBondDonorCount" }
POST https://chem-handler-api-v2.vercel.app/pubchem/cid Content-Type: application/json
{ "id": 1, "operationType": "synonyms" }
GET https://chem-handler-api-v2.vercel.app/pubchem/cid/3/image
### Get by name full records POST https://chem-handler-api-v2.vercel.app/pubchem/name Content-Type: application/json{ "name": "glucose", "operationType": "fullRecords" }
POST https://chem-handler-api-v2.vercel.app/pubchem/name Content-Type: application/json
{ "name": "glucose", "operationType": "property", "propertyName": "MolecularWeight" }
POST https://chem-handler-api-v2.vercel.app/pubchem/name Content-Type: application/json
{ "name": "glucose", "operationType": "property", "propertyName": "MolecularWeight,MolecularFormula,HBondDonorCount" }
POST https://chem-handler-api-v2.vercel.app/pubchem/name Content-Type: application/json
{ "name": "glucose", "operationType": "synonyms" }
GET https://chem-handler-api-v2.vercel.app/pubchem/name/glucose/image
### Get by name full records POST https://chem-handler-api-v2.vercel.app/pubchem/smiles Content-Type: application/json{ "smiles": "CCCC", "operationType": "fullRecords" }
POST https://chem-handler-api-v2.vercel.app/pubchem/smiles Content-Type: application/json
{ "smiles": "CCCC", "operationType": "property", "propertyName": "MolecularWeight" }
POST https://chem-handler-api-v2.vercel.app/pubchem/smiles Content-Type: application/json
{ "smiles": "CCCC", "operationType": "property", "propertyName": "MolecularWeight,MolecularFormula,HBondDonorCount" }
POST https://chem-handler-api-v2.vercel.app/pubchem/smiles Content-Type: application/json
{ "smiles": "CCCC", "operationType": "synonyms" }
GET https://chem-handler-api-v2.vercel.app/pubchem/smiles/CCCC/image
You can locate the folder at: src/pubchem/interceptors/pubchem-response.interceptor.ts
This file is primarily responsible for transforming the original records obtained from PubChem.