Skip to content

Commit

Permalink
docker_v1
Browse files Browse the repository at this point in the history
  • Loading branch information
nam0107 committed Aug 20, 2019
1 parent eab7939 commit ecc0d28
Show file tree
Hide file tree
Showing 226 changed files with 1,699 additions and 1,179 deletions.
2 changes: 1 addition & 1 deletion .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@


/node_modules
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:8

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package*.json ./


# Copy app source code
COPY . .

# Expose port and start application
EXPOSE 3000
CMD [ "npm", "start" ]

RUN chmod +x startup.sh
RUN npm install -g nodemon
190 changes: 95 additions & 95 deletions api/controllers/bookControllers.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
const sequelize = require('sequelize');
const multer = require('multer'); // up file

const Book = require('../../models').Book;
const Catalog = require('../../models').Catalog;
const User = require('../../models').User;
const Love = require('../../models').Love;

// get all book
exports.getAllBook = function (req, res){
Book.findAll({raw: true}).then(arrBook => {
res.json(arrBook)
})
};

// get a book
exports.getBook = function(req, res){
Book.findOne({
where: {
id: req.params.book_id
},
raw: true
}).then(book => res.json(book))
};

// create a book
exports.createBook = function(req, res){
console.log(req.file);
Book.create({
book_name: req.body.book_name,
author: req.body.author,
price: req.body.price,
description: req.body.description,
image: req.file.path,
quatity: req.body.quatity,
catalog_id: req.body.catalog_id
}).then(book => res.json(book))
};

// get all book by catalog_id
exports.getBookByCatalogId = function(req, res){
Book.findAll({
where: {
catalog_id: req.params.catalog_id
},
raw: true
}).then(arrBook => res.json(arrBook))
};

// search book
exports.searchBook = function(req, res){
Book.findAll({
include: [Catalog],
raw: true
}).then(arrBook => res.json(arrBook))
};

//update book
exports.updateBook = function(req, res){
Book.update({
book_name: req.body.book_name,
author: req.body.author,
price: req.body.price,
description: req.body.description,
image: req.file.path,
quatity: req.body.quatity,
catalog_id: req.body.catalog_id
},
{
where:{
book_id: req.params.book_id
}
}).then(row => console.log(row))
};

// get bookLove of user
exports.getBookLove = function(req, res){
Love.findAll({
where: {
user_id: req.params.user_id
},
include: [Book],
raw: true
}).then(arrBook => {
let books = [];
for(var i=0; i<arrBook.length; i++){
var b = {
user_id : arrBook[i].user_id,
book_id: arrBook[i].book_id,
book_name: arrBook[i]["Book.book_name"]
};
books.push(b);
}
res.json(arrBook);
})
const sequelize = require('sequelize');
const multer = require('multer'); // up file

const Book = require('../../models').Book;
const Catalog = require('../../models').Catalog;
const User = require('../../models').User;
const Love = require('../../models').Love;

// get all book
exports.getAllBook = function (req, res){
Book.findAll({raw: true}).then(arrBook => {
res.json(arrBook)
})
};

// get a book
exports.getBook = function(req, res){
Book.findOne({
where: {
id: req.params.book_id
},
raw: true
}).then(book => res.json(book))
};

// create a book
exports.createBook = function(req, res){
console.log(req.file);
Book.create({
book_name: req.body.book_name,
author: req.body.author,
price: req.body.price,
description: req.body.description,
image: req.file.path,
quatity: req.body.quatity,
catalog_id: req.body.catalog_id
}).then(book => res.json(book))
};

// get all book by catalog_id
exports.getBookByCatalogId = function(req, res){
Book.findAll({
where: {
catalog_id: req.params.catalog_id
},
raw: true
}).then(arrBook => res.json(arrBook))
};

// search book
exports.searchBook = function(req, res){
Book.findAll({
include: [Catalog],
raw: true
}).then(arrBook => res.json(arrBook))
};

//update book
exports.updateBook = function(req, res){
Book.update({
book_name: req.body.book_name,
author: req.body.author,
price: req.body.price,
description: req.body.description,
image: req.file.path,
quatity: req.body.quatity,
catalog_id: req.body.catalog_id
},
{
where:{
book_id: req.params.book_id
}
}).then(row => console.log(row))
};

// get bookLove of user
exports.getBookLove = function(req, res){
Love.findAll({
where: {
user_id: req.params.user_id
},
include: [Book],
raw: true
}).then(arrBook => {
let books = [];
for(var i=0; i<arrBook.length; i++){
var b = {
user_id : arrBook[i].user_id,
book_id: arrBook[i].book_id,
book_name: arrBook[i]["Book.book_name"]
};
books.push(b);
}
res.json(arrBook);
})
};
42 changes: 21 additions & 21 deletions api/controllers/commentControllers.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
const sequelize = require('sequelize');
const Comment = require('../../models').Comment;


// get all comment by book id
exports.getAllComment = function(req, res){
Comment.findAll({
where: {book_id: req.params.book_id},
raw: true
}).then(comments => res.json(comments))
};

// get comment by cmt_id and book_id
exports.getComment = function(req, res){
Comment.findOne({
where: {
book_id: req.params.book_id,
id: req.params.cmt_id
},
raw: true
}).then(comment => res.json(comment))
const sequelize = require('sequelize');
const Comment = require('../../models').Comment;


// get all comment by book id
exports.getAllComment = function(req, res){
Comment.findAll({
where: {book_id: req.params.book_id},
raw: true
}).then(comments => res.json(comments))
};

// get comment by cmt_id and book_id
exports.getComment = function(req, res){
Comment.findOne({
where: {
book_id: req.params.book_id,
id: req.params.cmt_id
},
raw: true
}).then(comment => res.json(comment))
};
Loading

0 comments on commit ecc0d28

Please sign in to comment.