Skip to content

dltxio/proxy.idem.com.au

Repository files navigation

Idem Proxy Service

Web service for proxying requests to exchange services.

Docs

Architecture

Technology

  • NodeJs -
    Recommend installing Node Version Manager (NVM) to allow using multiple versions of Node on your machine. Instructions for Windows
    We use Long Term Support (LTS) versions of Node so that our apps are stable
    Starting point of a Nodejs project is ./package.json

  • Typescript - The programming language of choice, compiles down to JavaScript. Refer to ./tsconfig.json for the compilation options

  • Yarn - We use Yarn (over npm) as the package manager. Windows installation instructions here, requires npm installed

  • NestJS - This app uses Nest as a (NodeJS) framework.

  • Es-lint and prettier - Code linting and formatting standards

  • Jest - Testing framework - TODO remove

  • Mocha and Chai - Testing and Assertion frameworks for unit testing

  • Supertest - Integration/End-to-End (e2e) testing framework for HTTP

  • Swagger - API documentation

  • TypeORM - TypeORM documentation

Structure

Quick overview of the folder structure:

github/ - github CI actions
dist/ - the build folder
node_nodules/ - downloaded 3rd part deps
src/
    accounts/ - example of an entity that has controller, module, service and references a DTO
    services/ - external connectors e.g. DTOs and APIs
    utils/ - common reusable components e.g. Nest validators and interceptors
    app.module.ts - entry point to the Nest app that defines the dependency injections
    interfaces.ts - global file of TS interfaces
    main.ts - nest setup including swagger config
    mocks.ts - mocked external classes used in tests
test/ - contains end to end tests

Modules controllers and services

This is a 3 tier API project
Controllers are the API endpoints for HTTP requests. They manage input validation and output encoding, agnostic to the business logic. All business logic is handed off to the associated service
Modules perform the dependency injection of all dependencies required

Sample Endpoints

This project contains a single entity accounts for demo purposes.
All related files are stored under the src/accounts folder. Simply create copies of this folder for other entities you wish to create

// Get all (vault) accounts

GET accounts

// Get a (vault) account

GET accounts/:accountId

Commands

More details in the scripts section of ./package.json

Installation

Download and install all dependencies into the ./node_modules folder

yarn

Build the project and output into the ./dist folder

yarn build

Linting and formatting

Make sure all line and tab formatting is correct

yarn format

Review some basic coding styles based on the rules set

yarn lint

Running the app

An .env file needs to be placed at the root for the app to work. Copy/swap the sibling .env.development file. Use:

cp .env.development .env

To run the (NestJS) API:

docker-compose down && docker-compose up

yarn start:dev

Then browse to localhost:3000/swagger

Testing the app

To run the unit tests:

yarn test

To run the end-to-end tests:

yarn test:e2e

Deployment

Options available on the dev-ops repo

UAT

Replace the values for each key in .env with the token name plus "_TOKEN". Then make sure there is a Github secret for each of those keys. For example:

ENV_VAR_1_KEY: ENV_VAR_1_KEY_TOKEN

Test PGP Key

The test PGP key is submitted to MIT, OpenPGP and Ubuntu. Live will be from support@idem.com.au.

-----BEGIN PGP PUBLIC KEY BLOCK-----

