Base URL: http://localhost:3000
Create a new user account.
- URL:
/register - Method:
POST - Body:
{ "nik": "1234567890123456", "name": "John Doe", "password": "securepassword", "role": "USER" // Optional, defaults to USER } - Response:
201 Created
Authenticate user and receive access credentials.
- URL:
/login - Method:
POST - Body:
{ "nik": "1234567890123456", "password": "securepassword" } - Response:
200 OK{ "message": "Login success", "user": { ... } }
Verify if the current user is authenticated.
- URL:
/check - Method:
GET - Response:
200 OK(User details) or401 Unauthorized
Retrieve a list of all election campaigns.
- URL:
/campaigns - Method:
GET - Response:
200 OK[CampaignObject]
Retrieve details for a specific campaign.
- URL:
/campaigns/:id - Method:
GET - Response:
200 OKCampaignObject
Create a new election campaign (Admin only).
- URL:
/campaigns - Method:
POST - Body:
{ "title": "Election 2024", "description": "General Election", "startDate": "2024-01-01T00:00:00Z", "endDate": "2024-01-02T00:00:00Z" } - Response:
201 Created
Remove a campaign.
- URL:
/campaigns/:id - Method:
DELETE - Response:
200 OK
Get high-level statistics for a campaign.
- URL:
/campaigns/:id/summary - Method:
GET - Response:
200 OK
Get detailed vote logs/stats for a campaign.
- URL:
/campaigns/:id/votes - Method:
GET - Response:
200 OK
List all candidates (optionally filtered by campaign).
- URL:
/candidates - Method:
GET - Response:
200 OK
Add a candidate to a campaign.
- URL:
/candidates - Method:
POST - Body:
{ "campaignId": 1, "number": 1, "name": "Jane Doe", "vision": "A better future", "mission": "To serve the people", "photo": "http://image.url" } - Response:
201 Created
Retrieve global dashboard statistics.
- URL:
/stats - Method:
GET - Response:
200 OK