1.2.8 • Published 1 year ago

basic-node-ts-config v1.2.8

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Basic Configuration to Nodejs With Express and Typescript

This module serving a basic structure and configuration of nodejs API with express and typescript

Summary

Getting Started

Prerequisites

Usage

  • Use this command in terminal and get initial structure, modules and development ambient to start your nodejs application
npx create-node-basic [YOUR_PROJECT_NAME]

Folder Structure

  • Your project get this structure
project
│   .env.example
│   .gitignore
│   .dockerignore
│   CHANGELOG.md
│   README.md
│   docker-compose.yml
│   docker-compose.test.yml
│   docker-compose.dev.yml
│   Dockerfile
│   Dockerfile.test
│   Dockerfile.dev
│   babel.config.js
│   package-lock.json
│   package.json
│   tsconfig.json
│   tsconfig.spec.json
│   pm2.json
│   nginx
|   │   default.conf
|   │   Dockerfile
│   docs
|   │   docs.yaml
│   __tests__
│   └───unit
|   │   |  example.test.ts
|   │   |  redis.test.ts
│   └───integration
|   │   |  example.test.ts
└───src
|   |   app.ts
|   |   server.ts
│   └───config
│   |   │   redisClient.ts
│   |   │   index.ts
│   └───controllers
│   |   │   ExampleController.ts
│   |   │   index.ts
│   └───services
│   |   │   Example.services.ts
│   |   │   index.ts
│   └───routes
│   |   │   example.routes.ts
│   |   │   index.ts
|   └───utils
│       │   createToken.ts
│       │   handleError.ts
│       │   index.ts

Basic Scripts In Project

  • Your package.json have initial commands to build, run, test and create server to development

build your project:

npm run build

build your project and immediately run your app builded:

npm start

run project in production mode with pm2:

npm run start:pm2

run project in development build:

npm run dev

run all of tests in project:

npm run test

Test your application run correctlly to send HTTP GET to localhost:8000

Docker Scripts In Project

run your project in docker to production (docker-compose -f ./docker-compose.yml up):

npm run docker:prod

run your project in docker to development (docker-compose -f ./docker-compose.dev.yml up):

npm run docker:dev

run your project in docker to test (docker-compose -f ./docker-compose.test.yml up):

npm run docker:test

run your project in docker to production (docker-compose -f ./docker-compose.yml up --build):

npm run docker:prod:build

run your project in docker to development (docker-compose -f ./docker-compose.dev.yml up --build):

npm run docker:dev:build

run your project in docker to test (docker-compose -f ./docker-compose.test.yml up --build):

npm run docker:test:build

Future Features

  • Explain how design patters used in your initial configuration of project
  • Explain how to use your initial configuration of project
  • Add options to get initial Dockerfile and docker-compose.yml to run your project in docker
  • Use Redis as cache
  • Use pm2 to run your project in production mode
  • Use Nginx as reverse proxy
  • Use Swagger to document your API

👔 Linkedin

1.2.8

1 year ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.1.4

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.0

2 years ago