Skip to content

Sample backend miniapp to demonstrate TMS transaction service usage

License

Notifications You must be signed in to change notification settings

kobil-systems/tms-sample-backend

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Donate us Support us Follow us on Twitter

TMS API Service

A NestJS-based API service for handling TMS (Transaction Management System) operations.

Overview

This service provides endpoints for managing TMS transactions with features including:

  • Authentication using Keycloak
  • TMS transaction creation and management
  • Swagger API documentation
  • Structured logging and error handling
  • Docker support

Prerequisites

  • Node.js (v20 or later)
  • Yarn package manager
  • Docker (optional, for containerized deployment)

Environment Variables

Create a .env file in the root directory with the following variables:

PORT=3000
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=1h
KEYCLOAK_BASE_URL=your_keycloak_url
KEYCLOAK_TENANT=your_tenant
KEYCLOAK_REDIRECT_URI=your_redirect_uri
TMS_CLIENT_ID=your_client_id
TMS_CLIENT_SECRET=your_client_secret

Installation

$ yarn install

Running the Application

# Development mode
$ yarn start

# Watch mode
$ yarn start:dev

# Production mode
$ yarn start:prod

Docker Deployment

Build and run the application using Docker:

# Build the Docker image
$ docker build -t my-tms-api .

# Run the container
$ docker-compose up

API Documentation

Once the application is running, you can access the Swagger API documentation at:

http://localhost:3000/swagger

Project Structure

src/
├── auth/           # Authentication related files
├── common/         # Shared decorators, filters, and interceptors
├── config/         # Configuration modules and services
├── tms/            # TMS module implementation
└── main.ts         # Application entry point

Features

  • Authentication: JWT-based authentication using Keycloak
  • TMS Operations:
    • Start TMS transaction
    • Get TMS transaction status
  • Security:
    • JWT guard protection
    • Request validation
    • CORS support
  • Logging: Structured logging with request/response tracking
  • Error Handling: Global exception filter with standardized error responses

Security

The API uses several security measures:

  • JWT-based authentication
  • Request validation using class-validator
  • CORS configuration
  • HTTP exception handling
  • Non-root user in Docker

Contributing

  1. Create a new branch for your feature
  2. Make your changes
  3. Write or update tests as needed
  4. Submit a pull request

Resources

Check out a few resources that may come in handy when working with NestJS:

  • Visit the NestJS Documentation to learn more about the framework.
  • For questions and support, please visit our Discord channel.
  • To dive deeper and get more hands-on experience, check out our official video courses.
  • Deploy your application to AWS with the help of NestJS Mau in just a few clicks.
  • Visualize your application graph and interact with the NestJS application in real-time using NestJS Devtools.
  • Need help with your project (part-time to full-time)? Check out our official enterprise support.
  • To stay in the loop and get updates, follow us on X and LinkedIn.
  • Looking for a job, or have a job to offer? Check out our official Jobs board.

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

License

Nest is MIT licensed.

About

Sample backend miniapp to demonstrate TMS transaction service usage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published