Giter VIP home page Giter VIP logo

book-library's Introduction

Book-Library

An Express.js API that interacts with a sequelize database via CRUD requests to store and interact with reader and book information.

Sequelize uses MySQL dialect for tests and Postgres for production.

Implements Test-Driven development using Mocha and Chai.

Created as part of the Manchester Codes full-stack web development boot-camp.

App hosted on Render at https://book-library-f9gi.onrender.com.

Table of Contents

  1. Dependencies
  2. Setup
  3. Commands
  4. Routes
  5. Attribution

Dependencies

Dev Dependencies

Setup

Install Dependencies

$ npm i

Database

If you have Docker installed, To set the database up, pull and run a MySQL image with:

$ docker run -d -p 3307:3306 --name book_library_mysql -e MYSQL_ROOT_PASSWORD=password mysql

Environment variables

You will need to create a file to store your environment variables. These credentials allow you to connect to the database. Two environments will need to be created, one for production and one for testing.

Create a .env file in the root of the repo with the following values:

DB_PASSWORD=password
DB_NAME=book_library
DB_USER=root
DB_HOST=localhost
DB_PORT=3307

Create a .env.test file in the root of the repo with the following values:

DB_PASSWORD=password
DB_NAME=book_library_dev
DB_USER=root
DB_HOST=localhost
DB_PORT=3307

Commands

To run the server use:

$ npm start

To run all tests use:

$ npm test

To only run unit tests use:

$ npm run unit-test

To run Prettier use:

$ npm run prettier

Routes

? In Schema represents optional field

/readers

Method Route Description Schema (JSON)
POST /readers Creates new reader
{
"name": STRING,
"email": STRING,
"password": STRING
}
GET /readers Returns all readers N/A
GET /readers/{readerId} Returns reader of specified ID N/A
PATCH /readers/{readerId} Updates reader with specified ID
{
"name"?: STRING,
"email"?: STRING,
"password"?: STRING
}
DELETE /readers/{readerId} Deletes reader with specified ID N/A

/books

Method Route Description Schema (JSON)
POST /books Creates new book
{
"title": STRING,
"ISBN"?: STRING,
"authorId": INTEGER,
"genreId"?: INTEGER
}
GET /books Returns all books and associated genres and authors N/A
GET /books/{bookId} Returns book of specified ID and associated genre and author N/A
PATCH /books/{bookId} Updates book with specified ID
{
"title"?: STRING,
"ISBN"?: STRING,
"authorId"?: INTEGER,
"genreId"?: INTEGER
}
DELETE /books/{bookId} Deletes book with specified ID N/A

/authors

Method Route Description Schema (JSON)
POST /authors Creates new author
{
"author": STRING
}
GET /authors Returns all authors and associated books and genres N/A
GET /authors/{authorId} Returns author of specified ID and associated books and genres N/A
PATCH /authors/{authorId} Updates author with specified ID
{
"author": STRING
}
DELETE /authors/{authorId} Deletes author with specified ID N/A

/genres

Method Route Description Schema (JSON)
POST /genres Creates new genre
{
"genre": STRING
}
GET /genres Returns all genres and associated books and authors N/A
GET /genres/{genreId} Returns genre of specified ID and associated books and authors N/A
PATCH /genres/{genreId} Updates genre with specified ID
{
"genre": STRING
}
DELETE /genres/{genreId} Deletes genre with specified ID N/A

Attribution

Created by Perry Baran.

book-library's People

Contributors

perrybaran avatar

Watchers

 avatar

Forkers

stuartcowley

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.