-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,530 additions
and
639 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,28 @@ | ||
const Book = require("../models/book"); | ||
const TokenGenerator = require("../lib/token_generator"); | ||
|
||
const BookController = { | ||
Index: (req, res) => { | ||
Book.find((err, books) => { | ||
if (err) { | ||
throw err; | ||
} | ||
const token = TokenGenerator.jsonwebtoken(req.book_id) | ||
console.log("Generated Token:", token); | ||
res.status(200).json({ books: books, token: token }); | ||
}); | ||
}, | ||
Create: (req, res) => { | ||
const book = new Book(req.body); | ||
Book.save((err) => { | ||
if (err) { | ||
throw err; | ||
} | ||
|
||
const token = TokenGenerator.jsonwebtoken(req.book_id) | ||
res.status(201).json({ message: 'OK', token: token }); | ||
}); | ||
}, | ||
}; | ||
|
||
module.exports = BookController; |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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,22 @@ | ||
const mongoose = require("mongoose"); | ||
|
||
const BookSchema = new mongoose.Schema({ | ||
genre: { type: String, required: true }, | ||
author: { type: String, required: true }, | ||
title: { type: String, required: true }, | ||
year_published: { type: String, required: true }, | ||
// TODO: check type for year_published and session_id | ||
session: [ | ||
{ | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: "Session", | ||
}, | ||
], | ||
cover_photo: { type: String, required: false }, | ||
personal_rating: { type: String, required: false }, | ||
external_rating: { type: String, required: false }, | ||
}); | ||
|
||
const Book = mongoose.model("Book", BookSchema); | ||
|
||
module.exports = Book; |
This file contains 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,20 @@ | ||
const mongoose = require("mongoose"); | ||
|
||
const BookClubSchema = new mongoose.Schema({ | ||
books: [ | ||
{type: mongoose.Schema.Types.ObjectId, | ||
ref: "Book"} | ||
], | ||
users: [ | ||
{type: mongoose.Schema.Types.ObjectId, | ||
ref: "user"} | ||
], | ||
sessions: [ | ||
{type: mongoose.Schema.Types.ObjectId, | ||
ref: "session"} | ||
], | ||
}) | ||
|
||
const BookClub = mongoose.model("BookClub", BookClubSchema); | ||
|
||
module.exports = BookClub; |
This file was deleted.
Oops, something went wrong.
This file contains 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,16 @@ | ||
const mongoose = require("mongoose"); | ||
|
||
const SessionSchema = new mongoose.Schema({ | ||
date: { type: String, required: true }, | ||
location: { type: String, required: true }, | ||
users: [ | ||
{ | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: "User", | ||
}, | ||
], | ||
}); | ||
|
||
const Session = mongoose.model("Session", SessionSchema); | ||
|
||
module.exports = Session; |
This file contains 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
Oops, something went wrong.