|
1 |
| -# Node.js project with TypeScript, Express.js, ESLint, Prettier, ts-node, nodemon and package.json environment specific scripts. |
| 1 | +# Node.js project with TypeScript, Express.js, ESLint, Prettier, ts-node, nodemon and package.json environment specific scripts |
2 | 2 |
|
3 |
| -Welcome to the TypeScript Node.js project! This repository provides a comprehensive guide on establishing a Node.js project with TypeScript, Express.js, ESLint, Prettier, ts-node, nodemon, and environment-specific package.json scripts for local, development, QA, and production. |
| 3 | +## #[typescript-node-project](https://shubhamsharmas.hashnode.dev/a-guide-on-setting-up-a-nodejs-project-with-typescript-expressjs-eslint-prettier-ts-node-nodemon-and-packagejson-environment-specific-scripts "https://shubhamsharmas.hashnode.dev/a-guide-on-setting-up-a-nodejs-project-with-typescript-expressjs-eslint-prettier-ts-node-nodemon-and-packagejson-environment-specific-scripts") |
4 | 4 |
|
5 |
| -As you navigate through this project, we'll delve into the following key areas: |
| 5 | +Welcome to the TypeScript Node.js project! This repository provides complete guide on setting-up a Node.js project with TypeScript, Express.js, ESLint, Prettier, ts-node, nodemon, and environment-specific package.json scripts for local, development, QA, and production. |
6 | 6 |
|
7 |
| -### TypeScript Node.js Express Project Setup: |
8 |
| -Learn how to configure your project with TypeScript and Express.js to kickstart your development journey. |
| 7 | +## Technologies & Tools Used |
9 | 8 |
|
10 |
| -### ts-node and nodemon Setup: |
11 |
| -Set up ts-node and nodemon for a seamless development experience, enabling automatic TypeScript compilation and server restarts. |
| 9 | +1. **Node.js**: The project is built using Node.js, allowing users to leverage the benefits of server-side JavaScript. |
12 | 10 |
|
13 |
| -### Package.json Start Scripts: |
14 |
| -Explore environment-specific start scripts in package.json for local, development, QA, and production environments, tailoring your workflow to different stages. |
| 11 | +2. **TypeScript Integration**: The project is written in TypeScript, providing static typing and improved code quality. |
15 | 12 |
|
16 |
| -### Dotenv Global Configuration: |
17 |
| -Understand the importance of global configuration with Dotenv, allowing you to manage environment variables consistently across your project. |
| 13 | +3. **Express.js Framework**: Utilizes the Express.js framework for building robust and scalable web applications and APIs. |
18 | 14 |
|
19 |
| -### TypeScript Build Configuration: |
20 |
| -Dive into configuring TypeScript for optimized builds, ensuring efficiency and performance in your Node.js applications. |
| 15 | +4. **ESLint Integration**: Incorporates ESLint for static code analysis to identify and fix problematic patterns in the code. |
21 | 16 |
|
22 |
| -### Linting for Static Code Analysis: |
23 |
| -Implement ESLint for static code analysis, enhancing code quality and catching potential issues early in the development process. |
| 17 | +5. **Prettier Integration**: Includes Prettier for code formatting, ensuring consistent and aesthetically pleasing code. |
24 | 18 |
|
25 |
| -### Prettier for Code Formatting: |
26 |
| -Learn how to integrate Prettier to maintain consistent and aesthetically pleasing code formatting throughout your project. |
| 19 | +6. **Environment Variables with dotenv**: Uses the `dotenv` package to manage environment variables, making it easy to configure and deploy the application across different environments. |
27 | 20 |
|
28 |
| -Follow this link to review the project details and code walk-through: [node.js-typescript-project-setup](https://shubhamsharmas.hashnode.dev/a-guide-on-setting-up-a-nodejs-project-with-typescript-expressjs-eslint-prettier-ts-node-nodemon-and-packagejson-environment-specific-scripts) |
| 21 | +7. **Security with Helmet**: Implements security practices by using the Helmet middleware to secure Express.js apps by setting various HTTP headers. |
| 22 | + |
| 23 | +8. **CORS Support**: Integrates the `cors` package to handle Cross-Origin Resource Sharing, allowing controlled access to resources from different domains. |
| 24 | + |
| 25 | +9. **Type Definitions**: Includes TypeScript type definitions for key packages such as `cors`, `express`, `helmet`, and `node`. |
| 26 | + |
| 27 | +10. **Development Dependencies for TypeScript**: Dev dependencies like `@types/cors`, `@types/express`, `@types/helmet`, `@types/node` provide TypeScript type definitions for development. |
| 28 | + |
| 29 | +11. **Development Server with Nodemon**: Uses Nodemon for automatic server restarts during development, making the development process more efficient. |
| 30 | + |
| 31 | +12. **TypeScript Execution with ts-node**: Integrates `ts-node` for running TypeScript files directly, eliminating the need for compiling before execution during development. |
| 32 | + |
| 33 | +13. **TypeScript Compiler (tsc)**: Includes the TypeScript compiler (`typescript` package) to transpile TypeScript code into JavaScript for deployment. |
| 34 | + |
| 35 | +14. **Linting and Formatting Scripts**: Provides environment-specific scripts in the `package.json` for linting and formatting code using ESLint and Prettier. |
| 36 | + |
| 37 | +## Project Setup |
| 38 | + |
| 39 | +Follow the steps below to set up the project on your local system: |
| 40 | + |
| 41 | +1. Clone the Github Repo: `git clone https://github.com/shubham-sharmas/typescript-node-project.git` |
| 42 | +2. Install dependencies: `npm i` |
| 43 | +3. Start dev server: `npm run dev` |
| 44 | +4. Open URL: `http://localhost:3000/` |
| 45 | + |
| 46 | +### Package.json start scripts |
| 47 | + |
| 48 | +`package.json` file contains different start scripts for different environment, use as per your requirement: |
| 49 | + |
| 50 | +``` |
| 51 | +"local": "NODE_ENV=local nodemon", |
| 52 | +``` |
| 53 | + |
| 54 | +``` |
| 55 | +"dev": "NODE_ENV=development npm run build:start", |
| 56 | +``` |
| 57 | + |
| 58 | +``` |
| 59 | +"qa": "NODE_ENV=qa npm run build:start", |
| 60 | +``` |
| 61 | + |
| 62 | +``` |
| 63 | +"prod": "NODE_ENV=production npm run build:start" |
| 64 | +``` |
| 65 | + |
| 66 | +## Check the link for complete project details and code walk-through: [node.js-typescript-project-setup](https://shubhamsharmas.hashnode.dev/a-guide-on-setting-up-a-nodejs-project-with-typescript-expressjs-eslint-prettier-ts-node-nodemon-and-packagejson-environment-specific-scripts) |
0 commit comments