Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
October 10, 2021 11:59 pm GMT

API Project Template, Written in Typescript

Building project with standardized structure could save much our time. We could focus on business process without considering too much on project structure. On the other hand, a good project structure should be clean, nice refactored, and easy to maintain.

Here's why:

  • Your time should be focused on creating something amazing. A project that solves a problem and helps others.
  • You shouldn't be doing the same tasks over and over like structuring project
  • You should implement dry principles to the rest of your life

This time, I created complete project template for API written in Typescript which is available in this github. Of course, no one template will serve all projects since your needs may be different.

Built With

This project structure is built using

Features

  • Everything is modular and unit testable
  • Typescript everything
  • Express API with dependency injected routes, controllers, repositories, middleware, and services
  • Centralized configuration loading and validation
  • API Documentation using swagger

Folder Structure

 .husky/                     # Pre-commit config for lint staged src/                        # All application source @types/                   # Type definition| api/                        controllers/            # Define all controllers helpers/                # Define all helpers lib/                     logger.ts             # Define logger middlewares/ authorization.ts      # Define authorization using JWT morgan.ts             # Define morgan    models/                 # Define all schema models repositories/           # Define all repositories routes/                  v1/                   # Define all v1 routes services/               # Define all services validations/            # Define all controller validations| config/ swagger/                # Define swagger configuration database.ts             # Define postgres database connection express.ts              # Define express configuration| constants/                # Define all constants                    server.ts                 # Create express config index.ts                  # ENTRYPOINT - Start server| test/                       # End-to-end test| Lots of random build-related files

See full project here. Let me know if you have any suggestions.


Original Link: https://dev.to/arifintahu/api-project-template-written-in-typescript-5dmk

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To