Bug Tracker API Documentation

REST API documentation for the Bug Tracker express application

Auth

Auth | Customer Login

post
http://localhost:4000/api/auth/customers/login

Parameter

Field Type Description
email String

Customer email

password String

Customer password

{
    "email": "suzi@test.ts"t,
    "password":"pass"
}

Success 200

Field Type Description
message String

Welcome message

token String

Authorization token

HTTP/1.1 200 Success
  {
      "message": "Welcome back Suzi",
      "token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjoxLCJuYW1lIjoiU3V6aSBMb2FkIiwicm9sZSI6I"
  }

Auth-Error

Name Type Description
UserNotFound String

User not found

BadRequest json

Missing params

HTTP 1.1 404 Not Found
"User was not found, please register"
HTTP 1.1 400 Not Found
{
     errorMessage: "Username or Password missing, please make sure to add username and password"
}

Send a Sample Request

url

Parameters

json
String
String

Auth | Employee Login

post
http://localhost:4000/api/auth/employees/login

Parameter

Field Type Description
email String

Employee email

password String

Employee password

role String

Employee role

{
    "email": "freddie@test.tst",
    "password": "pass",
    "role": "admin"
}

Success 200

Field Type Description
message String

Welcome message

token String

Authorization token

HTTP/1.1 200 Success
  {
      "message": "Welcome back Freddie",
      "token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjoxLCJuYW1lIjoiU3V6aSBMb2FkIiwicm9sZSI6I"
  }

Auth-Error

Name Type Description
UserNotFound String

User not found

BadRequest json

Missing Params

HTTP 1.1 404 Not Found
"User was not found, please register"
HTTP 1.1 400 Bad Request
{
     errorMessage: "Username or Password missing, please make sure to add username and password"
}

Send a Sample Request

url

Parameters

json
String
String
String

Auth | Register new user

post
http://localhost:4000/api/auth/register

Parameter

Field Type Description
firstname String

Customer Firstname

lastname String

Customer Lastname

email String

Customer Email

password String

Customer Password

role String

Customer User Role

{
    "firstName": "Firstname",
    "lastName": "Lastname",
    "email": "customer@test.tst",
    "password": "password",
    "role": "user"
}
HTTP/1.1 201 Created

  {
   "firstName": "Firstname",
   "lastName": "Lastname",
   "email": "customer@test.tst",
   "password": "$$2b$10$hVDly.4Mlfpu2tSVjZtnbu7nUsxWLnDT8Qr8JgFxhH5WGPSj6LVLG",
   "role": "user"
  }

Auth-Error

Name Type Description
BadRequest String

The entered email already has an associated account.

HTTP 1.1 400 Bad Request
"Email provided is already associated with an account"
HTTP 1.1 400 Bad Request
{
   "errorMessage": "Error, please make sure you use the correct format for email",
}
HTTP 1.1 400 Bad Request
{
    "errorMessage": "Not content, firstname is empty please provide first name"
}
HTTP 1.1 400 Bad Request
{
    "errorMessage": "First name exceeds min or max length, make sure that first name length is greater than 2 and less than 64"
}
HTTP 1.1 400 Bad Request
{
   "errorMessage": "Error, lastname not added, please make sure to add last name"
}
HTTP 1.1 400 Bad Request
{
    "errorMessage": "Lastname exceeds min or max length, make sure that lastname length is greater than 2 and less than 64"
}
HTTP 1.1 400 Bad Request
{
   "errorMessage": "Error, email is empty please send email address"
}
HTTP 1.1 400 Bad Request
{
  "errorMessage": "Error, password is empty, please make sure to provide a password in the request"
}
HTTP 1.1 400 Bad Request
{
   "errorMessage": "Please make sure the length of the password is at least 4 characters and less than 255"
}
HTTP 1.1 400 Bad Request
{
   "errorMessage": "Error, role not provided, please make sure to include a role"
}

Send a Sample Request

url

Parameters

json
String
String
String
String
String

Customer

Customer | Customers unique id

get
http://localhost:4000/api/customers/:id

Header

Field Type Description
jsonwebtoken String

Admin unique access token

