Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# Project API

This project includes the packages and babel setup for an express server, and is just meant to make things a little simpler to get up and running with.

## Getting started

Install dependencies with `npm install`, then start the server by running `npm run dev`

## View it live

Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about.
backend happy api
https://smilezone78.netlify.app/
33 changes: 33 additions & 0 deletions models/HappyThoughts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const mongoose = require('mongoose');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is a duplicate of the Schema in server.js. I suggest you use this Schema instead thou it has more properties for e.g. message, and import it into server.js.


const HappyThoughtsSchema = new mongoose.Schema({
message: {
type: String,
required: true,
minlength: 5,
maxlength: 140,
},
hearts: {
type: Number,
default: 0,
},
createdAt: {
type: Date,
default: Date.now,
},
username: {
type: String,
},
userId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
},
likedBy: [
{
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
},
],
});

module.exports = mongoose.model('HappyThoughts', HappyThoughtsSchema);
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
"@babel/core": "^7.17.9",
"@babel/node": "^7.16.8",
"@babel/preset-env": "^7.16.11",
"bcrypt-nodejs": "^0.0.3",
"cors": "^2.8.5",
"express": "^4.17.3",
"express-list-endpoints": "^7.1.1",
"jsonwebtoken": "^9.0.2",
"jwt-decode": "^4.0.0",
"mongoose": "^8.15.1",
"nodemon": "^3.0.1"
}
}
Loading