Node.js project with TypeScript, Express.js, ESLint, Prettier, ts-node, nodemon and package.json environment specific scripts
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.
-
Node.js: The project is built using Node.js, allowing users to leverage the benefits of server-side JavaScript.
-
TypeScript Integration: The project is written in TypeScript, providing static typing and improved code quality.
-
Express.js Framework: Utilizes the Express.js framework for building robust and scalable web applications and APIs.
-
ESLint Integration: Incorporates ESLint for static code analysis to identify and fix problematic patterns in the code.
-
Prettier Integration: Includes Prettier for code formatting, ensuring consistent and aesthetically pleasing code.
-
Environment Variables with dotenv: Uses the
dotenv
package to manage environment variables, making it easy to configure and deploy the application across different environments. -
Security with Helmet: Implements security practices by using the Helmet middleware to secure Express.js apps by setting various HTTP headers.
-
CORS Support: Integrates the
cors
package to handle Cross-Origin Resource Sharing, allowing controlled access to resources from different domains. -
Type Definitions: Includes TypeScript type definitions for key packages such as
cors
,express
,helmet
, andnode
. -
Development Dependencies for TypeScript: Dev dependencies like
@types/cors
,@types/express
,@types/helmet
,@types/node
provide TypeScript type definitions for development. -
Development Server with Nodemon: Uses Nodemon for automatic server restarts during development, making the development process more efficient.
-
TypeScript Execution with ts-node: Integrates
ts-node
for running TypeScript files directly, eliminating the need for compiling before execution during development. -
TypeScript Compiler (tsc): Includes the TypeScript compiler (
typescript
package) to transpile TypeScript code into JavaScript for deployment. -
Linting and Formatting Scripts: Provides environment-specific scripts in the
package.json
for linting and formatting code using ESLint and Prettier.
Follow the steps below to set up the project on your local system:
- Clone the Github Repo:
git clone https://github.com/shubham-sharmas/typescript-node-project.git
- Install dependencies:
npm i
- Start dev server:
npm run dev
- Open URL:
http://localhost:3000/
package.json
file contains different start scripts for different environment, use as per your requirement:
"local": "NODE_ENV=local nodemon",
"dev": "NODE_ENV=development npm run build:start",
"qa": "NODE_ENV=qa npm run build:start",
"prod": "NODE_ENV=production npm run build:start"