This is the backend API for the PMII (Pergerakan Mahasiswa Islam Indonesia) application. It provides authentication and user management functionality.
- User registration and authentication
- Pengurus (administrator) management
- Password reset functionality
- JWT-based authentication
- MongoDB Atlas integrations
- Go 1.21 or later
- MongoDB Atlas account
- Vercel account (for deployment)
Create a .env file in the root directory with the following variables:
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
PORT=3000
POST /api/auth/register- Register a new userPOST /api/auth/login- Login as a regular userPOST /api/auth/login-pengurus- Login as a pengurusPOST /api/auth/forgot-password- Request password resetPOST /api/auth/reset-password- Reset password with token
POST /api/create-pengurus- Create a new pengurus entry (requires authentication)
{
"_id": "ObjectId",
"email": "string (unique)",
"password_hash": "string",
"full_name": "string",
"anggota_id": "string (nullable)",
"role": "enum ['null', 'mapaba', 'pkd', 'pkl', 'pkn']",
"code_kepengurusan": "string (nullable)",
"active": "boolean",
"created_at": "timestamp",
"updated_at": "timestamp"
}{
"_id": "ObjectId",
"user_id": "ObjectId",
"level": "enum ['PB', 'PKC', 'PC', 'PK', 'PR']",
"wilayah": "string (nullable)",
"cabang": "string (nullable)",
"komisariat": "string (nullable)",
"jabatan": "string",
"aktif": "boolean",
"mulai_jabatan": "date",
"akhir_jabatan": "date",
"created_at": "timestamp",
"updated_at": "timestamp"
}{
"_id": "ObjectId",
"domain": "string (unique)",
"is_active": "boolean",
"created_at": "timestamp"
}{
"_id": "ObjectId",
"user_id": "ObjectId",
"token": "string",
"expires_at": "timestamp",
"created_at": "timestamp"
}- Passwords are hashed using bcrypt with cost factor 12
- JWT tokens are used for authentication
- Input validation is performed on all endpoints
- CORS is configured to allow specific origins
- Environment variables are used for sensitive data
- Clone the repository
- Install dependencies:
go mod download - Create
.envfile with required variables - Run the server:
go run main.go
The application is designed to be deployed on Vercel as serverless functions. Each API endpoint is implemented as a separate function in the /api directory.
This project is proprietary and confidential.