Skip to content

Commit

Permalink
updates dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
luishrd committed Sep 3, 2019
1 parent 11479b6 commit e09fd69
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 86 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Use `Node.js` and `Express` to build an API that performs _CRUD_ operations on `

### Project Setup

- **Fork** and **Clone** this repository.
- import this repository into your account
- clone **your copy** of this repository.
- **CD into the folder** where you cloned the repository.
- Type `npm install` to download all dependencies.
- To start the server, type `npm run server` from the root folder (where the _package.json_ file is). The server is configured to restart automatically as you make changes.
Expand Down
8 changes: 5 additions & 3 deletions data/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function findById(id) {

function insert(post) {
return db('posts')
.insert(post)
.insert(post, 'id')
.then(ids => ({ id: ids[0] }));
}

Expand Down Expand Up @@ -54,5 +54,7 @@ function findCommentById(id) {
}

function insertComment(comment) {
return db('comments').insert(comment).then(ids => ({ id: ids[0] }));
}
return db('comments')
.insert(comment)
.then(ids => ({ id: ids[0] }));
}
28 changes: 14 additions & 14 deletions data/migrations/20190509175531_add_comments_table.js.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
exports.up = function(knex) {
return knex.schema.createTable('comments', tbl => {
tbl.increments();
tbl
.string('text')
.notNullable()
tbl.timestamps(true, true);
tbl.increments();

tbl
.integer('post_id')
.notNullable()
.unsigned()
.references('id')
.inTable('posts')
.onDelete('CASCADE')
.onUpdate('CASCADE');
});
tbl.string('text').notNullable();

tbl
.integer('post_id')
.unsigned()
.notNullable()
.references('id')
.inTable('posts')
.onDelete('CASCADE')
.onUpdate('CASCADE');

tbl.timestamps(true, true);
});
};

exports.down = function(knex) {
Expand Down
13 changes: 7 additions & 6 deletions knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ module.exports = {
client: 'sqlite3',
connection: { filename: './data/lambda.db3' },
useNullAsDefault: true,
migrations: {
directory: './data/migrations',
},
seeds: {
directory: './data/seeds',
},
pool: {
afterCreate: (conn, done) => {
conn.run('PRAGMA foreign_keys = ON', done);
}
},
migrations: {
directory: './data/migrations',
tableName: 'dbmigrations',
},
},
seeds: { directory: './data/seeds' },
},
};
116 changes: 58 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "webapi-ii-challenge",
"name": "node-api2-project",
"version": "0.0.1",
"description": "Challenge for Web API II Module",
"description": "Project for Node API 2 Module",
"private": true,
"main": "index.js",
"scripts": {
"server": "nodemon index.js"
},
"dependencies": {
"knex": "^0.18.3",
"sqlite3": "^4.0.9"
"knex": "^0.19.3",
"sqlite3": "^4.1.0"
},
"devDependencies": {
"nodemon": "^1.19.1"
Expand Down

0 comments on commit e09fd69

Please sign in to comment.