Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thund3rhawk/auth_api
Auth API: Register users with email/password, validate via OTP, store data, login with JWT, retrieve user info securely.
https://github.com/thund3rhawk/auth_api
becrypt dotenv expressjs jsonwebtoken mongodb mongoosejs nodejs nodemailer prettier typescript
Last synced: about 1 month ago
JSON representation
Auth API: Register users with email/password, validate via OTP, store data, login with JWT, retrieve user info securely.
- Host: GitHub
- URL: https://github.com/thund3rhawk/auth_api
- Owner: Thund3rHawk
- Created: 2024-04-18T14:09:06.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-05-05T16:56:09.000Z (7 months ago)
- Last Synced: 2024-10-11T12:03:39.581Z (about 1 month ago)
- Topics: becrypt, dotenv, expressjs, jsonwebtoken, mongodb, mongoosejs, nodejs, nodemailer, prettier, typescript
- Language: TypeScript
- Homepage:
- Size: 98.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Auth_API Documentation
Register users with email/password, validate via OTP, store data, login with JWT, retrieve user info securely.
## Folder Structure
```
.
├── src --------- Source code root
│ ├── controllers --------- Route specific application logic.
│ │ ├──info.controller.ts
│ │ ├──login.controller.ts
│ │ ├──signup.controller.ts
│ │ ├──user.controller.ts
│ │ └──verify.controller.ts
│ ├── db --------- Reusable components related to database
│ │ └──index.ts
│ ├── routes --------- Reusable components for routing
│ │ └──index.ts
│ ├── schema --------- Reusable components related to data schema definitions
│ │ └──user.model.ts
│ ├── utils --------- Global utility functions
│ │ ├── asyncHandler.ts ------ Utility functions for handling asynchronous operations.
│ │ ├── nodemailerConfig.ts ------ Configuration settings for nodemailer
│ │ └── verifyToken.ts --- Function for verifying tokens
│ └index.ts
├── .env
├── package.json
├── README.md
└── tsconfig.json ----- TypeScript configuration file
```### 1. User Registration
#### Endpoint:
```
POST /signup
```#### Description:
Allows users to register on the website using their email and password.#### Request Body:
```json
{
"email": "[email protected]",
"password": "password123"
}
```#### Response:
- `200 OK`: User registered successfully.
- `400 Bad Request`: Invalid request or user already exists.---
### 2. Email Verification
#### Endpoint:
```
POST /verify
```#### Description:
Sends an OTP (One-Time Password) to the user's email for account validation.#### Request Body:
```json
{
"email": "[email protected]",
"otp": "123456"
}
```#### Response:
- `200 OK`: User Verified.
- `400 Bad Request`: Invalid request or user not found.---
### 3. User Information Update
#### Endpoint:
```
POST /info
```#### Description:
Allows users to validate their account using the OTP received and update additional information like location, age, and work details.#### Request Body:
```json
{
"email": "[email protected]",
"location": "New York",
"work_details": "Software Engineer"
}
```#### Response:
- `200 OK`: User details added successfully.
- `400 Bad Request`: Invalid request or user not found.---
### 4. User Login and JWT Token Generation
#### Endpoint:
```
POST /login
```#### Description:
Allows users to log in using their email and password and generates a JWT (JSON Web Token) for authentication.#### Request Body:
```json
{
"email": "[email protected]",
"password": "password123"
}
```#### Response:
- `200 OK`: Login successful. JWT token generated.
- `401 Unauthorized`: Invalid email or password.---
### 5. Retrieve User Information
#### Endpoint:
```
GET /user
```#### Description:
Retrieves all information of the logged-in user using the JWT token.#### Request Header:
```
Authorization: Bearer
```#### Response:
- `200 OK`: User information retrieved successfully.
- `401 Unauthorized`: Invalid or expired JWT token.---
These are the endpoints provided by the Auth API for user registration, validation, login, and information retrieval. Please make sure to include appropriate error handling and security measures in the implementation.