Skip to content

Node Js template configured with typescript, eslint, prettier, husky (pre-commit) and more...

Notifications You must be signed in to change notification settings

Aleydon/NodeJs-Template

Repository files navigation

🌎 NodeJs Template 🌎

📌 Requirements: 📌

NodeJs: 🔗 https://nodejs.org/en/


▶️ Get Started:

  1. Clone this repo
git clone https://github.com/Aleydon/NodeJs-Template.git
  1. Install NPM packages
npm install or yarn install
  1. Run this project
npm run dev or yarn dev

Template configuration:


Relative Paths Config:

	"baseUrl": "./",
		"paths": {
			"@controllers/*": ["./src/controllers/*"],
			"@models/*": ["./src/models/*"],
			"@routes/*": ["./src/routes/*"],
			"@services/*": ["./src/services/*"],
			"@utils/*": ["./src/utils/*"],
			"@constants/*": ["./src/constants/*"],
			"@config/*": ["./src/config/*"]
		},

Tests:

  • How to run tests:
npm run test or npm run test:watch

It has an example of tests with Jest + Testing-Library in src/tests/example.spec.tsx

import { UserModel } from '@models/user.model';

const sum = (numberA: number, numberB: number) => {
	return numberA + numberB;
};

describe('User Model', () => {
	it('should check if the name passed in the User model is Aleydon', () => {
		const user = new UserModel('Aleydon', 29);
		expect(user.name).toBe('Aleydon');
	});
});

describe('Math', () => {
	it('should sum two numbers correctly', () => {
		const result = sum(1, 2);
		expect(result).toBe(3);
	});
});

Test Running:


Image test running