Git Product home page Git Product logo

reactnd-project-readable-starter's Introduction

API Server

To install and start the API server, run the following commands in this directory:

  • npm install
  • node server

Using The Server

Include An Authorization Header

All requests should use an Authorization header to work with your own data:

fetch(
    url,
    {
        headers: { 'Authorization': 'whatever-you-want' }
    }
)

Comment Counts

Posts retrieved in a list or individually now contain comment counts in the format post: { commentCount: 0 }. This should make it easier to display the number of comments a post has without having to call the comments endpoint for each post. This count is updated whenever a comment is added or deleted via the POST /comments or DELETE /comments/:id endpoints.

API Endpoint

The following endpoints are available:

Endpoints Usage Params
GET /categories Get all of the categories available for the app. List is found in categories.js. Feel free to extend this list as you desire.
GET /:category/posts Get all of the posts for a particular category.
GET /posts Get all of the posts. Useful for the main page when no category is selected.
POST /posts Add a new post. id - UUID should be fine, but any unique id will work
timestamp - [Timestamp] Can in whatever format you like, you can use Date.now() if you like.
title - [String]
body - [String]
author - [String]
category - Any of the categories listed in categories.js. Feel free to extend this list as you desire.
GET /posts/:id Get the details of a single post.
POST /posts/:id Used for voting on a post. option - [String]: Either "upVote" or "downVote".
PUT /posts/:id Edit the details of an existing post. title - [String]
body - [String]
DELETE /posts/:id Sets the deleted flag for a post to 'true'.
Sets the parentDeleted flag for all child comments to 'true'.
GET /posts/:id/comments Get all the comments for a single post.
POST /comments Add a comment to a post. id - Any unique ID. As with posts, UUID is probably the best here.
timestamp - [Timestamp] Get this however you want.
body - [String]
author - [String]
parentId - Should match a post id in the database.
GET /comments/:id Get the details for a single comment.
POST /comments/:id Used for voting on a comment. option - [String]: Either "upVote" or "downVote".
PUT /comments/:id Edit the details of an existing comment. timestamp - timestamp. Get this however you want.
body - [String]
DELETE /comments/:id Sets a comment's deleted flag to true. ย 

reactnd-project-readable-starter's People

Contributors

ayoalik avatar forbiddenvoid avatar gihdz avatar jamesbibby avatar nomemoryerror avatar richardkalehoff avatar

Watchers

 avatar  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.