mQGNBGTW/a0BDAC9jrNp/y5GibYrC2pzo/CIY+ERwR1Ezoyo2JweqYs6vjACECf9
iWF9vWaDw8plUnSCu2TxtgKMjkbfukfenFUllSymXT+VK3tUzm4lP3Kha2f89Blc
j9Rmc2oLzS0uvVJpGNMit9z9wL19A/wOit7pi1a8bbeNsHbFeHImlvUHSdLKOnkh
U+KLhNBYafdsWHWNVA/zOO+nQsRDVAJ6/TI0YKSwM+VXlkHwOlnOcZvTW9S2H3u3
FaLjtsbMUl3NcIRkVfr1TKWmaR3sQuRXsCqYx313F0/GOgWzqpUQdKmfTq0ftsUO
nQPQp9NClkHiHIkQJp/QdCFc5XPVGIdDx0+1M9vYVijCqCCcXbWwj/ilLj8RqRje
xM4cQ8/4kZHkcJ6PoF3bOtCplyxFgR9wcl66ow4a+l15k6z+wcTK0Jiy5KutyB3Z
2dZbIFIy3NkGwdKGt7AWUaQlMr+/g4ZsEAvj3zE+9QQkzsLjTGM25Z6F7G9HT5Z2
Kb7jivD8Zo7kdSUAEQEAAbQaSWRlbSBJRCA8dGVzdEBpZGVtLmNvbS5hdT6JAc4E
EwEKADgWIQSDB4uNUUGexyN09IDH8TpxljZ1GAUCZNb9rQIbAwULCQgHAgYVCgkI
CwIEFgIDAQIeAQIXgAAKCRDH8TpxljZ1GB4wC/9E3EGYq1xC89YWsc5+56BuZieA
G+BsXyT+FGF5GqtMSBNoiriwJigjGdnyZ1vc/sF9swZzc/Z5FYOxzyCjO4Pq0Ud5
HrD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OljKQ2Yfgb8q3Bf8SCsdOqpl5TpfiOs
Sq1r6z7B2i11jMRw0QZexTf1SNGmJcgqTfo9qGVrwG0ZZENnqrZqoD//kH9SGfti
BaGoLhaTyt2RbcS5VuJpc7zS0WKV4RQ673ZttSY44xDsVJ3rbPCpuJuhr9bJpb4E
mymOj6/IiKen/cwOR+BxfWI1uF7c7l4xgbLvZjBFtHeSSMEK72eJYHYYjxHl/UQ+
KWbPrU+G3gSps/bMUg6GgcqX/hO7H2geG58sZKQEYPlJtH9wLRzfYf2y4maa5Gcv
QATnZwX8Fw4Q5gCsoYMaFKLfSi8LEYVIq5J/As7rtElaDBw8mkwX7etxTwegjIFd
mjTk8m891K8Uo+rW2I9JBqkPymxVuzhIihqzDhgw48fbW5TlIEoqYTmy/v8OsFLR
N7NBSaE2+96fwcaeaJ7uM2u/0GlIpMrcok5kWI5r/kq6CMAONU9q5HecEj5pdZCr
PzH2+OC2
=MWk4
-----END PGP PUBLIC KEY BLOCK-----

Xero

  1. Go to [this link](https://login.xero.com/identity/connect/authorize?response_type=code&client_id=873C683D0CA5428F8DB12E1D0CC24185&redirect_uri=http://localhost/&scope=openid profile email accounting.transactions accounting.contacts offline_access&state=DLTXisTheBest)

  2. Get the code from the redirect URL (After “code=”)

  3. Within 5 minutes of receiving code, go to the endpoint Request Xero Token endpoint found in the DLTX https://hoppscotch.io/ collection, adding the code you got in the previous step into the "code" value in the body (otherwise it will expire). Click send. The response will be the Xero token set. The generated token set is valid for 30 minutes.

    • Example token set:
    {
        "id_token": "<TOKEN>",
        "access_token": "<TOKEN>",
        "expires_in": 1800,
        "token_type": "Bearer",
        "refresh_token": "<TOKEN>",
        "scope": "openid profile email accounting.transactions accounting.contacts offline_access"
    }
    
  4. Then find the Send Invoices endpoint in the DLTx https://hoppscotch.io/ collection and add the Xero token set along with the Xero client ID.

NOTE: The access_token will be valid for 30 mins.

Demo Company Reset Instructions

Every 28 days the Demo Company resets, so when this happens run the following to get back up and running.

  1. Get a new tenant id for the demo company by making a GET request to https://api.xero.com/connections
  2. Update the .env file with the new tenant id
  3. Push the changes to github, and wait for deployment
  4. Verify Idem is working as normal

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages