Repository for CSCI 187 Project. In order to run on your system, you'll need to install Node.js on your system. Instructions for how to do this are given here.
Once the repository is cloned on your computer, you can use 'npm install --force --save' inside the cinder directory to install the necessary packages. Afterwards, you can simply run npm run web to test the app in your browser.
npm install --force --savenpx tscnode server/server.jsnpm start
This endpoint logs a like on a specified listing
listing_id(required): The id of the listing you want to like
POST /match/like/123{ "message": "Like logged successfully" }or if you match you will get an array of the listing ids for which you matched
{ "matches": [7] }if there is some issue you will get this response
{ "message": "An unexpected error occurred", "error": "<some error message>" };200 OK: Successful request 400 Bad Request: Invalid listing id or you tried to like your own listing 401 Unauthorized: you are not signed in 500 Internal server error
This endpoint logs a dislike for a specified listing
listing_id(required): The id of the listing you want to like
POST /match/dislike/123{ "message": "Dislike logged successfully" }if there is some issue you will get this response
{ "message": "An unexpected error occurred", "error": "<some error message>" };200 OK: Successful request 400 Bad Request: Invalid listing id or you tried to like your own listing 401 Unauthorized: you are not signed in 500 Internal server error
This endpoint retrieves information about a specific user.
id(required): The unique identifier of the user.
GET /account/123{
"id": "n2to7j44j7v6zyx",
"username": "ThomasIsABigLoser",
"profile_pic": "https://imgur.com/image_link",
"phone_number": "2032127226",
"class_year": 2024,
"bio": "cool bio",
"owned_listings": [
{
"id": 6,
"listing_name": "Album",
"owner_id": "n2to7j44j7v6zyx",
"description": "Bang",
"size": "L",
"waist": null,
"inseam": "top",
"category": "1701147400",
"created_at": null,
"tags": ["cool", "tags2", "tags3", "tags4"],
"image_links": ["https://i.imgur.com/bctsoAx.jpeg"]
}
]
}200 OK: Successful request 400 Bad Request: User does not exist 500 Internal server error
This endpoint retrieves information about the authenticated user.
GET /account{
"id": "n2to7j44j7v6zyx",
"username": "ThomasIsABigLoser",
"profile_pic": "https://imgur.com/image_link",
"phone_number": "2032127226",
"class_year": 2024,
"bio": "cool bio",
"owned_listings": [
{
"id": 6,
"listing_name": "Album",
"owner_id": "n2to7j44j7v6zyx",
"description": "Bang",
"size": "L",
"waist": null,
"inseam": "top",
"category": "1701147400",
"created_at": null,
"tags": ["cool", "tags2", "tags3", "tags4"],
"image_links": ["https://i.imgur.com/bctsoAx.jpeg"]
}
]
}200 OK: Successful request 401 Unauthorized: You are not signed in 500 Internal server error
This endpoint retrieves information about the authenticated user's matches
GET /match{
"72l8ux9nredq88u": {
"listings_you_have_liked": [
{
"id": 7,
"listing_name": "Inner Speaker",
"owner_id": "72l8ux9nredq88u",
"description": "Bang",
"size": "M",
"waist": null,
"inseam": "accessory",
"category": "1701148012",
"created_at": null,
"tags": ["bang", "tags2", "tags3", "tags4"],
"image_links": ["https://i.imgur.com/fzCsSOY.jpeg"]
}
],
"listings_they_have_liked": [
{
"id": 6,
"listing_name": "Album",
"owner_id": "n2to7j44j7v6zyx",
"description": "Bang",
"size": "L",
"waist": null,
"inseam": "top",
"category": "1701147400",
"created_at": null,
"tags": ["cool", "tags2", "tags3", "tags4"],
"image_links": ["https://i.imgur.com/bctsoAx.jpeg"]
}
],
"their_account_info": {
"id": "72l8ux9nredq88u",
"username": "LukeIsABigLoser",
"profile_pic": "https://i.imgur.com/Y6t3Gtk.jpeg",
"phone_number": "2032127226",
"class_year": 2023,
"bio": "Bang",
"owned_listings": [
{
"id": 7,
"listing_name": "Inner Speaker",
"owner_id": "72l8ux9nredq88u",
"description": "Bang",
"size": "M",
"waist": null,
"inseam": "accessory",
"category": "1701148012",
"created_at": null,
"tags": ["bang", "tags2", "tags3", "tags4"],
"image_links": ["https://i.imgur.com/fzCsSOY.jpeg"]
}
]
}
}
}200 OK: Successful request 401 Unauthorized: You are not signed in 500 Internal server error
POST /filtered-listings (Returns all listing data matching your provided search criteria)
If you wish to get all listings, just pass an empty array for all parameters. Note once you provide at least one value
that is not an empty array for a search you will need to be explicit in what you are searching for. Example: if you want
any listing with a size medium you will need to pass a request with a body like:
json { "sizes": ["M"], "categories": ["top", "bottom", "accessory", "shoes"], "tags": [], "inseam_lengths": [], "waist_sizes": [] }
If you were to instead do:
json { "sizes": ["M"], "categories": [], "tags": [], "inseam_lengths": [], "waist_sizes": [] }
The endpoint would return nothing since you selected 0 categories.
name type data type description sizesrequired string[] The sizes you want the returned listings to have waist_sizesrequired number[] The waist sizes you want the returned listsing to have inseam_lengthsrequired number[] The inseam lengths you want the returned listings to have categoriesrequired string[] The categories of listings you want to have returned tagsrequired string[] The tags you want the listings returned to have
http code content-type response 200application/json`[{ "id": 1, "listing_name": "Rust", "owner_id": "o3lh4vrvdw85o6b", "description": "bang", "size": "M", "waist": null, "inseam": null, "category": "top", "created_at": "2023-11-21T03:17:52.000Z", "tags": ["tags1", "tags2", "tags3", "tags4"], "image_links": ["https://i.imgur.com/hCjlYSf.jpeg"] }] 400application/json{ "error": "Please provide valid values for all fields: tags, waist_sizes, inseam_lengths, sizes, and categories. If you wish to not specify one or more of these fields for your search, just assign an empty array to that field's value'" }500application/json{"error": "An unknown error occurred"}
POST /listing (Creates a listing of an item of clothing somone wishes to sell or swap on Cinder)
name type data type description filerequired Buffer or Buffer[] The binary of an image, can be more than one listing_namerequired string The name of the listing sizeoptional string The size of the cloting item waistoptional number The length of the waist (only for bottoms) insteamoptional number The length of the inseam (only for bottoms) descriptionrequired string The description for the listing categoryrequired string The category the listing is for (top, bottom, accessory, or shoes) tagsrequired string[] or string The user generated tags for the listing
http code content-type response 200application/json{"message": "OK"}400application/json{"error":"No image provided for listing"}500application/json{"error":"status 500, failed to upload image"}
curl -X POST -H "Content-Type: multipart/form-data" -d '-----WebKitFormBoundaryaWlA9egrpy2SXNMe\ Content-Disposition: form-data; name="file"; filename="pants_back.png"\ Content-Type: image/png\ \ \ ------WebKitFormBoundaryaWlA9egrpy2SXNMe\ Content-Disposition: form-data; name="file"; filename="pants_front.png"\ Content-Type: image/png\ \ \ ------WebKitFormBoundaryaWlA9egrpy2SXNMe\ Content-Disposition: form-data; name="listing_name"\ \ Cool pants\ ------WebKitFormBoundaryaWlA9egrpy2SXNMe\ Content-Disposition: form-data; name="description"\ \ Lightly used cool pants (worn once)\ ------WebKitFormBoundaryaWlA9egrpy2SXNMe\ Content-Disposition: form-data; name="price"\ \ 23\ ------WebKitFormBoundaryaWlA9egrpy2SXNMe\ Content-Disposition: form-data; name="category"\ \ accessory\ ------WebKitFormBoundaryaWlA9egrpy2SXNMe--' http://localhost:3000/listing
GET /listing/:listing_id (Gets the data for a particular listing id)
name type data type description listing_idrequired number The id for the listing you want data for
http code content-type response 200application/json{"message": "OK"}400application/json{"No listing with that id exists"}500application/jsonServer Error
DELETE /listing/:listing_id (Deletes a specified listing from the database)
name type data type description listing_idrequired number The id for the listing you want to delete
http code content-type response 200application/json{"message": "OK"}500application/json{"error": "some error"}
PUT /listing/:listing_id (Updates a listing for an item of clothing to be published on Cinder)
name type data type description filerequired Buffer or Buffer[] The binary of an image, can be more than one listing_namerequired string The name of the listing priceoptional number The price of the listing descriptionrequired string The description for the listing categoryrequired string The category the listing is for (top, bottom, accessory, or shoes) tagsrequired string[] or string The user generated tags for the listing tags_to_removerequired string The user provided tag(s) previously on the listing you are wanting to remove images_to_removerequired string[] or string The image url(s) previously for the listing you are wanting to remove
http code content-type response 200application/json{"message": "OK"}400application/json{"error":"No image provided for listing"}500application/json{"error":"status 500, failed to upload image"}
POST /signup (Creates an account with a username and password)
name type data type description usernamerequired string The username of the user passwordrequired string The user's password
http code content-type response 200application/json{"OK"}400application/json{"Invalid username or password"}500application/json{"An unknown error occurred"}
POST /login (Signs in a user using their username and password)
name type data type description usernamerequired string The username of the user passwordrequired string The user's password
http code content-type response 200application/json{"OK"}400application/json{"Incorrect username or password"}500application/json{"An unknown error occurred"}