AuthNApp is a backend application that provides authentication and authorization services. It includes controllers and models for managing user authentication and authorization. The application checks whether a user is authorized to access a particular route and verifies if the user's role is authenticated.
To run the AuthNApp locally, follow these steps:
- Clone the repository:
git clone https://github.com/your-username/AuthNApp.git
- Install dependencies:
npm install
- Set up your environment variables:
- Create a
.env
file in the root directory - Add the following variables to your
.env
file:PORT=3000 DATABASE_URL=mongodb://localhost:27017/authnapp JWT_SECRET=your_jwt_secret_here
- Create a
- Start the server:
npm start
- The server should now be running on http://localhost:3000
To register a new user, send a POST request to /api/auth/register
with a JSON payload containing email
, password
, and role
:
{
"email": "[email protected]",
"password": "password123",
"role": "user"
}