{
    "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"
}

Success 200

Field Type Description
Customer json

Information

customer_id Number

ID

firstName String

Customer Firstname

lastName String

Customer Lastname

email String

Customer Email

password String

Customer Password

role String

Customer Role

HTTP/1.1 200 Ok
     {
         "customer_id": 1,
         "firstName": "Suzi",
         "lastName": "Load",
         "email": "suzi@test.tst",
         "password": "$2b$10$TA.fITJQ4gfT4w6HQizbrORraKBn9lWO5FInKUpr712bFko4ZY5/i",
         "role": "user"
     }

Customer-Error

Name Type Description
Unauthorized json

Not authorized

Forbidden String

Not authorized

{
    "message": "JWT malformed"
}
HTTP/1.1 403 Forbidden
"Permission Denied, not token found"
HTTP/1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Customer | Delete a customer

delete
http://localhost:4000/api/customers/:id

Header

Field Type Description
jsonwebtoken String

Admin unique access token

{
    "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"
}
HTTP/1.1 200 Ok
     {
         "customer_id": 9,
         "firstName": "Syas",
         "lastName": "Bnd",
         "email": "syasdsds@test.tst",
         "password": "$2b$10$NJxZd38RiKpbyjYmNz6FJueqTN/9UQ7/r7XfnLwDnYFwbKp3EfP6.",
         "role": "user"
     }

Customers-Error

Name Type Description
Forbidden String

Not authorized

Unauthorized json

Not authorized

HTTP 1.1 403 Forbidden
"Permission denied, not token found"
HTTP 1.1 401 Unauthorized
{
     message: "JWT malformed"
}
HTTP 1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Customer | Edit Customer

Edit customer description To edit a customer make sure to send in the header the jsonwebtoken The body of the request should include at least a change to make to the customer

put
http://localhost:4000/api/customers/:id

Header

Field Type Description
jsonwebtoken String

Employee unique access token

* { "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"}

Parameter

Field Type Description
payload json

Payload should be an object with the changes

{
    firstName: [The changed firstname],
    lastName: [The changed lastname],         
}

Request Body

Field Type Description
jsonwebtoken   json

JWT Mandatory json web token

payload   json

Mandatory changes to make at least 1 change

Success 200

Field Type Description
message json

Message

HTTP/1.1 200 Ok
     {
         "message": "Customer has been updated!"
     }

Customer-Error

Name Type Description
Unauthorized json

Not authorized

Forbidden String

Not authorized

{
    "message": "JWT malformed"
}
HTTP/1.1 403 Forbidden
"Permission Denied, not token found"
HTTP/1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Parameters

json
json

Body

json

Customers

Customers | List all customers

get
http://localhost:4000/api/customers

Header

Field Type Description
jsonwebtoken String

Employees unique access token

{
    "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"
}

Success 200

Field Type Description
customers json

List of all customers

customer_id Number

Customer ID

firstname String

Customer Firstname

lastname String

Customer Lastname

email String

Customer email

password String

Customer Password

role String

Customer Role

HTTP/1.1 200 OK
     [
         {
             "customer_id": 1,
             "firstName": "Lorenzo",
             "lastName": "Duplo",
             "email": "duplo@test.tst",
             "password": "afdfasdfasfasdfasdfsadfasdf,
             "role": "user"
         },
         {
             "customer_id": 2,
             "firstName": "Freddie",
             "lastName": "Maco",
             "email": "freddie@test.tst",
             "password": "$2b$10$Z34VNxFTv6WToPrnpqMn3uZa9oC7b/U1gR//UxQV6D.TJrKburmEe",
             "role": "user"
         },
    ]

Customers-Error

Name Type Description
Forbidden String

Not authorized

Unauthorized json

Not authorized

HTTP 1.1 403 Forbidden
"Permission denied, not token found"
HTTP 1.1 401 Unauthorized
{
     message: "JWT malformed"
}
HTTP 1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Employee

Employee | Create new employee

post
http://localhost:4000/api/employees/:id

Parameter

Field Type Description
firstname String

Employee Firstname

lastname String

Employee Lastname

email String

Employee Email

password String

Employee Password

