• Stars
    star
    131
  • Rank 274,475 (Top 6 %)
  • Language
    TypeScript
  • Created almost 3 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Complete project template for building RESTful API with Typescript.

Contributors Forks Stargazers Issues


Project Structure API

Complete project template for building RESTful API with Typescript

Report Bug ยท Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing

About The Project

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

Of course, no one template will serve all projects since your needs may be different. So I'll be adding more in the near future. You may also suggest changes by forking this repo and creating a pull request or opening an issue. Thanks to all the people have contributed to expanding this project template!

(back to top)

Built With

This project structure is built using

(back to top)

Features

  • Everything is modular and unit testable
  • Typescript everything
  • Project API structures with routes, controllers, models, repositories, middlewares, and services
  • Centralized configuration input validator

Folder Structure

โ”œโ”€โ”€ .husky/                     # Pre-commit config for lint staged
โ”œโ”€โ”€ docs/                       # Swagger API docs
โ”œโ”€โ”€ src/                        # All application source
โ”œโ”€โ”€โ”€โ”€ @types/                   # Type definition for modules
|
โ”œโ”€โ”€โ”€โ”€ api/
โ”œโ”€โ”€โ”€โ”€โ”€โ”€ controllers/            # Define all controllers
โ”œโ”€โ”€โ”€โ”€โ”€โ”€ middlewares/            # Define all middlewares
โ”œโ”€โ”€โ”€โ”€โ”€โ”€ models/                 # Define all sequelize models
โ”œโ”€โ”€โ”€โ”€โ”€โ”€ repositories/           # Define all repositories
โ”œโ”€โ”€โ”€โ”€โ”€โ”€ routes/
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ v1/                   # Define all v1 routes
โ”œโ”€โ”€โ”€โ”€โ”€โ”€ services/               # Define all services
โ”œโ”€โ”€โ”€โ”€โ”€โ”€ types/                  # Define all input types
|
โ”œโ”€โ”€โ”€โ”€ config/
โ”œโ”€โ”€โ”€โ”€โ”€โ”€ appConfig.ts            # Define app configuration
|
โ”œโ”€โ”€โ”€โ”€ constants/                # Define all constants
โ”œโ”€โ”€โ”€โ”€ database/                 # Define database connection and sync tables
โ”œโ”€โ”€โ”€โ”€ utils/                    # Define reusable libs
โ”œโ”€โ”€โ”€โ”€ server.ts                 # Create express config
โ”œโ”€โ”€โ”€โ”€ index.ts                  # ENTRYPOINT - Start server
|
โ””โ”€โ”€ ...

Getting Started

To start project, just clone this repo or Use this template

Prerequisites

Before installation, make sure you have the following prerequisites

  • NPM
    npm install npm@latest -g
  • Postgresql server

Installation

  1. Clone the repo or simply select use this template
    git clone https://github.com/arifintahu/project-structure-api.git
  2. Install NPM packages
    npm ci
  3. Create .env file in main directory
  4. Copy and customize envs from .env.example
  5. Test and build the project
    npm run build
  6. Sync database tables
    npm run sync-db
  7. Run the server
    npm run start
  8. Access swagger docs from localhost:3001/docs/v1

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/feature-name)
  3. Commit your Changes (git commit -m 'Add some feature-name')
  4. Push to the Branch (git push origin feature/feature-name)
  5. Open a Pull Request

(back to top)

More Repositories

1

dexplorer

Disposable Cosmos-based Blockchain Explorer
TypeScript
15
star
2

arifintahu.github.io

Portofolio Web
Vue
4
star
3

moleculer-express

Template service using moleculer and express
JavaScript
3
star
4

restful-typescript

Express REST API using typescript
TypeScript
3
star
5

go-api-questdb

Implementation Golang API using QuestDB
Go
2
star
6

intercollection

Uptick Interchain NFT Collections
TypeScript
2
star
7

challenge-todo-app

Challenge https://blog.gethired.id/devcode-challenge-1st/
TypeScript
2
star
8

movie-recommender-app

An implementation of user based collaborative filtering on movies dataset.
HTML
2
star
9

stock-financial-visual

Visual stock financial history
Vue
1
star
10

url-shortener

URL Shortener with Python
Python
1
star
11

stock-financial-history

Download indonesia stock market financial history through POEMS
HTML
1
star
12

template-service

Template service master
TypeScript
1
star
13

stargaze-nft-transfer

Stargaze NFT Transfer
TypeScript
1
star
14

graphql-vs-rest

TypeScript
1
star
15

content-aggregator

Content aggregator
HTML
1
star
16

ssr-nextjs

Template for Server Side Rendering Next.js; server using express.js, sequelize, postgresql; UI using nextjs, antdesign, less
JavaScript
1
star
17

cnn-handwritten-flask

Jupyter Notebook
1
star
18

blockchain-simulation

Blockchain simulation with node.js
JavaScript
1
star
19

data-science-projects

Portofolio of Data Science Projects
Jupyter Notebook
1
star
20

digit-recognition-app

Handwritten digit recognition dekstop application
Python
1
star
21

go-rest-api

Template Golang REST API
Go
1
star
22

moscha-ui

TypeScript
1
star
23

moscha-backend

TypeScript
1
star
24

convolution-visual-app

Visualize Convolution Process
Python
1
star
25

masterchef-bot

TypeScript
1
star