-
Notifications
You must be signed in to change notification settings - Fork 23
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
117 changed files
with
21,705 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"presets": ["env", "react"], | ||
"plugins": ["transform-object-rest-spread"], | ||
"env": { | ||
"production": { | ||
"plugins": [ | ||
"transform-react-remove-prop-types", | ||
"transform-react-constant-elements", | ||
"transform-react-inline-elements" | ||
] | ||
} | ||
} | ||
} |
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,14 @@ | ||
engines: | ||
duplication: | ||
enabled: false | ||
config: | ||
languages: | ||
javascript: | ||
mass_threshold: 20 | ||
ratings: | ||
paths: | ||
- "**.js" | ||
exclude_paths: | ||
- "test/" | ||
- "node_modules/" | ||
- "templates/" |
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 @@ | ||
repo_token: COVERALLS_REPO_TOKEN |
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,2 @@ | ||
/server/test | ||
/dist |
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,51 @@ | ||
{ | ||
"root": true, | ||
"extends": ["airbnb-base", "plugin:react/recommended"], | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
"es6": true, | ||
"mocha": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"ecmaFeatures": { "jsx": true } | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"node": { | ||
"extensions": [".js",".jsx"] | ||
} | ||
} | ||
}, | ||
"rules": { | ||
"one-var": 0, | ||
"one-var-declaration-per-line": 0, | ||
"new-cap": 0, | ||
"consistent-return": 0, | ||
"no-param-reassign": 0, | ||
"comma-dangle": 0, | ||
"max-len": [1, 80, 2], | ||
"import/prefer-default-export": 0, | ||
"curly": ["error", "multi-line"], | ||
"import/no-unresolved": [2, { "commonjs": true }], | ||
"import/extensions": "off", | ||
"no-shadow": ["error", { "allow": ["req", "res", "err"] }], | ||
"react/jsx-uses-react": "error", | ||
"react/jsx-uses-vars": "error", | ||
"valid-jsdoc": ["error", { | ||
"requireReturn": true, | ||
"requireReturnType": true, | ||
"requireParamDescription": false, | ||
"requireReturnDescription": true | ||
}], | ||
"class-methods-use-this": 0, | ||
"require-jsdoc": ["error", { | ||
"require": { | ||
"FunctionDeclaration": true, | ||
"MethodDefinition": true, | ||
"ClassDeclaration": true | ||
} | ||
}] | ||
} | ||
} |
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,27 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
/.nyc_output | ||
|
||
# production | ||
/build | ||
/dist | ||
|
||
# misc | ||
.DS_Store | ||
/config/db.js | ||
.env | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
/job | ||
*.txt | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
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,5 @@ | ||
eslint: | ||
enabled: true | ||
config_file: .eslintrc | ||
ignore_file: .eslintignore | ||
|
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,8 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
"config": path.resolve('./server/config', 'config.js'), | ||
"models-path": path.resolve('./server/models'), | ||
"seeders-path": path.resolve('./server/seeders'), | ||
"migrations-path": path.resolve('./server/migrations') | ||
}; |
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,10 @@ | ||
language: node_js | ||
node_js: | ||
- "6" | ||
env: | ||
global: | ||
- export NODE_ENV=test | ||
script: | ||
- npm test | ||
after_success: | ||
- npm run coverage |
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 @@ | ||
web: node dist/server/bin/www.js |
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,63 @@ | ||
[![Build Status](https://travis-ci.org/segunolalive/helloBooks.svg?branch=master)](https://travis-ci.org/segunolalive/helloBooks) | ||
[![Coverage Status](https://coveralls.io/repos/github/segunolalive/helloBooks/badge.svg?branch=master)](https://coveralls.io/github/segunolalive/helloBooks?branch=master) | ||
[![Code Climate](https://codeclimate.com/github/segunolalive/helloBooks/badges/gpa.svg)](https://codeclimate.com/github/segunolalive/helloBooks?branch=master) | ||
|
||
# helloBooks | ||
|
||
### A Library app | ||
Hello books is an application that provides users with access to books from wherever they are. | ||
Beeing a virtual library, users can borrow and read their favorite books using any device. | ||
HelloBooks exposes RESTful API endpoints such that anyone customize the method of consuming | ||
the resources. | ||
|
||
### Development | ||
This is a javascript application built with [**Express**](http://expressjs.com/) | ||
framework on the nodejs platform. Authentication of users is done via | ||
[**JSON Web Tokens**](https://jwt.io/) . | ||
|
||
#### Features | ||
- Login/Sign up to gain access to routes | ||
- A library of books from different categories | ||
- Ability to borrow books repeatedly | ||
- Track your reading/borrowing history | ||
- Admin access to modify book details | ||
|
||
#### API Routes | ||
- sign up route: | ||
**POST** /api/v1/users/signup | ||
parameters - username, password, email | ||
optional parameters - firstName, lastName | ||
|
||
|
||
- login route: | ||
**POST** /api/v1/users/signin | ||
parameters - username, password | ||
|
||
- get books (view library): | ||
**GET** /api/v1/books' | ||
|
||
- get book (view a book's metadata): | ||
**GET** /api/v1/books/:id | ||
parameters - bookId (number) | ||
|
||
- add a new book to library: | ||
**POST** /api/v1/books | ||
request body - authors, title, description, cover, bookfile, total | ||
|
||
- modify book information: | ||
**PUT** /api/v1/books/ | ||
request body - authors, title, description, cover, bookfile, total (any) | ||
query parameters - book id (number) | ||
|
||
- borrow book: | ||
**POST** /api/v1/users/:id/books | ||
parameters - user id | ||
query parameters - book id (number) | ||
|
||
- return book: | ||
**PUT** /api/v1/users/:id/books | ||
parameters - user id | ||
query parameters - book id (number) | ||
|
||
- get borrowed books: | ||
**GET** /api/v1/users/:id/books |
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,27 @@ | ||
{ | ||
"name": "helloBooks", | ||
"scripts": {}, | ||
"env": { | ||
"DATABASE_URL": { | ||
"required": true | ||
}, | ||
"NODE_ENV": { | ||
"required": true | ||
}, | ||
"NODE_MODULES_CACHE": { | ||
"required": true | ||
}, | ||
"SECRET": { | ||
"required": true | ||
} | ||
}, | ||
"formation": {}, | ||
"addons": [ | ||
"papertrail" | ||
], | ||
"buildpacks": [ | ||
{ | ||
"url": "heroku/nodejs" | ||
} | ||
] | ||
} |
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,39 @@ | ||
import keyMirror from './keyMirror'; | ||
/** | ||
* array of action types | ||
* @type {Array} | ||
*/ | ||
const actionList = [ | ||
'AUTH_LOADING', | ||
'SIGN_UP', | ||
'LOGIN', | ||
'LOGOUT', | ||
'SET_LOGIN_STATUS', | ||
'UPDATE_PROFILE', | ||
'SET_BOOK_ID', | ||
'GET_BOOK', | ||
'GET_BOOKS', | ||
'GET_BORROWED_BOOKS', | ||
'GET_TRANSACTION_HISTORY', | ||
'GET_ALL_BORROWED', | ||
'GET_BOOK_CATEGORIES', | ||
'BORROW_BOOK', | ||
'RETURN_BOOK', | ||
'CREATE_BOOK', | ||
'READ_BOOK', | ||
'EDIT_BOOK_INFO', | ||
'DELETE_BOOK', | ||
'UPLOAD_BOOK_FILE', | ||
'UPLOAD_BOOK_COVER', | ||
'SAVE_STATE', | ||
'GET_SAVED_STATE', | ||
'GET_ADMIN_NOTIFICATIONS', | ||
]; | ||
|
||
/** | ||
* action types object | ||
* @type {Object} | ||
*/ | ||
const actionTypes = keyMirror(actionList); | ||
|
||
export default actionTypes; |
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,110 @@ | ||
import axios from 'axios'; | ||
import actionTypes from '../actions/actionTypes'; | ||
import API from './api'; | ||
|
||
const Materialize = window.Materialize; | ||
|
||
|
||
/** | ||
* @param {Object} book - book | ||
* @returns {Object} - Object containing action type and user | ||
*/ | ||
export const editBookAction = book => ({ | ||
type: actionTypes.EDIT_BOOK, | ||
book, | ||
}); | ||
|
||
|
||
/** | ||
* edit book Detail | ||
* @param {Integer} id book Id | ||
* @param {Object} data book data with with to update database | ||
* @return {Object} dispatches an action to the redux store | ||
*/ | ||
export const editBook = (id, data) => dispatch => ( | ||
axios.put(`${API}/books/${id}`, data) | ||
.then((response) => { | ||
Materialize.toast(response.data.message, 2500, 'teal darken-4'); | ||
}, (error) => { | ||
Materialize.toast(error.response.data.message, 2500, 'red darken-4'); | ||
}) | ||
.catch((error) => { | ||
Materialize.toast(error, 2500, 'red darken-4'); | ||
}) | ||
); | ||
|
||
|
||
/** | ||
* @param {Object} book - book | ||
* @returns {Object} - Object containing action type and book | ||
*/ | ||
export const addBookAction = book => ({ | ||
type: actionTypes.ADD_BOOK, | ||
book, | ||
}); | ||
|
||
|
||
/** | ||
* @param {Object} book - book | ||
* @returns {Object} - Object containing action type and book | ||
*/ | ||
export const setBookToEdit = book => ({ | ||
type: actionTypes.SET_BOOK_TO_EDIT, | ||
book, | ||
}); | ||
|
||
|
||
/** | ||
* get the book to edit | ||
* @param {Number} id book id | ||
* @return {Object} redux action | ||
*/ | ||
export const bookToEdit = id => dispatch => ( | ||
axios.get(`${API}/books/${id}`) | ||
.then((response) => { | ||
dispatch(setBookToEdit(response.data.data)); | ||
}, (error) => { | ||
Materialize.toast(error.response.data.message, 2500, 'red darken-4'); | ||
}) | ||
.catch((error) => { | ||
Materialize.toast(error, 2500, 'red darken-4'); | ||
}) | ||
); | ||
|
||
|
||
/** | ||
* add new book to database | ||
* @param {Object} data book data | ||
* @return {Object} dispatches an action to the redux store | ||
*/ | ||
export const addBook = data => dispatch => ( | ||
axios.post(`${API}/books`, data) | ||
.then((response) => { | ||
Materialize.toast(response.data.message, 2500, 'teal darken-4'); | ||
}, (error) => { | ||
Materialize.toast(error.response.data.message, 2500, 'red darken-4'); | ||
}) | ||
.catch((error) => { | ||
Materialize.toast(error, 2500, 'red darken-4'); | ||
}) | ||
); | ||
|
||
|
||
/** | ||
* het book Detail | ||
* @param {Object} category new book category | ||
* @return {Object} dispatches an action to the redux store | ||
*/ | ||
export const addBookCategory = category => dispatch => ( | ||
axios.post(`${API}/books/category`, { category }) | ||
.then((response) => { | ||
Materialize.toast(response.data.message, 2500, 'teal darken-4'); | ||
}, (error) => { | ||
Materialize.toast(error.response.data.message, 2500, 'red darken-4'); | ||
}) | ||
.catch(() => { | ||
Materialize.toast(`Something went wrong. Ensure you're not adding | ||
an existing category`, 2500, 'red darken-4' | ||
); | ||
}) | ||
); |
Oops, something went wrong.