Coder Social home page Coder Social logo

typescript-tdd-template's Introduction

πŸ¦‹ TypeScript TDD Template

⚑ Start your Node.js project with Typescript using Test Driven Development (TDD) practices.

πŸ“‹ GitHub Actions Workflow:

🏠 Build

This GitHub Actions workflow automatically builds and tests the application when code changes are pushed to the master branch or a pull request targeting the master branch is opened or synchronized.

πŸ“₯ Installation

To get started with this template, you first need to clone the repository:

git clone https://github.com/AraManjon/typescript-tdd-template.git

Then, install the project dependencies:

npm install

🏁 How To Start

To start the server in development mode, run the following script:

npm run dev

Then, open http://localhost:8000 to access the server.

πŸš€ Production

To run the server in production mode, first build the TypeScript code into JavaScript by running:

npm run build

This will generate the dist directory with the compiled JavaScript files.

Then, start the server by running:

npm start

This will start the server and make it available at http://localhost:8000.

πŸ—οΈ Scripts

This project comes with several predefined scripts in the package.json file:

test: Runs tests using Jest.

lint: Runs ESLint to check code quality.

lint:fix: Runs ESLint to fix code style issues.

dev: Starts the development server with ts-node-dev and allows debugging

build: Removes the ./dist folder and compiles the TypeScript code into JavaScript in the ./dist folder.

start: Starts the server in production using the compiled files in the dist/ folder.

πŸ“ Dependencies

  • cors: middleware for handling Cross-Origin Resource Sharing (CORS)

  • dotenv: loads environment variables from a .env file

  • express: web framework for Node.js

  • express-promise-router: promise-based router for Express

  • helmet: middleware for adding security headers

  • mongodb: driver for MongoDB

  • mysql2: MySQL client for Node.js

πŸ› οΈ Dev Dependencies

  • @types/cors: TypeScript definitions for cors

  • @types/express: TypeScript definitions for express

  • @types/jest: TypeScript definitions for jest

  • @types/mysql: TypeScript definitions for mysql

  • eslint: linter for TypeScript

  • eslint-config-codely: ESLint configuration used by CodelyTV

  • mysql: MySQL driver for Node.js

  • rimraf: cross-platform tool for removing files and directories

  • ts-jest: TypeScript preprocessor for Jest

  • ts-node-dev: TypeScript execution and development environment for Node.js

  • tsc-watch: TypeScript compiler with file watching

πŸ—‚οΈ Folder structure

In this folder structure, the code is organized according to the principles of Hexagonal Architecture.

src/
β”œβ”€β”€ backend
β”‚   β”œβ”€β”€ middlewares
β”‚   β”œβ”€β”€ App.ts
β”‚   β”œβ”€β”€ server.start.ts
β”‚   └── Server.ts
β”œβ”€β”€ shared
β”‚   β”œβ”€β”€ utils
β”‚   β”œβ”€β”€ domain
β”‚   └── infrastructure
β”‚       β”œβ”€β”€ config
β”‚       └── persistence
└── user
    β”œβ”€β”€ application
    β”‚   β”œβ”€β”€ services
    β”‚   └── use-cases
    β”œβ”€β”€ domain
    β”‚   β”œβ”€β”€ entities
    β”‚   └── repositories
    └── infrastructure
        β”œβ”€β”€ controllers
        β”œβ”€β”€ repositories
        β”œβ”€β”€ routes
        β”œβ”€β”€ services
        └── UserModule.ts

typescript-tdd-template's People

Contributors

aramanjon avatar

Stargazers

Albert VilΓ  avatar Carlos Zamora avatar Oriol Sastre Rienitz avatar Danny MejΓ­a avatar Marcos GonzΓ‘lez avatar Razon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.