GithubHelp home page GithubHelp logo

dontlaugh / rocket-yew-starter-pack Goto Github PK

View Code? Open in Web Editor NEW
83.0 1.0 11.0 98 KB

Example boilerplate for websites in pure Rust

License: MIT License

Rust 70.57% HTML 0.83% CSS 24.50% Shell 4.10%
yew example sled rust wasm rocket-rs

rocket-yew-starter-pack's Introduction

Note: this repository is archived. I sketched it out at the time because nothing like it existed and I wanted to scratch an itch. But now Yew has come a really long way, and keeping up with all the changes + maintaining a backend, however minimal, is just not something that interests me anymore. It's irresponsible for me to have this be a "most stars" hit when people search for Yew, when it will usually be busted and out of date. Better stuff exists. Start with the official docs

It can still serve as an example for what I'd consider to be a basic repo layout, but you'll have to rewrite most of the internals.

The front-end rust web development space is still evolving, but has already benefitted from the (frankly incredible) work of so many trailblazers.

The next version of this repo needs to be written by someone new, scratching their own itch. Go do radical shit.

Love, Coleman


Rocket/Yew Starter Pack

Rocket is a framework for building web servers in Rust, with a routing API that feels like Flask (Python). Yew is a front end framework for writing apps in Rust using cutting-edge (but well-supported) WebAssembly technologies, and with an API inspired by patterns from Elm and React.

This project adapts the todoMVC example from the yew repo, and periodically syncs local state with a backend Rocket server.

We also include some scripts to demonstrate building the ui and shipping it over to the server to serve as static assets.

Getting Started

Install rust with rustup. Since we build with --target=wasm32-unknown-unknown, and rely on other unstable features, you must use nightly rust.

rustup default nightly

Build both ui and server on your current platform

./build.sh

Or, build ui and copy the outputs over to server to run locally.

./run-local.sh

Or, build the Rocket server backend as a static binary, using Eric Kidd's Docker container.

./static-binary.sh  # calls server/.container-script.sh

Other Libraries

This project also uses:

  • stdweb and cargo-web - core library and tooling that make frameworks like yew possible. You can support koute on Patreon.
  • maud - html templating
  • sled - an embedded, ordered key-value store
  • bincode - binary encoding for rust types, so we can put stuff in a sled tree

rocket-yew-starter-pack's People

Contributors

anxiousmodernman avatar dontlaugh avatar

Stargazers

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

Watchers

 avatar

rocket-yew-starter-pack's Issues

Why no type safety between client and server?

Hi @anxiousmodernman, thanks for putting this together, this is very useful for people like me who are curious about full-stack web apps in Rust. I was just wondering why you haven't had the typechecker check your client's API consumption at compile time.

For example, the client side Entry (https://github.com/anxiousmodernman/rocket-yew-starter-pack/blob/master/ui/src/lib.rs#L45) seems to be a duplicate of the server side Task (https://github.com/anxiousmodernman/rocket-yew-starter-pack/blob/master/server/src/main.rs#L57).

The compiler doesn't know that Task should be the same as Server, or that /tasks is statically guaranteed to return a list of Tasks.

Would it make sense to factor out a subset of server into a common package that defines the routes and their request and response types, and add it to both client's and server's cargo.toml?

Making this repository a Template

On Github you can make a repository a template by going to Settings > "Template Repository"

This way people could easy use your repository to start their own!

Upgrade yew/stdweb

Update 16 March 2018: We're broken! Let's pin stuff down a bit and get things compiling.

Upgrade sled

Tyler's been busy, and we respect that. Upgrade sled to the latest version.

WIP branch is upgrade_sled

Building Errors

After cloning the repository and running the shell scripts, I receive

error: failed to select a version for cfg-if.
... required by package wasm-bindgen v0.2.60
... which is depended on by yew v0.17.2 (https://github.com/DenisKolodin/yew.git?branch=master#b7b4a93f)
... which is depended on by ui v0.1.0 (/Users/francischua/gitprojects/rust/rustproj/tempgitdir/rocket-yew-starter-pack/ui)
versions that meet the requirements ^0.1.9 are: 0.1.10, 0.1.9

all possible versions conflict with previously selected packages.

previously selected package cfg-if v0.1.6
... which is depended on by backtrace v0.3.13
... which is depended on by failure v0.1.5
... which is depended on by ui v0.1.0 (/Users/francischua/gitprojects/rust/rustproj/tempgitdir/rocket-yew-starter-pack/ui)

failed to select a version for cfg-if which could resolve this conflict

I'm assuming from the error message that several packages require different versions? Is this a problem that could be resolved in Cargo.toml or does it depend on something else?

Get off iovec fork

We depend on a fork of iovec, and that will break out from under us when some PRs in yew are merged.

Make the build portable

Some issues related to the build

  1. Need to pin a version of yew. Currently ui/Cargo.toml is using a relative local path. This only works on my PC. That library is churning daily, but we can keep up.
  2. I am unable to make a higher level Cargo.toml for encapsulating these two crates in a workspace. I get an error like this:
    buildproblems

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.