Coder Social home page Coder Social logo

altschool-blog-api's Introduction

Blogging API Project

API for a blog app built with NodeJS, all blogposts are stored in a MongoDB database, some routes are only accessible by logged in users.


Routes

User Routes

  • POST /signup: Creates a new User and logs them in
  • POST /login: Logs an existing user in
  • POST /logout: Logs out an existing user

Blog Routes

  • GET /blog/: Gets all available blogposts
  • GET /blog/user: Gets all blogposts by a particulare user
  • GET /blog/:id: Gets a blogpost
  • POST /blog/: Creates a new blogpost
  • DELETE /blog/:id: Deletes a blogpost
  • PUT /blog/:id: Updates a blogpost

Requirements

  1. Users should have a first name, last name, email, password.
  2. A user should be able to sign up and sign in into the blog app
  3. Use JWT as authentication strategy and expire the token after 1 hour
  4. A blog can be in two states; draft and published
  5. Logged in and not logged in users should be able to get a list of published blogs created
  6. Logged in and not logged in users should be able to to get a published blog
  7. Logged in users should be able to create a blog.
  8. When a blog is created, it is in draft state
  9. The owner of the blog should be able to update the state of the blog to published
  10. The owner of a blog should be able to edit the blog in draft or published state
  11. The owner of the blog should be able to delete the blog in draft or published state
  12. The owner of the blog should be able to get a list of their blogs.
  13. The endpoint should be paginated and filterable by state
  14. When a single blog is requested, the api should return the user information(the author) with the blog. The read_count of the blog too should be updated by 1.

Setup

  • Install NodeJS, mongodb
  • Fork and Pull this repository
  • Install dependencies by running npm install in the root directory
  • Add enviromental variables in the following format:
    • PORT = "PORT"
    • DB_URI = "MongoDB connection URI"
    • JWT_SECRET = "Secret key"
  • Run npm run start

Models


User

field data_type constraints
id string required
firstName string required
lastName string required
email string required
password string required
blogs array required

Blog

field data_type constraints
id string Auto-generated
title string required, unique
state string default: "draft"
description string required
author string Auto-generated
reading_time string Auto-generated
read_count number Auto-generated
tags array required
body atring required

Contributor

altschool-blog-api's People

Contributors

teejay128 avatar

Watchers

 avatar

Forkers

tes-balo

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.