-
Notifications
You must be signed in to change notification settings - Fork 446
Kyle Baker #485
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
Open
kybak
wants to merge
11
commits into
bloominstituteoftechnology:master
Choose a base branch
from
kybak:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Kyle Baker #485
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
85ceedb
added trello link to readme
06a46fa
bootstrapped
9640085
data model
76da544
note helpers
6babb4c
routes
ccd8c6d
gitignore
914478c
tag helper bugs
5f8aadc
authentication
kybak d2a55ba
authentication
fbf88d3
seeding
kybak 2cd1374
minor changes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| .DS_Store | ||
| .idea/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| const knex = require('knex'); | ||
| const knexConfig = require('../knexfile.js'); | ||
|
|
||
| module.exports = knex(knexConfig.development); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| module.exports = { | ||
| intToBoolean, | ||
| booleanToint, | ||
| projectToBody, | ||
| actionToBody, | ||
| }; | ||
|
|
||
| function intToBoolean(int) { | ||
| return int === 1 ? true : false; | ||
| } | ||
|
|
||
| function booleanToint(bool) { | ||
| return bool === true ? 1 : 0; | ||
| } | ||
|
|
||
| function projectToBody(project) { | ||
| const result = { | ||
| ...project, | ||
| completed: intToBoolean(project.completed), | ||
| }; | ||
|
|
||
| if (project.actions) { | ||
| result.actions = project.actions.map(action => ({ | ||
| ...action, | ||
| completed: intToBoolean(action.completed), | ||
| })); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| function actionToBody(action) { | ||
| return { | ||
| ...action, | ||
| completed: intToBoolean(action.completed), | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| const db = require('../dbConfig.js'); | ||
| const mappers = require('./mappers'); | ||
|
|
||
| module.exports = { | ||
| get: function(id) { | ||
| let query = db('notes as n'); | ||
|
|
||
| if (id) { | ||
| query.where('n.id', id).first(); | ||
|
|
||
| const promises = [query, this.getProjectActions(id)]; // [ projects, actions ] | ||
|
|
||
| return Promise.all(promises).then(function(results) { | ||
| let [project, actions] = results; | ||
| project.actions = actions; | ||
|
|
||
| return mappers.projectToBody(project); | ||
| }); | ||
| } | ||
|
|
||
| return query.then(projects => { | ||
| return projects.map(project => mappers.projectToBody(project)); | ||
| }); | ||
| }, | ||
| /*getProjectActions: function(projectId) { | ||
| return db('actions') | ||
| .where('project_id', projectId) | ||
| .then(actions => actions.map(action => mappers.actionToBody(action))); | ||
| },*/ | ||
| insert: function(note) { | ||
| return db('notes') | ||
| .insert(note) | ||
| .then(([id]) => this.get(id)); | ||
| }, | ||
| update: function(id, changes) { | ||
| return db('notes') | ||
| .where('id', id) | ||
| .update(changes) | ||
| .then(count => (count > 0 ? this.get(id) : null)); | ||
| }, | ||
| remove: function(id) { | ||
| return db('notes') | ||
| .where('id', id) | ||
| .del(); | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
|
|
||
| exports.up = function(knex, Promise) { | ||
|
|
||
| }; | ||
|
|
||
| exports.down = function(knex, Promise) { | ||
|
|
||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| exports.seed = function(knex, Promise) { | ||
| return knex('notes') | ||
| .del() | ||
| .then(function() { | ||
| return knex('notes').insert([ | ||
| { | ||
| name: 'Complete Node.js and Express Challenge', | ||
| description: | ||
| 'Build and Awesome API Using Node.js and Express to Manage Projects and Actions GTD Style!', | ||
| }, | ||
| ]); | ||
| }); | ||
| }; | ||
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| const express = require('express'), | ||
| bodyParser = require('body-parser'), | ||
| notes = require('./api/notes'); | ||
|
|
||
| const app = express(); | ||
|
|
||
| app | ||
| .use(bodyParser.json()) | ||
| .use('/notes', notes) | ||
|
|
||
|
|
||
| app.listen(5000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| module.exports = { | ||
| development: { | ||
| client: 'sqlite3', | ||
| connection: { filename: './data/lambda.sqlite3' }, | ||
| useNullAsDefault: true, | ||
| migrations: { | ||
| directory: './data/migrations', | ||
| tableName: 'dbmigrations', | ||
| }, | ||
| seeds: { directory: './data/seeds' }, | ||
| }, | ||
| }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to have the
> 0