firmanJS / express-template-typescript

Nodejs, Express Typescript Boilerplate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

expressjs-typescript-template

Node.js CI Maintainability Test Coverage made-with-nodejs made-with-expressjs Ask Me Anything ! GitHub license GitHub release Github all releases GitHub issues GitHub pull-requests PRs Welcome

Default branch :

  • using postgres database and sequelize orm

More Feature Checkout the branch :

  • main using postgres and mongodb database as a default branch
  • feature/elastic using database elastic
  • feature/grpc using grpc
  • feature/graphql using graphql

This project has 3 Domain layer :

  • Repository Layer
  • Usecase Layer
  • Transport Layer

How To use

you must click the button use this template

  • using template - create name of your repository
  • rename link readme - change link repo default github/firmanJS/express-template-typescript to your repo
  • codeclimate - you must integrate repo to codeclimate don't forget set your repo is public for integrated and in github repo settings create secret key with name CC_TEST_REPORTER_ID and value from code climate REPORTER ID in https://codeclimate.com/

or clone this repository via https :

https://github.com/firmanJS/express-template-typescript.git

Core Stack

Feature

    • error handling
    • clean architecture folder
    • testing with jest
    • coverage use jest
    • with docker example
    • validiation, use express-valdator
    • pagination example
    • custom message api response
    • eslint airbnb base

Unit testing

How To run

copy environment variable

cp .env-sample .env

run manualy

  • via yarn or npm :
# install package
npm install or yarn install

#  running app
npm run dev or yarn dev

# running unit tetsing
npm run test or yarn test
  • via make :
# start aplication with docker
make docker-start 

# stop docker container
make docker-stop 

# remove docker container
make docker-down 

fill in the copied environment earlier

#NODEJS
APP_PORT=8000
NODE_ENV=development
CLUSTER_MODE=off
JWT_SECRET_KEY=

#DB
DB_USERNAME=
DB_PASSWORD=
DB_PORT=
DB_DATABASE=
DB_DRIVER='postgres'
DB_HOST=
DB_NAME=
MONGO_URL=

run with docker-compose

docker-compose up --build

or run with background process

docker-compose up --build -d

execution npm with container docker

# install package
docker-compose exec boillerplate-typescript npm install

# running unit testing
docker-compose exec boillerplate-typescript npm run test

Project Structure

.
├── .github/            * all workflows github actions
├── caprover/           * for deployment in caprover
├── coverage/           * all output coverage
├── build/              * all output build source code
├── docker/             * all dockerfile
├── src/                * all source code here
  └── config/           * folder for configuration
  |  └── *.ts           * all configuration like db, awes redis etc.
  └── db/               * folder for database
  |  └── *.ts           * all database files
  └── interface/        * folder for interface
  |  └── *.ts           * all interface files
  └── lang/             * folder for language message
  |  └── *.ts           * all language message files en, id etc.
  └── middlewares/      * folder for middlewares
  |  └── *.ts           * all middlewares files
  └── repository/       * folder for repository / query logic
  |  └── *.ts           * all utility files
  └── transport/        * folder for transport / api, grpc or graphql
  |  └── *.ts           * all transport files
  └── usecase/          * folder for usecase / busines logic
  |  └── *.ts           * all usecase files
  └── utils/            * folder for utility
  |  └── *.ts           * all utility files

Code Style Guides

  • Guideline:
    • Use camelCase for variable name, naming function
    • Use UpperCase for Constant Variable
    • Use PascalCase for class name, models, interface
    • Use snake_case for file name
    • Function name use Verb
    • Variable name use Noun

About

Nodejs, Express Typescript Boilerplate

License:MIT License


Languages

Language:TypeScript 98.4%Language:Dockerfile 1.0%Language:Makefile 0.5%