This is the backend for the Wallpaper App, built with Node.js, Express, and MongoDB, featuring:
- User and Admin authentication
- Image uploads with Cloudinary
- Payments with Razorpay
- Validation with Joi
- Modular controller and route structure
- Error handling middleware
├── Controllers/ → Logic for each route
├── Db/db.js → MongoDB connection
├── Middlewares/ → Custom middleware (error, multer)
├── Models/ → Mongoose schemas
├── Routes/ → Express routers
├── Utils/ → Helpers (Cloudinary, handlers)
├── Validation/ → Joi validation schemas
├── public/temp/ → Temp folder for uploads
├── app.js → Main Express app
├── index.js → Server entry point
- Backend: Node.js, Express
- Database: MongoDB with Mongoose
- File Uploads: Multer + Cloudinary
- Payments: Razorpay
- Authentication: JWT
- Validation: Joi
- Mailer: Nodemailer
git clone https://github.com/yourusername/wallpaper-app-backend.git
cd wallpaper-app-backendnpm installPORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
# Razorpay
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_key_secret
# Cloudinary
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
# Nodemailer
SMTP_HOST=smtp.example.com
SMTP_PORT=465
SMTP_USER=youremail@example.com
SMTP_PASS=yourpassword🔐 Note: Make sure to keep
.envin your.gitignore(already done).
npx nodemon index.jsnode index.jsServer will start at http://localhost:5000 (or your configured port).
- Cloudinary is configured in
src/Utils/cloudinary.js. - Uploads handled via
multerMiddleware.js. - Endpoint example:
/api/wallpapers/upload
- Razorpay controller:
src/Controllers/razorpayController.js - Route:
/api/payment/create-order - Uses your Razorpay credentials to create and verify orders.
| Feature | Endpoint | Method |
|---|---|---|
| User Registration | /api/users/register |
POST |
| User Login | /api/login |
POST |
| Admin CRUD | /api/admin/ |
GET/POST/PUT/DELETE |
| Wallpaper Upload | /api/wallpapers/upload |
POST |
| Wallpaper List | /api/wallpapers |
GET |
| Create Razorpay Order | /api/payment/create-order |
POST |
Full routing is in
/src/Routes/
- Prettier config:
.prettierrc - Ignored files:
.prettierignore
Run formatting:
npx prettier --write .If you’re deploying to Vercel, your vercel.json will help route the backend appropriately.
You may also consider platforms like:
- Render
- Railway
- DigitalOcean App Platform
You can test endpoints using:
- Postman
- Thunder Client (VS Code)
- Insomnia
Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.
This project is licensed under the ISC License.
Developed by Vedansh Tiwari