role String

Employee User Role

{
    "firstName": "Firstname",
    "lastName": "Lastname",
    "email": "unique@test.tst",
    "password": "password",
    "role": "admin"
}
HTTP/1.1 201 Created

  {
    "employee_id": 20
    "firstName": "Firstname",
    "lastName": "Lastname",
    "email": "unique@test.tst",
    "password": "$$2b$10$hVDly.4Mlfpu2tSVjZtnbu7nUsxWLnDT8Qr8JgFxhH5WGPSj6LVLG",
    "role": "admin"
  }

Employee-Error

Name Type Description
BadRequest String

The entered email already has an associated account.

Bad json

Request Role param empty.

HTTP 1.1 400 Bad Request
"Email provided is already associated with an account"
HTTP 1.1 400 Bad Request
{
    "errorMessage": "Not content, firstname is empty please provide first name"
}
HTTP 1.1 400 Bad Request
{
   "errorMessage": "Error, lastname not added, please make sure to add last name"
}
HTTP 1.1 400 Bad Request
{
   "errorMessage": "Error, email is empty please send email address"
}
HTTP 1.1 400 Bad Request
{
   "errorMessage": "Error, password not provided, please create a password"
}
HTTP 1.1 400 Bad Request
{
   "errorMessage": "Error, password not provided, please create a password"
}
HTTP 1.1 400 Bad Request
{
   "errorMessage": "Error, role not provided, please make sure to include a role"
}

Send a Sample Request

url

Parameters

json
String
String
String
String
String

Employee | Delete an employee

delete
http://localhost:4000/api/employees/:id

Header

Field Type Description
jsonwebtoken String

Admin unique access token

{
    "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"
}
HTTP/1.1 200 Ok
     {
         "employee_id": 9,
         "firstName": "Firstname",
         "lastName": "Lastname",
         "email": "unique@test.tst",
         "password": "$2b$10$NJxZd38RiKpbyjYmNz6FJueqTN/9UQ7/r7XfnLwDnYFwbKp3EfP6.",
         "role": "admin"
     }

Employee-Error

Name Type Description
Forbidden String

Not authorized

Unauthorized json

Not authorized

HTTP 1.1 403 Forbidden
"Permission denied, not token found"
HTTP 1.1 401 Unauthorized
{
     message: "JWT malformed"
}
HTTP 1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Employee | Edit Employee

Edit customer description To edit an employee make sure to send in the header the jsonwebtoken The body of the request should include at least a change to make to the employee

put
http://localhost:4000/api/employee/:id

Header

Field Type Description
jsonwebtoken String

Employee unique access token

* { "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"}

Parameter

Field Type Description
payload json

Payload should be an object with the changes

{
    firstName: "Change",
    lastName: "Change",         
}

Request Body

Field Type Description
jsonwebtoken   json

JWT Mandatory json web token

payload   json

Mandatory changes to make at least 1 change

Success 200

Field Type Description
employee json

Updated Employee Object

message json

Message

HTTP/1.1 200 Ok
     {
        {
         "employee_id": 9,
         "firstName": "Changed FirstName",
         "lastName": "LastName",
         "email": "unique@test.tst",
         "password": "$2b$10$NJxZd38RiKpbyjYmNz6FJueqTN/9UQ7/r7XfnLwDnYFwbKp3EfP6.",
         "role": "admin"
        },
        "message": "Employee has been updated!"
     }

Customer-Error

Name Type Description
Unauthorized json

Not authorized

Forbidden String

Not authorized

{
    "message": "JWT malformed"
}
HTTP/1.1 403 Forbidden
"Permission Denied"
HTTP/1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Parameters

json
json

Body

json

Employee | Employees unique id

get
http://localhost:4000/api/employees/:id

Header

Field Type Description
jsonwebtoken String

Admin unique access token

{
    "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"
}

Success 200

Field Type Description
Employee json

Information

employee_id Number

ID

firstName String

Employee Firstname

lastName String

Employee Lastname

email String

Employee Email

password String

Employee Password

role String

Employee Role

