This project is a TypeScript-based backend application using Express, MongoDB with Mongoose, and other essential libraries for authentication and security.
Make sure you have the following installed on your machine:
- Clone the repository:
git clone <repository-url>
- Change into the project directory:
cd authentication-authorization
- Install dependencies:
npm install
- Create a
.env
file in the project root and set the following environment variables:ReplacePORT=5000 MONGODB_URI=<your-mongodb-uri> JWT_SECRET=<your-secret-key>
<your-mongodb-uri>
with your actual MongoDB connection URI and<your-secret-key>
with a secure secret key for JWT.
npm run build
: Build the TypeScript code.npm start
: Start the server (after building).npm run start:dev
: Start the server in development mode with automatic restarts on code changes.npm run lint
: Run ESLint to lint TypeScript files.npm run lint:fix
: Run ESLint and automatically fix fixable issues.npm run prettier
: Run Prettier to format code.npm run prettier:fix
: Run Prettier and automatically fix formatting issues.npm test
: Run tests (not implemented in this template).
- Build the project:
npm run build
- Start the server:
npm start
- Access the API at
http://localhost:5000
(or the port you specified in the.env
file).
For development with automatic restarts on code changes, use:
npm run start:dev