Skip to content

daveeS987/buy-nothing-backend

 
 

Repository files navigation

Buy Nothing Back End

Inspired by Buy Nothing. A web application for giving things away for free or finding things for free. This is the back-end server for buynothing.netlify.app

Contributors: Davee Sok, Ryan Geddes, Sarah Shatto, Jonathon Lee.

Version

Links and Resources

Overview

This server performs crud operations on a listings collections and images collections. Certain routes can require authentication and authorization priveleges.

Architecture

  • The server uses an express framework and is deployed through heroku.
  • MongoDB is used to store listings information and image urls.
  • Actual images are not stored in our database, but a middleware in the image route, sends images to Cloudinary, and saves the url to our database.
  • Passwords are not stored in our database but handled through Auth0 on the frontend application.

Dependencies and Tools

JavaScript

Node.js

Express.js

Mongo

Cloudinary



Javascript ➡ NodeJS ➡ ExpressJS ➡ MongoDB ➡ Cloudinary 

Setup

  • Clone down this repo
  • Make sure MongoDB is installed on your computer
  • Install dependencies: npm install
  • Create an account at https://cloudinary.com/ and get the following:
    • Cloud Name
    • API key
    • API secret
  • Add the following into an .env file:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/buy-nothing-backend
SECRET= ** pick a word, must match front end secret word. this is used to authenticate a token
CLOUD_NAME=  <<Get from Cloudinary Account>>
API_KEY= <<Get from Cloudinary Account>>
API_SECRET= <<Get from Cloudinary Account>>
  • If you want a database in the cloud
    • Go to https://www.mongodb.com/
    • Create New project
    • Create new cluster
    • replace MONGODB_URI with the address mongo gives you
  • Run the server: nodemon index.js

How to use this server:

The following routes are available:

api/v1/listings
api/v1/imghandler/images
api/v1/imghandler/upload

api/v2/listings
api/v2/imghandler/images
api/v2/imghandler/upload

Schema:

const listings = mongoose.Schema({
  title: { type: String, required: true },
  description: { type: String, required:true },
  imageUrl: { type: String, required:true },
  creatorUserName: { type: String, required:true },
  creatorUserId: { type: String, required:true },
  categories: { type: String, required:true },
  location:{ type: String, required:true },
  itemStatus: { type: Boolean, required:true },
  comments:[],
  commentors: [],
});

Tests

in progress... no tests at this time

Releases

No releases published

Packages

 
 
 

Languages

  • JavaScript 100.0%