Skip to content

Trade API proof-of-concept written in TypeScript for deployment to AWS Lambda using Node.js v8.10.

Notifications You must be signed in to change notification settings

djeley/tapi-ts-poc

Repository files navigation

Overview

Trade API proof-of-concept written in TypeScript for deployment to AWS Lambda using Node.js v8.10.

Goals

  • Node.js for improved cold starts.
  • Easy to run and debug locally.
  • One SQL query per request using plain SQL to get flat RFR data.
  • Type safety.

Requirements for running

  • Node v8.10+
  • A local MTS environment to access the database.

Installation

$ npm install

Env Configuration

The application is configured to run locally using the Serverless Framework and Serverless Offline. The AWS Lambda environment variables for running locally can be found in the serverless.yml file

This is where you can configure the database connection details to connect to your local MTS database e.g:

...

environment:
    SERVICE_NAME: moth-api
    SERVICE_ENV: serverless
    LOG_LEVEL: debug
    KMS_ENABLED: false
    DATABASE_CONNECTION: '10.10.10.30'
    DATABASE_USERNAME: 'motdbuser'
    DATABASE_PASSWORD: 'password'
    DATABASE_NAME: 'mot2'
    DATABASE_KEEP_CONNECTION: true

...

Running locally

# Install the serverless cli globally
npm install -g serverless

# Start locally
$ npm run start-sls

Debugging locally

  • Install Visual Studio Code.
  • Open the root directory of the project in VS Code.
  • Main menu > View > Debug
  • Start debugging by pressing the green play button for the debug configuration named Debug TAPI.
  • Add breakpoints and use the API via curl/Postman etc. to cal the API.

Using the API

Documentation for Trade API is here: https://www.check-mot.service.gov.uk/mot-history-api

The URL root for running and debugging locally will be http://localhost:3000/

Example:

http://localhost:3000/trade/vehicles/mot-tests?registration=F50GGP

About

Trade API proof-of-concept written in TypeScript for deployment to AWS Lambda using Node.js v8.10.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published