A comprehensive backend system for the Boundless project with a robust authentication system.
-
Email/Password Authentication
- User registration with email verification
- Secure login with JWT tokens
- Password reset functionality
- Email verification with OTP
-
Social Authentication
- Google OAuth integration
- GitHub OAuth integration
-
Security Features
- JWT-based authentication
- Role-based access control
- Rate limiting
- CORS protection
- Helmet security headers
- Node.js >= 14.0.0
- MongoDB
- SMTP server (for email functionality)
- Google OAuth credentials
- GitHub OAuth credentials
- Clone the repository:
git clone https://github.com/yourusername/boundless-backend.git
cd boundless-backend- Install dependencies:
npm install- Create a
.envfile in the root directory with the following variables:
# Server Configuration
PORT=3000
MONGO_URI=mongodb://localhost:27017/boundless
# JWT Configuration
JWT_ACCESS_TOKEN_SECRET=your-access-token-secret
JWT_REFRESH_TOKEN_SECRET=your-refresh-token-secret
JWT_ACCESS_TOKEN_EXPIRY=15m
JWT_REFRESH_TOKEN_EXPIRY=7d
# Email Configuration
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_SECURE=false
EMAIL_USER=your-email@gmail.com
EMAIL_PASSWORD=your-app-specific-password
EMAIL_FROM=noreply@boundlessfi.xyz
# Google OAuth Configuration
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://localhost:3000/auth/google/callback
# GitHub OAuth Configuration
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
GITHUB_REDIRECT_URI=http://localhost:3000/auth/github/callback
# CORS Configuration
CORS_ORIGIN=http://localhost:3000- Start the development server:
npm run devPOST /api/auth/register- Register a new userPOST /api/auth/login- Login with email/passwordPOST /api/auth/forgot-password- Request password resetPOST /api/auth/reset-password- Reset password with tokenPOST /api/auth/google- Google OAuth loginPOST /api/auth/github- GitHub OAuth loginGET /api/auth/me- Get current user profile
-
POST /api/campaigns- Create a new campaign (creator only)- Request Body:
{ "projectId": "<projectObjectId>", "goalAmount": 10000, "deadline": "2024-12-31T23:59:59.000Z", "milestones": [ { "title": "M1", "description": "First milestone" }, { "title": "M2", "description": "Second milestone" } ] } - Response:
- 201 Created, campaign and milestones created, status set to
pending_approval.
- 201 Created, campaign and milestones created, status set to
- Request Body:
-
PATCH /api/campaigns/:id/approve- Admin approves a campaign (admin only)- Validations:
- Campaign must have at least one milestone
- Deadline must be a valid future date
- goalAmount must be a positive number
- Must have a whitepaper or pitch deck attached
- On success:
- Sets status to
live, recordsapprovedByandapprovedAt
- Sets status to
- Response:
- 200 OK, updated campaign returned
- Validations:
-
Admin reviews campaign details and milestones
-
If all validations pass, campaign is approved and goes live
-
Approval is logged for audit/debugging
-
POST /api/campaigns/:id/back