Coder Social home page Coder Social logo

scoopit / scoop-demo-server Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 557 KB

Demo server that gets data from scoop.it api. Backend in Rust, frontend in JS/React

License: Apache License 2.0

Dockerfile 3.32% Rust 47.13% JavaScript 41.77% HTML 6.88% CSS 0.91%

scoop-demo-server's Introduction

Modern demo of accessing the Scoop.it API.

This repository consists in two parts:

The backend, responsible for requesting Scoop.it API and serving frontend files (only in production mode). It is written in the Rust programming language. Under the hood it's using warp to handle HTTP request, and scoopit-api to make requests to Scoop.it.

The frontend, responsible for getting data from the backend and presenting it in your browser. It is a regular Create React App. State management is done with Recoil and RxJS.

Building

Development

You need the Rust toolchain to build the backend, yarn and nodejs 12+ to build the frontend.

First create a .env file containing needed configuration for the backend:

# Backend config
APP_CLIENT_ID=ABCDEF_MY_KEY
APP_CLIENT_SECRET=GHIYJ_MY_SECRET
APP_BIND_ADDRESS="[::]:5001"
# Tell rust env_logger to log a bit
RUST_LOG=info

Build and run the backend:

cargo run

Then, build and run the frontend

cd front
yarn start

It should open a browser tab on http://localhost:3000

Build for production

# build
cargo build --release
cd front
yarn build

When running the produced backend binary you need to set the APP_STATIC_HTML environment variable to tell the backend to server frontend files. Note that is this done automatically in the provided Dockerfile

Alternatively you can use the provided Dockerfile:

# build the image
docker build -t scoop-demo-server .

# run the image with correct args
docker run --init -p 5001:5001 \
  -e RUST_LOG=info \
  -e APP_BIND_ADDRESS=0.0.0.0:5501 \
  -e APP_CLIENT_ID=my_client_id \
  -e APP_CLIENT_SECRET=my_secret \
  scoop-demo-server

Prebuilt Docker image

A docker image is provided containing the latest build for this demo server: zenria/scoop-demo-server.

docker run -p 5001:5001 \
  -e RUST_LOG=info \
  -e APP_BIND_ADDRESS=0.0.0.0:5501 \
  -e APP_CLIENT_ID=my_client_id \
  -e APP_CLIENT_SECRET=my_secret \
  zenria/scoop-demo-server

Configuration parameters

Configuration are read from environment variables.

  • APP_BIND_ADDRESS bind address
  • APP_CLIENT_ID oauth client id
  • APP_CLIENT_SECRET oauth secret id
  • RUST_LOG logging configuration see env_logger

If a .env file is present in the current directory or its parents environments variables declared in it will expand the current environment.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

scoop-demo-server's People

Contributors

zenria avatar

Stargazers

ANDREASCY avatar

Watchers

Vincent Demay avatar James Cloos 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.