Skip to content

Commit c203f37

Browse files
authored
Merge pull request #4 from leachcoding/jay-leach
Jay leach
2 parents b702189 + 2e02a8e commit c203f37

File tree

11 files changed

+106
-6
lines changed

11 files changed

+106
-6
lines changed

api/server.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ const helmet = require('helmet');
55
const authenticate = require('../auth/authenticate-middleware.js');
66
const authRouter = require('../auth/auth-router.js');
77

8+
const berryRouter = require('../berries/berryRouter.js');
9+
const itemRouter = require('../items/itemRouter.js');
10+
const machineRouter = require('../machines/machineRouter.js');
11+
const pokemonRouter = require('../pokemon/pokemonRouter.js');
12+
813
const server = express();
914

1015
server.use(helmet());
@@ -15,6 +20,11 @@ server.get('/', (req, res) => {
1520
res.status(200).json({ test: "LISTENING" })
1621
})
1722

18-
server.use('/api/auth', authRouter);
23+
server.use('/api/auth', authRouter); // For the trainer
24+
25+
server.use('/api/berries', authenticate, berryRouter); // For the berries
26+
server.use('/api/items', authenticate, itemRouter); // For the items
27+
server.use('/api/machines', authenticate, machineRouter); // For the machines
28+
server.use('/api/pokemon', authenticate, pokemonRouter); // For the pokemon
1929

2030
module.exports = server;

berries/berryModel.js

Whitespace-only changes.

berries/berryRouter.js

Whitespace-only changes.
Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,88 @@
11
exports.up = function(knex) {
22
return knex.schema.createTable('users', tbl => {
3+
tbl.increments();
4+
tbl.string('username', 128).unique().notNullable();
5+
tbl.string('password', 256).notNullable();
6+
tbl.string('user_type');
7+
})
8+
9+
.createTable('items', tbl => {
10+
tbl.string('name').notNullable();
11+
tbl.integer('id');
12+
tbl.integer('cost');
13+
tbl.integer('user_id')
14+
.unsigned()
15+
.notNullable()
16+
references('id')
17+
.inTable('users')
18+
.onUpdate('CASCADE')
19+
.onDelete('RESTRICT');
20+
tbl.integer('total_count');
21+
tbl.integer('count').defaultTo(0);
22+
})
23+
24+
.createTable('machines', tbl => {
25+
tbl.string('name').notNullable();
26+
tbl.integer('id');
27+
tbl.integer('user_id')
28+
.unsigned()
29+
.notNullable()
30+
references('id')
31+
.inTable('users')
32+
.onUpdate('CASCADE')
33+
.onDelete('RESTRICT');
34+
tbl.integer('count').defaultTo(0);
35+
tbl.string('mega-punch').notNullable();
36+
})
37+
38+
.createTable('berries', tbl => {
39+
tbl.string('name').notNullable();
40+
tbl.integer('id');
41+
tbl.integer('user_id')
42+
.unsigned()
43+
.notNullable()
44+
references('id')
45+
.inTable('users')
46+
.onUpdate('CASCADE')
47+
.onDelete('RESTRICT');
48+
tbl.integer('size');
49+
tbl.integer('smoothness');
50+
tbl.integer('naturalGiftPower');
51+
tbl.integer('soilDryness');
52+
tbl.integer('growthTime');
53+
tbl.integer('maxHarvest');
54+
})
355

4-
tbl.increments();
5-
tbl.string('username', 128).unique().notNullable();
6-
tbl.string('password', 256).notNullable();
7-
tbl.string('user_type');
56+
.createTable('pokemon', tbl => {
57+
tbl.integer('id');
58+
tbl.string('name').notNullable();
59+
tbl.string('img').notNullable();
60+
tbl.integer('height');
61+
tbl.integer('weight');
62+
tbl.specificType('types', 'text ARRAY');
63+
tbl.integer('speed');
64+
tbl.integer('specialAttack');
65+
tbl.integer('specialDefense');
66+
tbl.integer('defense');
67+
tbl.integer('attack');
68+
tbl.integer('hp');
69+
tbl.specificType('abilities', 'text ARRAY');
70+
tbl.specificType('moves', 'text ARRAY');
71+
tbl.integer('user_id')
72+
.unsigned()
73+
.notNullable()
74+
references('id')
75+
.inTable('users')
76+
.onUpdate('CASCADE')
77+
.onDelete('RESTRICT');
878
})
979
};
1080

1181
exports.down = function(knex) {
1282
return knex.schema
83+
.dropTableIfExists('pokemon')
84+
.dropTableIfExists('berries')
85+
.dropTableIfExists('machines')
86+
.dropTableIfExists('items')
1387
.dropTableIfExists('users')
1488
};

database/seeds/05-pokemon.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@ exports.seed = function (knex) {
22
return knex('').truncate()
33
.then(function () {
44
return knex('').insert([
5-
{}
5+
{
6+
id: 1,
7+
name: 'bulbasaur',
8+
img: 'https://img.pokemondb.net/sprites/black-white/anim/normal/bulbasaur.gif',
9+
height: 7,
10+
weight: 69,
11+
types: ['poison', 'grass'],
12+
speed: 45,
13+
specialAttack: 65,
14+
specialDefense: 65,
15+
defense: 45,
16+
attack: 49,
17+
hp: 45,
18+
abilities: ['chlorophyll', 'overgrow'],
19+
moves: ['razor-wind', 'swords-dance', 'cut', 'bind'],
20+
user_id: 1
21+
}
622
]);
723
});
824
};

items/itemModel.js

Whitespace-only changes.

items/itemRouter.js

Whitespace-only changes.

machines/machineModel.js

Whitespace-only changes.

machines/machineRouter.js

Whitespace-only changes.

pokemon/pokemonModel.js

Whitespace-only changes.

pokemon/pokemonRouter.js

Whitespace-only changes.

0 commit comments

Comments
 (0)