GithubHelp home page GithubHelp logo

raasahsan / rust-realworld-example-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from derickwarshaw/rust-realworld-example-app

0.0 1.0 0.0 399 KB

Example Rust codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld API spec.

Batchfile 0.88% Rust 97.57% Shell 0.32% PLpgSQL 1.18% RenderScript 0.04%

rust-realworld-example-app's Introduction

RealWorld Example App

Build status

Rust/Diesel codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This codebase was created to demonstrate a fully fledged fullstack application built with Rust fast HTTP implementation Hyper in including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the Rust community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

How it works

This is an application written in Rust using these crates:

  • Hyper - a fast HTTP implementation written in and for Rust
  • Serde - a framework for serializing and deserializing Rust data structures efficiently and generically
  • Reroute - A router for Rust's hyper framework using regular expressions
  • IIS - Set of helper functions for running web server written in Rust on Internet Information Services (IIS)
  • Diesel - Safe, Extensible ORM and Query Builder for Rust

Getting started

  • Install Rust: https://www.rustup.rs/
  • Get Diesel and Diesel supported database.
  • Create database.
  • Copy conduit - sample.toml to conduit.toml and set your connection string in DATABASE_URL there.
  • Also use .env and run echo DATABASE_URL=<DATABASE_URL from conduit.toml> > .env (your .env file in the project directory should look like DATABASE_URL=postgres://postgres:Pass123@localhost/conduit then)
  • Run diesel setup --database-url='<DATABASE_URL from conduit.toml>' script to create the database structure and all the tables, functions etc.
  • Build with cargo build.
  • Run with cargo run.
  • API URL: http://localhost:6767, to test the requests you can you e.g. Advanced REST Client.

Step by step installation on Windows

  • install chocolatey
  • install CMake choco install cmake (administrative cmd needed)
  • install Microsoft Visual C++ Build Tools 2015 choco install vcbuildtools (administrative cmd needed; not possible if Visual Studio 2015 already installed, in that case but check if C++ is installed: File -> New project -> Visual C++ -> Install Visual C++ 2015 Tools for Windows Desktop)
  • install Rust, you are good to go with stable (or nightly) and msvc
  • install PostgreSQL; skip Stack Builder if you do not need to install anything else
  • use pgAdmin 4 from C:\Program Files\PostgreSQL\10\pgAdmin 4\bin to connect to the server (username postgres, password from the previous step)
  • go to Servers -> PostgreSQL 10 -> Databases and create a new database conduit
  • set environment variable PQ_LIB_DIR to C:\Program Files\PostgreSQL\10\libdir (you need to call refreshenv in the opened cmd then)
  • Add C:\Program Files\PostgreSQL\10\bin to PATH (in the same windows as you set the environment variable; call refreshenv again)
  • follow the steps from the Getting started sections, install diesel with cargo install diesel_cli --no-default-features --features postgres
  • when running diesel setup, do not use the singe quotes, it needs to look like e.g. diesel setup --database-url=postgres://postgres:Password123@localhost/conduit

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.