Skip to content

Mod8124/AnimeBlog

Repository files navigation

Anime Blog with register

This is an anime blog, with uploaded images, blog, comments, dark mode and auth system with jwt


Anime-BLog

Table of contents


Features

Users should be able to:

  • Could Log In
  • Could Sign Up
  • could log Out
  • Switch on dark mode o normal mode theme
  • The user just has to sign up one time and then just log in, at least the user wants to make another user
  • If the user log in, the user don't have to log in again until 3 days after, at least that he log out
  • If the user has been registering already could :
    • See all blogs
    • See random Quotes
    • See blog details
    • Post comments on the blog
    • Post and create blogs
  • If the user is the owner of the blog could:
    • Edit the Blog
    • Delete the Blog

Built with


Blog Api


This api provides blogs and comments that user has already created or posted

main route :

https://blog-anime-node.herokuapp.com/blogs

These examples exclude the view template EJS by default and auth middleware also you have to be a login already to get all these data. This is just a guide that things you could expect to get from API that exclude the view template

Get All Blogs


https://blog-anime-node.herokuapp.com/blogs

example request

    fetch('https://blog-anime-node.herokuapp.com/blogs')
    .then(request => request.json())
    .then(data => console.log(data))
    .catch(err => console.log(err.message))

Example response

 [
    {
        "title":"aaaa",
        "body":"eeee",
        "user:":"email.com",
        "filename":"esss",
        "content-type":"esss",
        "imageBased64":"esoo",
        "comments":["esoo"],
        "email":["user@gmail.com"]

    }
 ]

Details Blog


https://blog-anime-node.herokuapp.com/blogs/**id**

the id : blog_id

example request

    fetch(`https://blog-anime-node.herokuapp.com/blogs/${id}`)
    .then(request => request.json())
    .then(data => console.log(data))
    .catch(err => console.log(err.message))

Example response

 [
    {
        "title":"aaaa",
        "body":"eeee",
        "user:":"email.com",
        "filename":"esss",
        "content-type":"esss",
        "imageBased64":"esoo",
        "comments":["esoo"],
        "email":["user@gmail.com"]

    }
 ]

Post a blog


https://blog-anime-node.herokuapp.com/blogs

example request

     const formData = new FormData(this)

    fetch('https://blog-anime-node.herokuapp.com/blogs', {
        method:"POST",
        body:formData,
    })
     .then(request => request.json())
     .then(data => console.log(data))
      .catch(err => console.log(err.message))

example response - success

    [
        {
            "newBlog":"SADFASDASD",
            "location":"/blogs/newBlog"
        }
    ]

newBlog means the id of the new blog the location, it's the route for details of the blog

example response - unsuccessfull

    [
        {
            "errors":{
                "title":"",
                "body":""
            }
        }
    ]

These errors are based on mongoose handle Errors

Update a blog


https://blog-anime-node.herokuapp.com/blogs/update/**id**

example request

     const formData = new FormData(this)
      const id = blog._id

    fetch(`https://blog-anime-node.herokuapp.com/blogs/update/${id}`, {
        method:"PUT",
        body:formData,
    })
     .then(request => request.json())
     .then(data => console.log(data))
      .catch(err => console.log(err.message))

example response - unsuccessfull

    [
         
        {
            "errors":{
                "title":"",
                "body":""
            }
        }
    
    ]

The location, it's the route for details of the old blog

Example response - successfull

    [
        {
            "state":"update",
            "location":"/blogs/id_old_blog"
        }
    ]

The location, it's the route for details of the old blog

Post a comment

For the comment actually, the blog is updated

https://blog-anime-node.herokuapp.com/blogs/comments/**id**

example request

    const {email, comment} = form
    const id = blog._id

    fetch(`https://blog-anime-node.herokuapp.com/blogs/update/${id}`, {
           method:"PUT",
           headers:{"Content-Type":"application/json"},
           body:JSON.stringify({ email, comment }),
    })
     .then(request => request.json())
      .then(data => console.log(data))
      .catch(err => console.log(err.message))

Example response - successfull

    [
        {
            "state":"Successfull",
            "location":"/blogs/id_old_blog"
        }
    ]

Delete a Blog


https://blog-anime-node.herokuapp.com/blogs/id

Example request

    const id = blog._id

    fetch(`blogs/${id}`, {
        method:"DELETE",
    })
     .then(request => request.json())
     .then(data => console.log(data))
      .catch(err => console.log(err.message))

Example response - successfull

    [
        {
            "state":"delete",
            "location":"/blogs"
        }
    ]

example response - unsuccessfull

    [
         
        {
            "errors":"try again"
        }
    
    ]

Auth Api

The API for auth is for registering new users on the database and login with cookies

Hosting

The app is hosting on Heroku so kind of slow because you have to pay for dynos and I can't pay