Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dah-kenangnon committed Feb 4, 2024
0 parents commit 8426a4b
Show file tree
Hide file tree
Showing 116 changed files with 13,884 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
90 changes: 90 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
##---------------------------------------------------------------##
# PROJECT INFORMATIONS
##---------------------------------------------------------------##
## 1. Project code name and description
PROJECT_NAME = typescript-express-mongoose-api-boilerplate
PROJECT_DISPLAY_NAME = Express Typescript MongoDB
PROJECT_DESCRIPTION = Fully featured backend API with Express, Typescript,MongoDB, JWT Authentication, Swagger, Docker, Unit Test, E2E Test, Code Coverage, Continuous Integration, Continuous Deployment, and more...
DOMAIN_NAME = api.example.com
FRONTEND_URL = http://localhost:3000

## 2. Express Js And Node Js Http Server
PORT = 9004
NODE_ENV = development
KEEP_ALIVE_TIMEOUT = 60000
PARAMETER_LIMIT = 100000
MAXIMUM_REQUEST_BODY_SIZE = '50mb'

## 3. Mongo Db Database
DB_URL = mongodb://localhost:27017/typescript-express-mongoose-api-boilerplate_dev

## 4. Log
LOG_FORMAT = dev
LOG_DIR = ../logs

## 5. Cors
ORIGIN = *
CREDENTIALS = false



##---------------------------------------------------------------##
# SECURITY AND AUTHENTICATION
##---------------------------------------------------------------##
## 1. Json Web Token (JWT)
JWT_SECRET = thisisasamplesecret
JWT_ACCESS_EXPIRATION_MINUTES = 30
JWT_REFRESH_EXPIRATION_DAYS = 30
JWT_RESET_PASSWORD_EXPIRATION_MINUTES = 10
JWT_VERIFY_EMAIL_EXPIRATION_MINUTES = 10

## 2. Others security secrets
SECRET_KEY = a unique secret to identify the application. Not confusible with JWT_SECRET



##---------------------------------------------------------------##
# DATA VALIDATIONS AND CONSTRAINTS
##---------------------------------------------------------------##
## 1. Password
MIN_PASSWORD_LENGTH = 8
MAX_PASSWORD_LENGTH = 255

## 2. Username, include firstname, lastname, familyname, etc.
MIN_USERNAME_LENGTH = 1
MAX_USERNAME_LENGTH = 50
MAX_USER_FULLNAME_LENGTH = 70

## 3. Email
MIN_EMAIL_LENGTH = 3
MAX_EMAIL_LENGTH = 255



##---------------------------------------------------------------##
# SMTP AND EMAIL CONFIGURATION OR SERVICES FOR SENDING EMAILS
##---------------------------------------------------------------##
## 1. Smtp
SMTP_HOST = mail.example.com
SMTP_PORT = 587
SMTP_USERNAME = no-reply@exampe.com
SMTP_PASSWORD = 'SecretPassword'

## 2. Admin email and Email Sender
EMAIL_FROM = no-reply@example.com
EMAIL_ADMIN = admin@mail.com



##---------------------------------------------------------------##
# UPLOADING FILES CONFIGURATIONS
##---------------------------------------------------------------##
UPLOAD_ALLOWED_FILE_TYPES = audio,video,image,document
UPLOAD_AUDIO_ALLOWED_FILE_TYPES = mp3,wav,ogg
UPLOAD_AUDIO_DISALLOWED_FILE_TYPES = nothing
UPLOAD_IMAGE_ALLOWED_FILE_TYPES = jpeg,jpg,png,gif
UPLOAD_IMAGE_DISALLOWED_FILE_TYPES = nothing
UPLOAD_VIDEO_ALLOWED_FILE_TYPES = mp4,avi,mkv,wmv
UPLOAD_VIDEO_DISALLOWED_FILE_TYPES = nothing
UPLOAD_DOCUMENT_ALLOWED_FILE_TYPES = pdf,doc,docx,xls,xlsx,ppt,pptx,txt
UPLOAD_DOCUMENT_DISALLOWED_FILE_TYPES = nothing
90 changes: 90 additions & 0 deletions .env.test.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
##---------------------------------------------------------------##
# PROJECT INFORMATIONS
##---------------------------------------------------------------##
## 1. Project code name and description
PROJECT_NAME = typescript-express-mongoose-api-boilerplate
PROJECT_DISPLAY_NAME = Express Typescript MongoDB
PROJECT_DESCRIPTION = Fully featured backend API with Express, Typescript,MongoDB, JWT Authentication, Swagger, Docker, Unit Test, E2E Test, Code Coverage, Continuous Integration, Continuous Deployment, and more...
DOMAIN_NAME = api.example.com
FRONTEND_URL = http://localhost:3000

