Skip to content

Repository files navigation

SmartShed Backend

1. Authentication APIs

1.1. Login

For Worker, Supervisor and Authority login

1.1.1. Request

POST /api/auth/login

1.1.2. Request Body

FieldTypeDescription
emailstringEmail of Worker, Supervisor or Authority
passwordstringPassword

1.1.3. Response

{
"status": "200 | 400",
"message": "Login successful | Login failed",
"auth_token": "token"
}

1.2. Register

For Worker, Supervisor and Authority registration

1.2.1. Request

POST /api/auth/register

1.2.2. Request Body

FieldTypeDescription
emailstringEmail of Worker, Supervisor or Authority
passwordstringPassword
namestringName of employee
positionstringPosition (Worker, Supervisor or Authority)

1.2.3. Response

{
"status": "200 | 400",
"message": "Registration successful | Registration failed",
"auth_token": "token"
}

1.3. Logout

For Worker, Supervisor and Authority registration

1.3.1. Request

POST /api/auth/logout

1.3.2. Request Headers

FieldTypeDescription
auth_tokenstringWorker token

1.2.3. Response

{
"status": "200 | 400",
"message": "Logout successful | Logout failed"
}

1.4. Google Login

For Worker, Supervisor and Authority registration

1.4.1. Request

POST /api/auth/login/google

1.4.2. Request Headers

FieldTypeDescription
emailstringEmail of Worker, Supervisor or Authority

1.4.3. Response

{
"status": "200 | 400",
"message": "Login successful | Login failed",
"auth_token": "token"
}

1.5. Google Register

For Worker, Supervisor and Authority registration

1.5.1. Request

POST /api/auth/register/google

1.5.2. Request Body

FieldTypeDescription
emailstringEmail of Worker, Supervisor or Authority
namestringName of employee
positionstringPosition (Worker, Supervisor or Authority)

1.5.3. Response

{
"status": "200 | 400",
"message": "Registration successful | Registration failed",
"auth_token": "token"
}

1.6. Add Employee

For Worker, Supervisor and Authority registration

1.6.1. Request

POST /api/auth/addemployee

1.6.2. Request Body

FieldTypeDescription
supervisorarray of stringsEmails of Supervisor
workerarray of stringsEmails of Workers
authorityarray of stringsEmails of Authoritys
position"authority" OR "supervisor" OR "worker"Position of Employee
{
"worker": ["worker01@gmail.com", "worker02@gmail.com", "worker03@gmail.com"],
"supervisor": ["supervisor01@gmail.com", "supervisor02@gmail.com"],
"authority": ["authority01@gmail.com"],
"position": "worker"
}

1.6.3. Response

{
"status": "200 | 500",
"message": "Employee emails added successfully! | Error"
}

1.7. Forgot Password

For Worker, Supervisor and Authority registration

1.6.1.1 Request

POST /api/auth/forgot-password

1.6.1.2 Request Body

FieldTypeDescription
emailemailEmails of Worker, Supervisor or authority
{
"email": "parthsali04@gmail.com"
}

1.6.1.3 Response

{
"message": "OTP sent successfully"
}

1.6.2.2 Request

POST /api/auth/validate-otp

1.6.2.2 Request Body

FieldTypeDescription
emailstringEmail
otpstringOTP
{
"email": "parthsali04@gmail.com",
"otp": "131432"
}

1.6.1.3 Response

{
"message": "OTP validated successfully"| "OTP expired"
}

1.6.3.1 Request

POST /api/auth/reset-password

1.6.3.2 Request Body

FieldTypeDescription
emailstringEmail
passwordstringNew Password
{
"email": "parthsali04@gmail.com",
"password": "new password"
}

1.6.3.3 Response

{
"message": "Password reset successfully"
}

2. Sections, Forms and Questions APIs

2.1. Get Sections

When a worker logs in, he will be redirected to the Dashboard. The Dashboard will show all the sections. The worker can click on a section to see the forms of that section.

2.1.1. Request

GET /api/sections

2.1.2. Response

{
"message": "Sections fetched successfully | Sections fetching failed",
"sections": [
{
"_id": "section_id",
"name": "section_name"
}
]
}

2.2. Get Forms of a Section

When worker clicks on a section in the Dashboard, he will be redirected to Forms by Section page. This page will show all the forms of that section. The worker can create a new form by clicking on form name in the All Forms section in the Forms by Section page.

2.2.1. Request

GET /api/sections/:section_id/forms

2.2.2. Response

{
"message": "Forms fetched successfully | Forms fetching failed",
"forms": [
{
"id": "form_id",
"title": "form_name",
"descriptionHindi": "descriptionHindi",
"descriptionEnglish": "descriptionEnglish"
}
]
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages