Code Monkey home page Code Monkey logo

bibliofile-api's Introduction

Bibliofile: A RESTful API written in Rocket for book collectors

I'm using this project to learn more about Rocket, a Rust web framework written by Sergio Benitez, and Diesel, an ORM & Query Builder by Sean Griffin.

The Rust blog tutorial series by Ryan Blecher forms the basis of the code for this project, although I have adapted it to work with a Sqlite database (as opposed to Postgres).

The code is currently up to date with Part II of the tutorial series.

The goal is to implement a RESTful API for cataloging one's book collection. The API will operate on CRUD (Create, Read, Update, Delete) principles.

HTTP Method URI Action
GET http://[hostname]/api/v1.0/books Retrieve list of books
GET http://[hostname]/api/v1.0/books/[isbn] Retrieve a book
POST http://[hostname]/api/v1.0/books Create a book
PUT http://[hostname]/api/v1.0/books/[isbn] Update an existing book
DELETE http://[hostname]/api/v1.0/books/[isbn] Delete a book

Setup Instructions

  1. Clone the repo and change into it

git clone https://github.com/mycognosist/bibliofile-api.git && cd bibliofile-api

  1. Set environment variable (may not be necessary)

source $HOME/.cargo/env

  1. Install diesel_cli

cargo install diesel_cli --no-default-features --features sqlite

  1. Create .env and add db url

vim .env DATABASE_URL=/path/to/your/database.db

  1. Setup diesel (creates migrations folder)

diesel setup

  1. Create migrations

diesel migration generate create_users_and_books

  1. Define db schemas

vim migrations/...create_users_and_books/up.sql vim migrations/...create_users_and_books/down.sql

  1. Run migrations

diesel migration run

  1. Seed the database (optional)

cargo run --bin seed

bibliofile-api's People

Contributors

mycognosist avatar

Stargazers

 avatar

Watchers

 avatar

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.