Coder Social home page Coder Social logo

realworld-warp's Introduction

Background

Realworld is "The Mother of all demo apps".
This project specifies a precise API description. Thus there are a large number of independent front-end implementations and back-end implementations. Any front-end can working with another set of back-ends.
On the other hand, Realworld defines a full-featured forum system. In order to achieve this exquisite small goal, a lot of practical technology needs to be applied. If the front-end and back-end solutions achieve this goal, and it is easy to verify the development potential in other Internet application topics.

Rust+Warp

This back-end implementation uses Rust language and Warp Web framework. The database system uses PostgreSQL through Diesel ORM.
Most of the program code comes from another Rust RealWorld implementation: Rust + Rocket.
I used to be a user of Rocket and Actix, but neither of them satisfied me. The former uses the Nightly version of Rust. It is also unstable when working, process lockup often. The latter has a large amount of memory usage for unknown reasons.
Finally, I moved to the Warp framework, at least until now, Warp's performance is very satisfying.

Difference with official specs

  • This implementation embed static file server, you can directly put front-end in to ./dist/ folder
  • Add upload function for some file exchange request
  • Addition command line tool

Install

  • Setup PostgreSQL database
  • Install PostgreSQL dev library (Include PostgeSQL in Linux version)

mac:

brew install libpq

ubuntu:

sudo apt install libpq-dev postgresql-server-dev-all
  • Run init.sql to create user and database in psql client:
sudo -u postgres psql -f init.sql 
CREATE USER realworld WITH PASSWORD 'realworld';
CREATE DATABASE realworld;
GRANT ALL PRIVILEGES ON DATABASE realworld TO realworld;
  • setting .env configure file in working root directory as sample below:
DATABASE_URL=postgres://realworld:[email protected]:6551/realworld
SECRET_KEY="8Xui8SN4mI+7egV/9dlfYYLGQJeEx4+DwmSQLwDVXJg="
WEB_URL="0.0.0.0:8000"
SERVER_NAME="RealWorld Server"
#RUST_LOG=info
#RUST_LOG=trace
RUST_LOG=debug
PUBLIC_BOARD=true

.env.txt file content is same as up, you directly rename as .env then edit as your wish

  • Run diesel setup database tables
# install diesel client
cargo install diesel_cli --no-default-features --features "postgres"
# setting up tables
diesel migration run
  • Copy Realworld front-end to ./dist/ folder, currently I put Vue version client here

run in debug mode

cargo run --bin realworld-warp

compile

cargo build --release

run

There will be 2 binary compiled:

  • realworld-warp is main program
  • realworld-cli is a command line tool help list user/article/follow, or delete them

You need run in the root path of project, because .env ./dist/ and some other dependency path location

./target/release/realworld-warp

Demo address

http://39.105.37.153:8000
(This is not a permenant server, so may not exist long)

other

Upload function and Static file holder need front-end cooperate, suggest use my vue version, it's a revisionary from Vue2 version RealWorld Frontend

realworld-warp's People

Contributors

formoon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

realworld-warp's Issues

Licence

Looks like a good starting point for my project, whats the licence for your code?

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.