therma-energy-api-gateway
TypeScript icon, indicating that this package has built-in type declarations

2024.7.12-0 • Public • Published

Therma Energy API Gateway

Overview

The Therma Energy API Gateway is a service that sits in the Energy cluster. This service is responsible for proxying requests made from the Therma-client web application.

Getting Started

To get started, we need to do the following:

  1. Install Node.js on your system
  2. Get the local development JWT Secret
  3. Install dependencies
  4. Start locally

Install Node.js on your system

You need Node.js v16 to for this project. Recommend using nvm to manage Node.js versions on your system.

Get the local development JWT Secret

This service is exposed to the "open web", so the only authentication mechanism we are using to authenticate and allow requests inside our energy cluster is by using a JWT token. This is passed in the authorization header. In order to configure this gateway locally, we need to set the MONITORING_JWT_SECRET as an environment variable. You need to get this JWT secret for decrypting JWT tokens from a teammate.

Install Dependencies

Once the previous steps are done, we need to set the correct NPM_TOKEN value for pulling from our private NPM registry. You also need to ask a teammate for this as well, then just export NPM_TOKEN=THE_CORRECT_TOKEN to load the expected NPM token for the given shell you are working in.

Finally, just npm install and we're almost done.

Start locally

To start locally, and assuming all of the previous steps are done, just npm run dev and the app will start on port 4001 by default.

Since this is a proxy service that works specifically with the therma-energy-apis, recommend having that service running locally on port 3000 - which is that service's default port that is uses.

Using the Swagger docs

Located at /docs, we have documentation of every route that the therma-energy-api-gateway proxies to. To use the Swagger docs effectively, you need to "login" with a JWT token. Here's one way to create a jwt for use with the Swagger docs, after installing the jwt-cli:

jwt encode --secret=MONITORING_JWT_SECRET '{ "user": { "uuid": "SOME_USER_UUID", "companyUUID": "MONITORING_COMPANY_UUID", "name
": "John Doe"}, "iat": 1516239022 }'

Readme

Keywords

none

Package Sidebar

Install

npm i therma-energy-api-gateway

Weekly Downloads

2

Version

2024.7.12-0

License

ISC

Unpacked Size

6.37 MB

Total Files

118

Last publish

Collaborators

  • mewe-devops