Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Pull Request #4

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b94c53c
Initial commit.
Jul 17, 2018
78e5b29
Fixed json
Jul 17, 2018
18afce9
Stupid errors! We hates them!
Jul 17, 2018
16c9f3b
Why the heck is this not working?
Jul 17, 2018
0aca6cf
Hope this works...
Jul 17, 2018
4aadc1a
Let's see if this works now...
Jul 17, 2018
8569adf
Trying to get it to work still.
Jul 17, 2018
ee0001e
Please work!
Jul 17, 2018
80b8d33
Added node -v 8
Jul 17, 2018
444426b
Fixed?
Jul 17, 2018
b63101e
Completed Trello.
Jul 18, 2018
048d8d2
Got notes and user models done.
Jul 18, 2018
5c4cee2
Updated README.md
Jul 18, 2018
6ebc407
Server connecting to database but had to comment out server.use('/use…
Jul 19, 2018
7512b8f
Using console.log with userEndpoints and noteEndpoints to trace the e…
Jul 19, 2018
3270d8d
Sometimes you just have to pull the pin and walk away; starting over.
Jul 20, 2018
c031c72
Still not getting it.
Jul 23, 2018
303415e
Fixed package.json
Jul 23, 2018
47b2dd2
Successfully connected to Database!
Jul 24, 2018
338dfa2
PUT, POST, PUT, and DELETE requests all working!
Jul 24, 2018
98c5ce9
Modified README.md
Jul 24, 2018
b12bc88
get('/:id') working!
Jul 24, 2018
5378a3b
Added delete to user.
Jul 25, 2018
83f6aab
I messed something up so reverting my code.
Jul 25, 2018
72219e4
Going to try PUT with user.
Jul 25, 2018
56a32bc
Going to try PUT request for user.
Jul 25, 2018
16eba51
user PUT successfully updates user in database but Postman still give…
Jul 25, 2018
4269ae5
Let's see if no error without return.
Jul 26, 2018
421ba46
F******* user
Jul 26, 2018
c817c99
Just user
Jul 26, 2018
57c760f
delete user method added.
Jul 26, 2018
ba834b6
Adding notes array to user schema
Jul 26, 2018
6c51ead
Testing auth routes.
Jul 26, 2018
ed0f1b9
Added auth routes.
Jul 26, 2018
0230c5e
Console.logging batman
Jul 27, 2018
5d3fb0b
Trying to restrict user routes.
Jul 27, 2018
f0b3074
Just some minor comment changes.
Jul 27, 2018
c041b4e
Will GET from notes'/' only display current user's notes?
Jul 27, 2018
8e7c6d0
I only want to display notes of current user.
Jul 27, 2018
c6b2c01
Still trying to only display current user's notes.
Jul 27, 2018
956b316
Please work this time...
Jul 27, 2018
f071ec0
GET request on notes successfully only displays current user's notes.
Jul 27, 2018
3d419a5
a;sldkmfa;lsidjf;lasdjfa;ls
Jul 29, 2018
c8d0f27
Added restricted routes to more methods. Commented on changes desired…
Jul 29, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
node_modules
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node index.js
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
My Trello: https://trello.com/b/pYlW6ToH/lambda-notes-backend


My Heroku URL: https://dashboard.heroku.com/apps/back-end-week


## Trello Set Up:
* [X] Use your existing Trello account from the Front End Project, or create a new one
* [X] Create a new board called "Lambda Notes(Backend) - {Your Name}"
* [X] Create lists titled `backlog`,`To Do`, `In Progress`, and `Done`
* [X] Fill in the `To Do` list with the MVP features listed below
* [X] Fill in the `backlog` list with all the extra features listed below
* [X] Share your board with the project manager that has been assigned to you. If you have not been assigned yet, reach out to your Section Lead for guidance
* [X] Add your Trello URL to your project's README.md file. Commit the change, push it to your repository & submit a pull request

## Backend MVP Features:
* [X] Create a Database for your app
* [X] Design your models for your app. You should have a model for notes and for users. (The users model will come in handy when building out your stretch goals).
* [X] Deploy your application to the web
* [X] Create a Node app and connect it to your database
* [X] Store Notes in your Database

Build an API Endpoint in your Node App for each of the following, and connect them to your React App. These should all be read from your Database and scoped to the logged in user.
* [X] Display a list of notes
* [X] Create a note with a title and content
* [X] View an existing note
* [X] Edit an existing note
* [ ] Delete an existing note
* [ ] Link up your Front End Project to your new and improved backend

# Back End Project Week
This week you will be building a backend for a note taking app called "Lambda Notes."

Expand Down Expand Up @@ -87,4 +117,4 @@ Once your MVP has been approved, you have been given a feature list that the cli
* [ ] Add a payment form integrating with Stripe that allows Users to buy a "Premium" version of LambdaNotes.
* [ ] Gate your favorite feature behind the premium paywall

You will notice that this repository does not have any starter code. This is on purpose. You are to start from scratch using any files you have built throughout your time here at Lambda School.
You will notice that this repository does not have any starter code. This is on purpose. You are to start from scratch using any files you have built throughout your time here at Lambda School.
25 changes: 25 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// require('dotenv').config();
const PORT = process.env.PORT || 5000;
const mongoose = require('mongoose');
const server = require('./server')

const options = {
user: process.env.DB_USER,
pass: process.env.DB_PASS,
useNewUrlParser: true
}

mongoose
//.connect(process.env.DB_HOST, options)
.connect('mongodb://SeanValdivia:[email protected]:41671/lambda-notes-sean')
.then(() => {
console.log('Connected to mongodb!!')
server.listen(PORT, () => {
console.log(`Listening on ${PORT}`)
})
})
.catch(err => {
console.log(err);
})


24 changes: 24 additions & 0 deletions models/Note.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const mongoose = require('mongoose');
const { Schema } = mongoose;

const note = {
title: {
type: String,
required: true,
maxlength: 15
},
content: {
type: String,
required: true,
maxlength: 100
},
postedBy: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
}

const options = {
timestamps: true,
}

const noteSchema = new mongoose.Schema(note, options);

module.exports = mongoose.model('Note', noteSchema);
39 changes: 39 additions & 0 deletions models/User.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const mongoose = require('mongoose');
const bcrypt = require('bcryptjs');


const User = new mongoose.Schema({
email: {
type: String,
required: true,
unique: true
},
username: {
type: String,
required: true,
unique: true
},
password: {
type: String,
required: true,
minlength: 8
},
notes: [{type: mongoose.Schema.ObjectId, ref: 'Note'}]
})

User.pre('save', function (next) {
bcrypt.hash(this.password, 11, (err, hash) => {
if (err) {
return next(err)
} else {
this.password = hash;
return next()
}
})
})

User.methods.validatePassword = function (passAttempt) {
return bcrypt.compare(passAttempt, this.password);
};

module.exports = mongoose.model('User', User)
Loading