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
98 changes: 98 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# gatsby files
.cache/
public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/
8 changes: 4 additions & 4 deletions api/server.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const express = require('express')
const server = express()
const cors = require('cors');
const helmet = require('helmet')

const server = express()
server.use(helmet())
server.use(cors())
server.use(express.json())

const usersRouter = require('../users/users-route')
const itemsRouter = require('../items/items-route')
const categoriesRouter = require('../categories/categories-route')

server.use(helmet())
server.use(cors())
server.use(express.json())

server.use('/auth', usersRouter)
server.use('/api', itemsRouter)
Expand Down
3 changes: 3 additions & 0 deletions client/package-lock.json

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

5 changes: 2 additions & 3 deletions database/db-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const knex = require('knex');
const knexConfig = require('../knexfile.js');

const knexConfig = require('../knexfile.js')

const dbEnv = process.env.DB_ENV || 'development'
const dbEnv = process.env.DB_ENV || 'development';

module.exports = knex(knexConfig[dbEnv]);
20 changes: 0 additions & 20 deletions database/migrations/20190923181643_users.js

This file was deleted.

20 changes: 0 additions & 20 deletions database/migrations/20190923181715_categories.js

This file was deleted.

43 changes: 0 additions & 43 deletions database/migrations/20190923181732_list-items.js

This file was deleted.

8 changes: 0 additions & 8 deletions database/migrations/20190923181916_create-accounts.js

This file was deleted.

21 changes: 21 additions & 0 deletions database/migrations/20190926152549_users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
exports.up = function(knex) {
    return knex.schema.createTable('users', tbl => {
          tbl.increments(); 

          tbl
              .text('username', 255)
              .notNullable()
              .unique();
          tbl
              .text('password', 255)
              .notNullable();
    })

};

exports.down = function(knex) {
    return knex.schema.dropTableIfExists('users')
};



21 changes: 21 additions & 0 deletions database/migrations/20190926152605_categories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
exports.up = function(knex) {
    return knex.schema
    .createTable('categories', tbl => {
        tbl.increments();

        tbl
            .text('category_name')
            .notNullable()
    })


};

exports.down = function(knex) {
    return knex.schema
        // .dropTableIfExists('users_categories')
        .dropTableIfExists('categories')
};



39 changes: 39 additions & 0 deletions database/migrations/20190926152611_items.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
exports.up = function(knex) {
  return knex.schema
    .createTable('items', tbl => {
        tbl.increments();

        tbl
            .text('item_name')
            .notNullable()
        tbl
            .text('description')
        tbl
            .integer('user_id')
            .unsigned()
            .notNullable()
            .references('id')
            .inTable('users')
            .onDelete('CASCADE')
            .onUpdate('CASCADE')
        tbl
            .integer('category_id')
            .unsigned()
            .notNullable()
            .references('id')
            .inTable('categories')
            .onDelete('CASCADE')
            .onUpdate('CASCADE')
        tbl
            .boolean('completed')
            .defaultTo(false)

        tbl
            .text('links')
    })
};

exports.down = function(knex) {
    return knex.schema.dropTableIfExists('items')
};

8 changes: 8 additions & 0 deletions database/seeds/00-cleanup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const cleaner = require('knex-cleaner');

exports.seed = function (knex) {
return cleaner.clean(knex, {
mode: 'truncate',
ignoreTables: ['knex_migrations', 'knex_migrations_lock'],
});
};
28 changes: 14 additions & 14 deletions database/seeds/01-users.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const bcrypt = require ("bcryptjs")
exports.seed = function(knex) {
// Deletes ALL existing entries
return knex('users')
.del()
.then(function () {
// Inserts seed entries
return knex('users').insert([
{username: 'Admin', password: 'Testing1'},
{username: 'FrontEnd', password: 'Testing1'},
{username: 'Marketing', password: 'Testing1'}
]);
});
};
exports.seed = function(knex) {
  // Deletes ALL existing entries
  return knex('users')
    .truncate()
    .then(function () {
      // Inserts seed entries
      return knex('users').insert([
        {username: 'Admin', password: 'Testing1'},
        {username: 'FrontEnd', password: 'Testing1'},
        {username: 'Marketing', password: 'Testing1'}
      ]);
    });
};
31 changes: 16 additions & 15 deletions database/seeds/02-categories.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
exports.seed = function(knex) {
// Deletes ALL existing entries
return knex('categories')
.del()
.then(function () {
// Inserts seed entries
return knex('categories').insert([
{category_name: 'Health & Fitness'},
{category_name: 'Travel'},
{category_name: 'Adventure'},
{category_name: 'Education'},
{category_name: 'Adrenaline'}
]);
});
};
exports.seed = function(knex) {
  // Deletes ALL existing entries
  return knex('categories')
    .truncate()
    .then(function () {
      // Inserts seed entries
      return knex('categories').insert([
        {category_name: 'Health & Fitness'},
        {category_name: 'Travel'},
        {category_name: 'Adventure'},
        {category_name: 'Education'},
        {category_name: 'Adrenaline'}
      ]);
    });
};

Loading