ERM Shadow API¶
ERM Shadow API¶
The goal of this project is to mimic Omnivoltaic OTP API so that distributors can send/get similar request/response to access and manipulate data in the ERM System.
About the Project¶
The project uses a Node.js application that provides REST API endpoints for distributor functionality which includes:
- Authentication
- Listing assigned items
- Code generation
- Code history listing
The Legacy API and Shadow API have several functions for the Distributor:
- Login
- List Assets
- Code Generation
- Access Code history of Items
Difference between Legacy API and Shadow API¶
Shadow API acts as a mediator or a proxy between the Legacy or ERM. When a distributor requests the Shadow API, the middleware checks the distributor's authorization token. Based on the token the middleware decides whether to redirect the distributor to the Legacy or the ERM. This mechanism allows the distributor to seamlessly interact with the appropriate platform based on their authorization status.
Legacy API — These APIs help access and manage data within these legacy systems. When a client makes a request via a Legacy API, the API directly processes this request based on predefined rules and permissions encoded with the system. For legacy there is no API acting as a mediator. Legacy API is responsible for authenticating the request.
Getting Started¶
Prerequisite¶
Installation¶
- Clone the repo:
git clone https://github.com/ovesorg/erm-shadow-api.git
- Install NPM packages:
npm install
- Create a
.envfile:
cp .env.example .env
- Enter your GraphQL URL in
.env:
const FEDERATED_ERM_API_ENDPOINT = 'Enter your GraphQL URL'
Project Structure¶
config— Configuration files for the application, including environment variables and database connectioncontrollers— Business logic including authentication, code generation, and item listingroutes— API endpoint routesutils— Utility functions: validation, formatting, GraphQL client, JWT, logger
Available Scripts¶
Yarn dev¶
Runs the app in development mode. Open http://localhost:3001 to view it in the browser. The page will reload if you make edits. You will also see any lint errors in the console.
Yarn build¶
Builds the application for production to the build folder. Correctly bundles Node.js in production mode and optimizes the build for the best performance. The build is minified and the filenames include the hashes.
After following these steps, your application is ready for deployment.