Our environment:

  • Express Server
  • TypeScript
  • Joi validation
  • Swagger

Our task: DRY

For this task we should create Swagger documentation and TypeScript Interfaces just from Joi-Schemas!

Ready? Go!

Step 1: Installing Dependencies

npm init
npm install --save express http body-parser swagger-ui-express joi joi-to-swagger @babel/core @types/node typescript ts-node
npm install --save-dev gulp @babel/register @babel/plugin-proposal-class-properties @babel/preset-env @babel/preset-typescript json-schema-to-typescript

You may need to install ts-node globally if local version will not run:

npm install -g ts-node

The first group of tools allows us to make a swag, the second will create TypeScript interfaces for us.

Step 2: Creating the Express Server

First things first: we need to serve routers. For our example we will…

Leonid Ponomarev

Full-Stack Web Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store