This project is a comprehensive backend system built using Node.js, Express, and MongoDB. It provides functionalities to manage user authentication, file uploads, and associated details.
- User Authentication: Utilizes JWT for secure user registration, login, logout, and profile management. Passwords are securely hashed using bcrypt.
- User Profile: Allows users to register with a unique email, username, and an avatar uploaded to Cloudinary.
- Upload Management: Offers functionalities to create, update, delete, and retrieve file uploads associated with specific users. Each upload can have multiple files with respective details.
- File Details Management: Enables users to create, update, and delete details associated with files uploaded. These details include name, description, and timestamp.
- Node.js: Server-side JavaScript runtime environment.
- Express: Web application framework for Node.js.
- MongoDB: NoSQL database used to store user and upload-related data.
- Mongoose: Elegant MongoDB object modeling for Node.js.
- JWT (JSON Web Tokens): Used for secure authentication.
- Bcrypt: Library for hashing passwords securely.
- Cloudinary: Cloud-based image and video management service used for avatar uploads.
- For API endpoints and examples, refer to the [Postman Collection](link-to-your-postman-collection.
- Node.js and npm installed on your machine
- MongoDB database set up
- Cloudinary API credentials
-
Clone the repository
git clone https://github.com/your-username/repository-name.git
-
Install dependencies
cd repository-name npm install
-
Set up environment variables
- Create a
.env
file based on the provided.env.example
and add necessary credentials.
- Create a
-
Start the server
npm start
- User Registration: Send a POST request to
/api/user/register
with username, email, and password. - User Login: Send a POST request to
/api/user/login
with email and password. This returns a token for authentication. - Upload Management: Access endpoints in
/api/upload
for creating, updating, and retrieving uploads and associated details. - User Profile Update: Send a PUT request to
/api/user/:id
with updated username and avatar for profile modification.
User Routes:
/api/v1/register
: Register a new user./api/v1/login
: Log in a user./api/v1/logout
: Log out the user./api/v1/getById/:id
: Get user details by ID./api/v1/:id
: Update user details.
Upload Routes:
/api/v1/:userId
: Create a new upload./api/v1/create/:uploadId/:fileId
: Create details for a file in an upload./api/v1/update/:uploadId/:fileId/:detailId
: Update details for a file in an upload./api/v1/delete/:uploadId/:fileId/:detailId
: Delete details for a file in an upload./api/v1/getAll/:userId
: Get all uploads by user ID./api/v1/files/:uploadId
: Get files by upload ID./api/v1/details/:uploadId/:fileId
: Get details by file ID in an upload.
Feel free to contribute by opening issues or pull requests. Follow the existing code style and guidelines.
This project is licensed under the MIT License.