HTTP/1.1 200 Ok
     {
         "employee_id": 1,
         "firstName": "Suzi",
         "lastName": "Load",
         "email": "suzi@test.tst",
         "password": "$2b$10$TA.fITJQ4gfT4w6HQizbrORraKBn9lWO5FInKUpr712bFko4ZY5/i",
         "role": "user"
     }

Employee-Error

Name Type Description
Unauthorized json

Not authorized

Forbidden String

Not authorized

{
    "message": "JWT malformed"
}
HTTP/1.1 403 Forbidden
"Permission Denied"
HTTP/1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Employees

Employees | List all Employees

get
http://localhost:4000/api/employees

Header

Field Type Description
jsonwebtoken String

Employees unique access token

{
    "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"
}

Success 200

Field Type Description
Employees Object[]

List of all Employees

employee_id Number

Employee ID

firstname String

Employee Firstname

lastname String

Employee Lastname

email String

Employee email

password String

Employee Password

role String

Employee Role

HTTP/1.1 200 OK
     [
         {
             "employee_id": 1,
             "firstName": "Lorenzo",
             "lastName": "Duplo",
             "email": "duplo@test.tst",
             "password": "asgjsadgasjdg",
             "role": "user"
         },
         {
             "employee_id": 2,
             "firstName": "Freddie",
             "lastName": "Maco",
             "email": "freddie@test.tst",
             "password": "$2b$10$Z34VNxFTv6WToPrnpqMn3uZa9oC7b/U1gR//UxQV6D.TJrKburmEe",
             "role": "user"
         },
    ]

Employees-Error

Name Type Description
Forbidden String

Not authorized

Unauthorized json

Not authorized

HTTP 1.1 403 Forbidden
"Permission denied, not token found"
HTTP 1.1 401 Unauthorized
{
     message: "JWT malformed"
}
HTTP 1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Ticket

Ticket | Assign Ticket to employee

Assign ticket description To assign a ticket to an employee make sure to send in the request body the employee id

patch
http://localhost:4000/api/tickets/:id

Header

Field Type Description
jsonwebtoken String

Employee admin unique access token

* { "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"}

Parameter

Field Type Description
payload json

Payload should be an object with employee id

id Number

Employee ID

{
    "employee_id": 2
}

Success 200

Field Type Description
message json

Message

ticket json

Ticket update with new assigned employee

HTTP/1.1 Ok
     {
         "message": "The ticket has been assigned with a new employee, Freddie Maco will be taking care of the ticket with the id of 8",
         "ticket": {
                     "ticket_id": 8,
                     "customer_id": 1,
                     "employee_id": 2,
                     "subject": "More test",
                     "date": "November 11th 2022",
                     "status": "new",
                     "body": "testing testing testing"
                     }
     }

Ticket-Error

Name Type Description
TicketNotFound String

Ticket not found

Forbidden String

Not authorized

HTTP/1.1 404  Not Found
"Ticket with id of 81 does not exist!"
HTTP/1.1 403 Forbidden
"Permission Denied, not token found"
HTTP/1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Parameters

json
json
Number

Ticket | Create a ticket

post
http://localhost:4000/api/tickets/

Header

Field Type Description
jsonwebtoken String

Customer or Admin unique token

{
    "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"
}
HTTP/1.1 200 Ok
         {
             "message": "A new ticket with id: 8 was created!",
         }

Tickets-Error

Name Type Description
Unauthorized json

Not authorized

Forbidden String

Not administrator

{
    "message": "Invalid Token"
}
HTTP/1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Ticket | Delete a ticket

delete
http://localhost:4000/api/tickets/:id

Header

Field Type Description
jsonwebtoken String

Admin or Customer-Owner unique access token

{
    "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"
}
HTTP/1.1 200 Ok
      {
          "deleted": {
          "ticket_id": 7,
          "customer_id": 1,
          "employee_id": null,
          "subject": "More test",
          "date": "November 11th 2022",
          "status": "new",
          "body": "testing testing testing"
          },
          "message": "Ticket with id 7 has been deleted"
      }

Ticket-Error

Name Type Description
Forbidden String

Not authorized

Unauthorized json

Not authorized