## 2. Express Js And Node Js Http Server
PORT = 9004
NODE_ENV = test
KEEP_ALIVE_TIMEOUT = 60000
PARAMETER_LIMIT = 100000
MAXIMUM_REQUEST_BODY_SIZE = '50mb'

## 3. Mongo Db Database
DB_URL = mongodb://localhost:27017/typescript-express-mongoose-api-boilerplate_test

## 4. Log
LOG_FORMAT = dev
LOG_DIR = ../logs

## 5. Cors
ORIGIN = *
CREDENTIALS = false



##---------------------------------------------------------------##
# SECURITY AND AUTHENTICATION
##---------------------------------------------------------------##
## 1. Json Web Token (JWT)
JWT_SECRET = thisisasamplesecret
JWT_ACCESS_EXPIRATION_MINUTES = 30
JWT_REFRESH_EXPIRATION_DAYS = 30
JWT_RESET_PASSWORD_EXPIRATION_MINUTES = 10
JWT_VERIFY_EMAIL_EXPIRATION_MINUTES = 10

## 2. Others security secrets
SECRET_KEY = a unique secret to identify the application. Not confusible with JWT_SECRET



##---------------------------------------------------------------##
# DATA VALIDATIONS AND CONSTRAINTS
##---------------------------------------------------------------##
## 1. Password
MIN_PASSWORD_LENGTH = 8
MAX_PASSWORD_LENGTH = 255

## 2. Username, include firstname, lastname, familyname, etc.
MIN_USERNAME_LENGTH = 1
MAX_USERNAME_LENGTH = 50
MAX_USER_FULLNAME_LENGTH = 70

## 3. Email
MIN_EMAIL_LENGTH = 3
MAX_EMAIL_LENGTH = 255



##---------------------------------------------------------------##
# SMTP AND EMAIL CONFIGURATION OR SERVICES FOR SENDING EMAILS
##---------------------------------------------------------------##
## 1. Smtp
SMTP_HOST = mail.example.com
SMTP_PORT = 587
SMTP_USERNAME = no-reply@exampe.com
SMTP_PASSWORD = 'SecretPassword'

## 2. Admin email and Email Sender
EMAIL_FROM = no-reply@example.com
EMAIL_ADMIN = admin@mail.com



##---------------------------------------------------------------##
# UPLOADING FILES CONFIGURATIONS
##---------------------------------------------------------------##
UPLOAD_ALLOWED_FILE_TYPES = audio,video,image,document
UPLOAD_AUDIO_ALLOWED_FILE_TYPES = mp3,wav,ogg
UPLOAD_AUDIO_DISALLOWED_FILE_TYPES = nothing
UPLOAD_IMAGE_ALLOWED_FILE_TYPES = jpeg,jpg,png,gif
UPLOAD_IMAGE_DISALLOWED_FILE_TYPES = nothing
UPLOAD_VIDEO_ALLOWED_FILE_TYPES = mp4,avi,mkv,wmv
UPLOAD_VIDEO_DISALLOWED_FILE_TYPES = nothing
UPLOAD_DOCUMENT_ALLOWED_FILE_TYPES = pdf,doc,docx,xls,xlsx,ppt,pptx,txt
UPLOAD_DOCUMENT_DISALLOWED_FILE_TYPES = nothing
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/dist
/node_modules
/coverage
/logs
23 changes: 23 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"parser": "@typescript-eslint/parser",
"extends": ["prettier", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"@typescript-eslint/explicit-member-accessibility": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-parameter-properties": 0,
"@typescript-eslint/interface-name-prefix": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-var-requires": "off"
},
"settings": {
"import/resolver": {
"typescript": {}
}
}
}
28 changes: 28 additions & 0 deletions .github/workflows/test-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Node.js CI/CD

on:
push:
branches:
- main

jobs:
test-build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install Dependencies
run: yarn install

- name: Run Tests
run: yarn test

- name: Build
run: yarn run build
132 changes: 132 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
trash/*
trash
public/uploads/*
11 changes: 11 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

## Run lint-staged
npx lint-staged

## Run prettier
yarn prettier:check

## Run tests
yarn test
Loading

0 comments on commit 8426a4b

Please sign in to comment.