user-auth-imgbb
v1.0.0
Published
A Node.js auth package with Imgbb image upload and JWT login
Maintainers
Readme
User Auth with Imgbb Upload
This package provides a ready-to-use user authentication system in Node.js. It supports user registration, login, and profile access, along with profile image upload to Imgbb.
Features
- Register a user with name, email, password, and a profile image
- Upload images to Imgbb during registration
- Secure password storage using bcrypt
- Generate and verify JWT tokens on login
- Access protected profile route using token
Setup Instructions
Install the package Add the package to your Node.js project using GitHub Packages or npm.
Environment Variables Create a
.envfile in your root directory and add the following:IMGBB_API_KEY: Your Imgbb API key (you can get it from imgbb.com)JWT_SECRET: A secret string to sign JWT tokensMONGODB_URI: The full connection string to your MongoDB database (e.g., from MongoDB Atlas)
MongoDB You must have MongoDB running locally or on the cloud. Set your
MONGODB_URIlike this:mongodb+srv://<username>:<password>@cluster0.mongodb.net/your-db-nameReplace with your actual MongoDB credentials and database name.
Run the server After connecting the router in your Express app, you can start handling register, login, and profile routes.
API Endpoints
POST /api/auth/register: Register a new user with name, email, password, and profile imagePOST /api/auth/login: Log in a user with email and password, returns JWT and user infoGET /api/auth/me: Get the profile of the logged-in user (requires token in header)
NPM Package Link
You can access this package on NPM:
