This project is a backend service built with Node.js, Fastify, Mongoose, and Auth0 for authentication. It provides a simple API for user registration and login.
my-backend-service
├── src
│ ├── controllers
│ │ └── authController.js
│ ├── models
│ │ └── userModel.js
│ ├── routes
│ │ └── authRoutes.js
│ ├── services
│ │ └── authService.js
│ ├── utils
│ │ └── authUtils.js
│ └── index.js
├── package.json
├── .env
├── .gitignore
└── README.md
To set up the project, clone the repository and install the required packages:
npm install fastify mongoose dotenv @auth0/auth0-spa-js nodemon
Create a .env
file in the root directory and add the following variables:
MONGODB_URI=your_mongodb_connection_string
AUTH0_DOMAIN=your_auth0_domain
AUTH0_CLIENT_ID=your_auth0_client_id
AUTH0_CLIENT_SECRET=your_auth0_client_secret
To start the server in development mode, use:
npx nodemon src/index.js
- POST /api/auth/register: Register a new user.
- POST /api/auth/login: Log in an existing user.
Feel free to submit issues or pull requests for improvements or bug fixes.