Skip to content

A simple application that helps manage a library and its processes like stocking, tracking and renting books

License

Notifications You must be signed in to change notification settings

adesege/HelloBooks

Repository files navigation

Build Status Code Climate Test Coverage Coverage Status Issue Count

Hello-Books

A simple application that helps manage a library and its processes like stocking, tracking and renting books.

Built on Nodejs.

screen shot 2017-12-13 at 5 29 15 pm

How to install

Pre-requisites

You will need to have the following installed in your working environment before this application can work.

  • Latest version of Nodejs - comes with a Node Package Manager
  • Postgresql

Installing

  1. Download or clone this branch at https://github.com/adesege/HelloBooks.git
  2. Install dependencies by running npm install. Ensure you are in your working directory. Run cd /path/to/HelloBooks to change.
  3. Go to client directory and run npm run install to install dependencies.
  4. Go to the root dir cd ../
  5. Then type npm run transpile to transpile from es6 to es5
  6. and then run npm run start:dev in your terminal to start the server.
  7. To start the client, cd client
  8. Then npm run start

The server and client listens on port 5000 and 3000 by default respectively unless otherwise stated as an environment variable.

Visit http://localhost:3000 to access the front end and http://localhost:5000/api to access the api endpoint.

Authentication Mechanism

This application uses JSON web token to sign and verify users. The default expiration time is 24 hours but this can be modified in the application config.

Middlewares

Some endpoints are restricted to logged users and admins only. E.g. Only admin can access api/:versionNumber/books/stocks.

There are two middlewares defined in this application.

  • authMiddleware - verifies a user's token and checks if the user is valid.
  • adminMiddleware - checks if the user is admin.

Documentation

If Ruby is already installed, but the bundle command doesn't work, just run gem install bundler in a terminal.

Starting the server

  1. cd slate from the root directory.
  2. Initialize and start Slate. You can either do this locally, or with Vagrant:
    npm run slate:install
  # then
    npm run slate:build 
  # finally
    npm run slate:start
  # OR run this to run with vagrant
    vagrant up

Please visit the application documentation at http://hellobooks.herokuapp.com/docs/v1 or http://localhost:4567 to test locally

To deploy generated files into your application, run npm run slate:build

Testing

There are three different kind of testing in this application; client, server and end-to-end testing.

To start the server test. In your CMD, run

  npm run test

  # To get coverage result, run
  npm run test:coverage

To start the end-to-end test

# For the first time you are running it, 
# you'll need to install the selenium server and chrome driver.
# To do that, run
npm run test:e2e-install

# then start the server with
npm run test:e2e-server

# finally, run the test with
npm run test:e2e

Ensure that the server and client are up and running. The client must listen to port 3000. Otherwise, change it in nightwatch.conf:16

Finally, for the client test,

# first cd to the test folder
# then run
npm run test

# for coverage report, run
npm run test:coverage

Author

Temitayo Fadojutimi is a Software Developer at Andela and he dedicates his expertise to solving practical problems in the society. He tweets at @adesege_

Contributing Guide

Thank you for your interest in contributing to this package. I currently accept contributions from everyone but I expect that standards are maintained. To contribute,

  1. Fork the project
  2. Create a feature branch, branch away from master
  3. Write tests, using Mocha and Chai or any other testing frameworks, and code
  4. If you have multiple commits please combine them into a few logically organized commits by squashing them.
  5. Push the commit(s) to your fork
  6. Submit a merge request (MR) to the master branch
  7. The MR title should describe the change you want to make
  8. The MR description should give a motive for your change and the method you used to achieve it.
  9. Mention the issue(s) your merge request solves, using the Solves #XXX or Closes #XXX syntax to auto-close the issue(s) once the merge request will be merged.
  10. Be prepared to answer questions and incorporate feedback even if requests for this arrive weeks or months after your MR submission
  11. If a discussion has been addressed, select the "Resolve discussion" button beneath it to mark it resolved.
  12. When writing commit messages please follow these guidelines.

License

This project is licensed under the MIT license. Click here to read the license in full

About

A simple application that helps manage a library and its processes like stocking, tracking and renting books

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published