Code Monkey home page Code Monkey logo

dadjokesbe's Introduction

DadJokesBE-BW

Backend API, and authorization

Jokes have this basic format:

{
   "id": 3,
   "joke": "joke description"
}
  • id is of type 'int', auto-generated by 'jokes' table.
  • user_id is of type 'int', generated by our CRUD functions
  • joke is of type 'string'

POST (registers a new user)

Body(Required): username, password

Headers(Required): Content-Type: application/json

Body:

{ "username": string (Required), "password": string (Required) }

Responds:

{
    "id": int,
    "username": string,
    "password": hashed string
}

POST (logs user in, returns a USER_TOKEN)

Body(Required): username, password

Headers(Required): Content-Type: application/json Body:

{ "username": string (Required), "password": string (Required) }

Responds:

{
    "message": string,
    "token": string
}

GET (returns a list of public jokes)

Responds:

[
 {
 	"id": int,
 	"joke": "Did you hear about the guy whose whole left side was cut off? He's all right now.",
 	"votes": int or null
 }
]

POST (Adds a new public joke)

Body: 'joke' (Required), 'votes' (Optional) Headers: Content-Type: application/json, Authorization: USER_TOKEN

Body:

{
	"joke": string (Required)
}

Response:

{
    "id": int,
    "joke": string,
    "votes": null
}

GET (returns a list of private jokes)

Headers: Authorization: USER_TOKEN Response:

	{
	    "id": int,
	    "joke": string,
	    "votes": null
	}

POST (Adds a new private joke)

joke_id REQUIRED in url

Body: 'joke' (Required), 'votes' (Optional) Headers: Content-Type: application/json, Authorization: USER_TOKEN Body:

    {
    	"joke": string (Required)
    }

Response:

	{
	    "id": int,
	    "joke": string,
	    "votes": null
	}

PUT (updates private joke by joke_id)

Body(Required): 'joke' Headers(Required): Content-Type: application/json, Authorization: USER_TOKEN

Body:

    {
    	"joke": string (Required)
    }

Response:

	{
	    "id": int,
	    "joke": string,
	    "votes": null
	}

DELETE (deletes a private joke by joke_ID)

Headers(Required): Authorization: USER_TOKEN

Response:

1

**200 OK**

or

**404 NOT FOUND**

    {
        "errorMessage": "A joke the specified ID does not exist."
    }

dadjokesbe's People

Contributors

adamhinckley avatar ajb85 avatar jkaunert avatar laikafusion avatar lflores12 avatar unknownmonk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.