Skip to content

prisoner-skills-org/back-end

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prisoner Skills - Back-End


API Documentation

NON-AUTH ENDPOINTS

Links Endpoints
POST Registration /api/auth/register
POST Login /api/auth/login
GET Prisons /api/prisons
GET Prisons by ID /api/prisons/:id
GET Prisoners /api/prisoners
GET Prisoners by ID /api/prisoners/:id
GET Skills /api/skills
GET Skills by Prisoner ID /api/prisoners/:id/skills

AUTH ENDPOINTS

All Endpoints below require a token!

Links Endpoints
POST Prisoners /api/prisoners
PUT Prisoner by ID /api/prisoners/:id
DEL Prisoner by ID /api/prisoners/:id
POST Prison /api/prisons/
PUT Prison by ID /api/prisons/:id
DEL Prison by ID /api/prison/:id
POST Skills /api/skills
PUT Skills by Skill ID /api/skills/:id
DEL Skills by Skill ID /api/skills/:id/

[POST] Registration

{
	"username": "janedoe1",
	"password": "DoePass"
}

Returns id, username, and hashed password:

{
    "id": 1,
    "username": "janedoe1",
    "password": "hashed"
}

[POST] Login

{
	"username": "janedoe1",
	"password": "DoePass"
}

Returns:

{
    "message": "Welcome Jane!",
    "token": "keeping it secret!"
}

[GET] Prisons

[
	{
		id: integer,
		name: string,
		address: string,
		user_id: string // the admin assigned to the prison
	},
	.
	.
	.
]

[GET] Prisons By ID

   {
	id: integer,
		name: string,
		address: string,
		user_id: string
   }
		.
		.
		.
	]
}

[PUT] Prisons By ID

Requires the following in JSON body:

{
	name: string,
		address: string,
		user_id: string
}

[DEL] Prisons by ID

Returns:

{
    "removed": {
		prison object
	}
}

[GET] Prisoners by ID

[
	{
	 "id": 4,
  "name": "Morgan Ensley",
  "gender": "Female",
  "canHaveWorkLeave": 1,
  "prison_id": 1

	},
	.
	.
	.
]

[GET] Skills By Prisoners ID

{
  "id": 2,
  "name": "Sally Mason",
  "gender": "Female",
  "canHaveWorkLeave": 0,
  "prison_id": 2,
  "skills": [
    {
      "id": 2,
      "name": "Cleaning",
      "prisoner_id": 2
    },
    {
      "id": 3,
      "name": "Dancing",
      "prisoner_id": 2
    }
  ]
}


[POST] Prisoners

Required in JSON body:


{
 "name" : "John Smith",
	"gender" : "Male",
	"canHaveWorkLeave" : true,
	"prison_id" : 2
}

Returns:

{
 "id": 4,
  "name": "John Smith",
  "gender": "Male",
  "canHaveWorkLeave": 1,
  "prison_id": 2
}

[PUT] Prisoners by ID

Required in JSON body

{
	"name" : "Alex Smith",
	"gender" : "Male",
	"canHaveWorkLeave" : true,
	"prison_id" : 2
}

Returns:

{
   	"name" : "Alex Smith",
	"gender" : "Male",
	"canHaveWorkLeave" : true,
	"prison_id" : 2
}

[GET] Skills By Prisoner ID

{
  "id": 1,
  "name": "Billy Bob",
  "gender": "Male",
  "canHaveWorkLeave": 1,
  "prison_id": 1,
  "skills": [
    {
      "id": 1,
      "name": "Interior painting",
      "prisoner_id": 1
    },
    {
      "id": 2,
      "name": "Cleaning",
      "prisoner_id": 1
    }
  ]
}

[POST] Skills

{
	"name" : "Structural Engineering",
	"prisoner_id" : "4"
}

Returns:

{
  "id": 5,
  "name": "Structural Engineering",
  "prisoner_id": 4
}

[DEL] Prisoner By ID

Returns:

{
    "removed": {
		prisoner object
	}
}

[DEL] Prison By ID

Returns:

{
    "removed": {
		prison object
	}
}

[DEL] Skills by ID

Returns:

{
    "removed": {
		prisoner object
	}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •