Skip to content

Build-Week-Expat-Journal-3/backend

Repository files navigation

Back End Server for Build Week - Expat Journal

Expat Journal simulates a travel-blogging platform. Users can upload photos and share stories with other users.

Base URL

https://expat-journal3.herokuapp.com/

Installation

npm install
npm run server

Tests

npm test <test file>

Tech Stack

  • Node
  • Express
  • JWT
  • PostgreSQL
  • Knex
  • bcrypt

Endpoints

All get endpoints, as well as login and register endpoints do not require an auth header. Any other requests must be sent with an Authorization header containing the token.

Method Endpoint Description
POST /api/auth/register Creates a user using the information sent inside the request body. Returns the new user and the authorization token. username and password are required fields, bio is optional and can be updated later.
POST /api/auth/login checks user credentials against the request body, and returns an authorization token. Username and password are required.
GET /api/users Returns an array of all the users contained in the database.
GET /api/users/:id Returns the user object with the specified id from URL.
GET /api/users/:id/posts Returns an array of all the post objects associated with the user with the specified id provided in URL.
GET /api/posts/ Returns an array of all of the posts objects in the database. Not protected.
GET /api/posts/:id Returns the post object with the associated post ID specified in URL.
DELETE /api/users/:id Removes the user with the specified id and returns a success message. PROTECTED
DELETE /api/posts/:id Removes the post with the specified id and returns a success message. PROTECTED.
PUT /api/users/:id/bio Updates the user bio with the specified id using data from the request body. Returns the modified user object. PROTECTED
PUT /api/posts/:id Takes a request body object and updates the post story for the post object with the specified ID.
POST /api/users/:id/posts Creates a new post using the information sent inside the request body. title and image are required. ID and timestamp are created by the database. Location and story are optional. PROTECTED

POST LOGIN

{
  username: '',
  password: '',
}

BOTH REQUIRED FIELDS

POST REGISTER

{
  username: '',
  password: '',
  bio: '',
}

USERNAME and PASSWORD *required. bio is optional.

PUT /api/users/:id/bio

{
  bio: 'new bio goes here'
}

PUT /api/posts/:id

{
  story: 'new story goes here',
}

POST /api/user/:id/post

{
  title: '',
  img_url: '',
  location: '',
  story: '',
  user_id: 1
}

title, img_url and user_id are required fields, location and story are optional. timestamps and post id are generated by the database.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •