Skip to content

SmartShed/Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Field Type Description
email string Email of Worker, Supervisor or Authority
password string Password

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

Field Type Description
email string Email of Worker, Supervisor or Authority
password string Password
name string Name of employee
position string Position (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

Field Type Description
auth_token string Worker 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

Field Type Description
email string Email 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

Field Type Description
email string Email of Worker, Supervisor or Authority
name string Name of employee
position string Position (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

Field Type Description
supervisor array of strings Emails of Supervisor
worker array of strings Emails of Workers
authority array of strings Emails of Authoritys
position "authority" OR "supervisor" OR "worker" Position of Employee
{
  "worker": ["[email protected]", "[email protected]", "[email protected]"],
  "supervisor": ["[email protected]", "[email protected]"],
  "authority": ["[email protected]"],
  "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

Field Type Description
email email Emails of Worker, Supervisor or authority
{
  "email": "[email protected]"
}

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

Field Type Description
email string Email
otp string OTP
{
  "email": "[email protected]",
  "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

Field Type Description
email string Email
password string New Password
{
  "email": "[email protected]",
  "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

Watchers

Forks