This is my first Node.js Express project for an e-commerce server. The server is built using TypeScript and follows a structured approach for development and production environments. Below are the available commands and their functionalities.
To get started with the project, follow these instructions.
- Node.js (v14.x or later)
- npm (v6.x or later) or yarn (v1.x or later)
- TypeScript (v4.x or later)
- ts-node-dev
- eslint
- prettier
-
Clone the repository:
git clone https://github.com/your-username/e-commerce-server.git cd e-commerce-server
-
Install the dependencies:
npm install # or yarn install
In the project directory, you can run the following scripts:
-
Production:
npm run start:prod # or yarn start:prod
This will compile the TypeScript files and start the server using the compiled JavaScript files located in the
dist
directory. -
Development:
npm run start:dev # or yarn start:dev
This will start the server in development mode using
ts-node-dev
for real-time TypeScript compilation and automatic server restarts.
npm run build
# or
yarn build
This will compile the TypeScript files into JavaScript and output them to the dist
directory.
npm run lint
# or
yarn lint
This will run ESLint on the src
directory, using the configurations specified in the .eslintrc
file and ignoring files listed in .eslintignore
.
npm run lint:fix
# or
yarn lint:fix
This will run ESLint with the --fix
flag, attempting to automatically fix any linting errors in the codebase.
npm run prettier
# or
yarn prettier
This will format the code in the src
directory using Prettier, according to the rules specified in the Prettier configuration file.
npm run prettier:fix
# or
yarn prettier:fix
This will run Prettier with the --write
flag, attempting to automatically fix any formatting issues in the codebase.
The project follows a typical structure for a Node.js application with TypeScript:
e-commerce-server/
├── dist/ # Compiled JavaScript files
├── src/ # Source TypeScript files
│ ├── controllers/ # Controller files
│ ├── models/ # Model files
│ ├── routes/ # Route files
│ ├── services/ # Service files
│ ├── utils/ # Utility files
│ ├── server.ts # Entry point of the application
├── .eslintignore # ESLint ignore file
├── .eslintrc # ESLint configuration file
├── .gitignore # Git ignore file
├── .prettierrc # Prettier configuration file
├── package.json # NPM package configuration file
├── tsconfig.json # TypeScript configuration file
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.