HTTP 1.1 403 Forbidden
"Permission denied, not token found"
HTTP 1.1 401 Unauthorized
{
     message: "JWT malformed"
}
HTTP 1.1 403 Forbidden
"Permission denied, not the owner of the ticket"

Send a Sample Request

url

Headers

String

Ticket | Edit Ticket

Edit customer description To edit a ticket make sure to send in the header the jsonwebtoken The body of the request should include at least a change to make to the customer Only the ticket's customer/owner or an employee admin can edit a ticket

put
http://localhost:4000/api/tickets/:id

Header

Field Type Description
jsonwebtoken String

Customer Owner or Employee unique access token

* { "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"}

Parameter

Field Type Description
payload json

Payload should be an object with the changes

{
    "subject": "New Subject...",
    "body": "New body...",         
}

Request Body

Field Type Description
jsonwebtoken   json

JWT Mandatory json web token

payload   json

Mandatory changes to make at least 1 change

Success 200

Field Type Description
message json

Message

HTTP/1.1 200 Ok
     {
         "ticket_id": 6,
         "customer_id": 1,
         "employee_id": null,
         "subject": "New subject changes..."",
         "date": "November 5th 2022",
         "status": "new",
         "body": "New body changes..."
     }

Ticket-Error

Name Type Description
Unauthorized json

Not authorized

Forbidden String

Not authorized

{
    "message": "JWT malformed"
}
HTTP/1.1 403 Forbidden
"Permission Denied"
HTTP/1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Parameters

json
json

Body

json

Ticket | Users unique id

Get a ticket by id A ticket can be checked by the owner/customer of the ticket and an employee with admin access

get
http://localhost:4000/api/tickets/:id

Header

Field Type Description
jsonwebtoken String

Customer Owner or Admin unique access token

{
    "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"
}

Success 200

Field Type Description
ticket json

Ticket Information

ticket_id Number

Ticket ID

customer_id Number

Customer Owner ID

employee_id Number

Employee Assigned ID

subject String

Ticket Subject

date String

Ticket Date

status String

Ticket Status

body String

Ticket Body

HTTP/1.1 200 Ok
         {
             "ticket_id": 6,
             "customer_id": 1,
             "employee_id": 1,
             "subject": "java update",
             "date": "November 5th 2022",
             "status": "new",
             "body": "System requires a java update"
         }

Tickets-Error

Name Type Description
Unauthorized json

Not authorized

Forbidden String

Not authorized

{
    "message": "JWT malformed"
}
HTTP/1.1 403 Forbidden
"Permission Denied, not token found"
HTTP/1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Tickets

Tickets | List all tickets

get
http://localhost:4000/api/tickets

Header

Field Type Description
jsonwebtoken String

Employees unique access token

{
    "Authorization": "aklsdfuhajwejn;aglkasgjasoidgasf##$$sjfaisdfoi"
}

Success 200

Field Type Description
tickets Object[]

List of all tickets

ticket_id Number

Ticket ID

customer_id Number

Customer Owner ID

employee_id Number

Employee Assigned ID

subject String

Ticket Subject

date String

Ticket Date

status String

Ticket Status

body String

Ticket Body

HTTP/1.1 200 OK
     [
         {
             "ticket_id": 6,
             "customer_id": 1,
             "employee_id": 1,
             "subject": "java update",
             "date": "November 5th 2022",
             "status": "new",
             "body": "System requires a java update"
         },
         {
             "ticket_id": 7,
             "customer_id": 1,
             "employee_id": null,
             "subject": "More test",
             "date": "November 12th 2022",
             "status": "new",
             "body": "testing testing testing"
         }
    ]

Tickets-Error

Name Type Description
Forbidden String

Not authorized

Unauthorized json

Not authorized

HTTP 1.1 403 Forbidden
"Permission denied, not token found"
HTTP 1.1 401 Unauthorized
{
     message: "JWT malformed"
}
HTTP 1.1 403 Forbidden
"Permission denied, not an admin user"

Send a Sample Request

url

Headers

String

Generated with apidoc 0.51.1 - Fri May 20 2022 00:42:11 GMT-0400 (Eastern Daylight Time)