Giter Club home page Giter Club logo

bikes's Introduction

DI

The following repository contains an small Rest API example with Rust language. It creates a CRUD for bikes The next image is a simple architecture diagram.

Dependencies

Diesel ORM:

cargo install diesel_cli --no-default-features --features postgres

Auto-reload:

cargo install systemfd cargo-watch

Running the Application

  1. Deploy the Postgres database
docker-compose up
  1. Diesel configuration:
export DATABASE_URL=postgres://di:di@localhost/di
diesel setup
diesel migration run
  1. Start the application: The following command runs the aplication and allows to reload it when you change something in the code. Please check the .env to verified the port in wich it will run the application.
systemfd --no-pid -s http::4000 -- cargo watch -x run

Usage

Get all bikes

curl --request GET \
  --url http://localhost:4000/bikes

Get a bike by id

curl --request GET \
  --url http://localhost:4000/bikes/1fdf0da9-1bfe-410e-b6ac-5a27b3cd1dc8

Create a bike

curl --request POST \
  --url http://localhost:4000/bikes \
  --header 'content-type: application/json' \
  --data '{
	"model": "MBT",
	"description": "This is a montain bike"
}
'

Update a bike

curl --request PUT \
  --url http://localhost:4000/bikes/1fdf0da9-1bfe-410e-b6ac-5a27b3cd1dc8 \
  --header 'content-type: application/json' \
  --data '{
  "model": "",
  "description": "",
  "created_at": "2020-07-07T02:06:24.028203",
  "updated_at": "2020-07-07T02:06:24.028220"
}'

Delete a bike

curl --request GET \
  --url http://localhost:4000/bikes/1fdf0da9-1bfe-410e-b6ac-5a27b3cd1dc8

bikes's People

Contributors

cristianchaparroa avatar

Watchers

 avatar  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.