Skip to content

codigo47/makingsense_blog

Repository files navigation

MakingSense blog API

How to Install the blog backend

git clone [email protected]:codigo47/makingsense_blog.git
cd makingsense_blog
docker-compose up

How to run the tests

$ docker exec -it app /bin/bash
$ mocha test

  Post
    PostModel
      model validateNew()
        ✓ should not allow an empty title
        ✓ should not allow an empty post
        ✓ should not allow an wrong state
      model validateList()
        ✓ should allow an empty post object
        ✓ should not allow an empty title
      model validateDelete()
        ✓ should not allow IDs with less than 24 chars
    PostController
      /posts
        ✓ should get a unauthorized error
        ✓ should create a new post
    PostController
      ✓ should create, list and delete a post


  9 passing (93ms)

Endpoints

POST /posts, creates a new post

body:

{"title": "title1", "text": "bla bla bla", "author": "esteban", "state": "draft"}

Example

curl -X POST "http://127.0.0.1:3000/posts" --user esteban:pass123 -H "Content-Type: application/json" -d '{"title": "title1", "text": "bla bla bla", "author": "esteban", "state": "draft"}'

GET /posts, get all posts

curl "http://127.0.0.1:3000/posts" --user esteban:pass123 -H "Content-Type: application/json"

GET /posts?id=[ID], get post by ID

curl "http://127.0.0.1:3000/posts?id=5ce44c5bd072890a9f9849b4" --user esteban:pass123 -H "Content-Type: application/json"

GET /posts?title=[TITLE], get post by TITLE

curl "http://127.0.0.1:3000/posts?title=any_title" --user esteban:pass123 -H "Content-Type: application/json"

DELETE /posts, deletes a post

body:

{id: '5ce48ba2e72abd0012e56ae8'}

Example

curl -X DELETE "http://127.0.0.1:3000/posts" --user codigo47:codigo12 -H "Content-Type: application/json" -d '{"id": "5ce44c5bd072890a9f9849b4"}'

About

Makingsense Blog challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published