Graphql backend for cindy-next.
It is based on async-graphql
, actix-web
, diesel
, powered by Rust.
- Dynamic query building with
diesel
(with support for complex filtering) - Graphql interface
- Realtime Subscriptions
- Authorization
- Access control
- Relay-like pagination (not included)
-
Rust, first of all. Follow the instructions on rustup.rs if you don't have one. The minimum supported version is v1.46.
# Install rustup curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Install latest rust and cargo rustup install nightly
Postgresql ≥ 12, and its dev library.
# Debian-based OS sudo apt-get install postgresql libpq-dev # Arch linux sudo pacman -S postgresql postgresql-libs
Diesel client. You need to compile this yourself
cargo install diesel_cli --no-default-features --features "postgres"
just (optional), to run recipes defined in
justfile
.cargo install just
Basically only two binaries (
cindy-next-rust
anddiesel
) are required in the server. Currently we do not provide compiled binaries. It is recommended to compile them yourself and push the binaries to the server.-
Clone the repo with
git clone https://github.com/heyrict/cindy-next-rust
. -
Create an empty database for Cindy with
sudo -u postgres psql
CREATE ROLE cindy LOGIN PASSWORD 'cindy-password'; ALTER ROLE cindy SET client_encoding TO 'utf8'; ALTER ROLE cindy SET timezone TO 'UTC'; CREATE DATABASE cindy-db; GRANT ALL ON DATABASE cindy-db TO cindy; \c cindy-db; GRANT ALL ON schema public to cindy; CREATE EXTENSION pgcrypto; CREATE EXTENSION "uuid-ossp";
Copy
.env.example
to.env
and edit it based on your flavor.Make sure
DATABASE_URL
in the config file points to your postgres instance. If you followed the steps above, it ispostgres://cindy:[email protected]:5432/cindy-db
.Setup the database with
diesel database setup && diesel migration run
.Run
cargo run --release
or./path/to/cindy-next-rust
if you have a compiled binary to start the server. For the former command, once compiled, it can be found in./target/release/cindy-next-rust
.Create an admin account with
just signup
.Load initial data to the database with
psql cindy-db < setup/jp/initdb.up.sql
.cindy-next-rust's People
Forkers
pb10005cindy-next-rust's Issues
Postgres error occurred in setup
An error occurred while setting up postgres.
OS: Debian 10(buster) on VirtualBox(host OS: macOS Big Sur)command I executed
sudo -u postgres psql cindy -U cindy < setup/jp/initdb.up.sql
error message
ERROR: relation "chatroom" does not exist LINE 1: INSERT INTO chatroom (name, description, user_id) ^ ERROR: relation "public.award" does not exist Query buffer reset (cleared). invalid command \n2. Query buffer reset (cleared). invalid command \n色んな称号を考案して、まさに名付けの親である。 Query buffer reset (cleared). invalid command \n「BSって何?」と思った方は用語集をチェック! Query buffer reset (cleared). invalid command \n「外の世界に一体何が起きたんでしょうか?」 Query buffer reset (cleared). invalid command \nATODUKEの「DUKE」が「公爵」を意味することから、この称号名になった。 Query buffer reset (cleared). invalid command \nジャパネットシンディで最高売上を記録した彼の腕にかかれば、たとえゴミ捨て場に捨てられたゴミでさえ売り物にしてしまうことだろう。 Query buffer reset (cleared). invalid command \n invalid command \. ERROR: syntax error at or near "230" LINE 1: 230 ★Cindy通(三年) 登録日から3年以上経過した後に1問以上出題... ^
Image uploading
Description
Images can be a bonus for creating lateral thinking puzzles. Generally users may want to use one or two images in a single puzzle.
Proposed solution
IMO, a table storing paths to pictures and uploaded users, file size, modification time, etc. should be created (one-to-many relationship between user and images may be sufficient in this case), thus alternation in the database is required.
Database alternation is done by files in themigrations
folder, created withdiesel migration generate
. See files there as an example.The graphql endpoint for uploading files is implemented in
async-graphql
, documented here.Alternative solutions
Adding an optional field in
puzzle
table may allow user to use up to one picture, associated with the puzzle. This could be easier to implement with the cost of flexibility.[Security] Workflow workflow.yml is using vulnerable action actions/checkout
The workflow workflow.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.[ Feature Request ] Relay-like pagination
Hi,
I saw
Relay-like pagination (not included)
is planned on theFeature Roadmap
. Any plan to make this happen?I am building a GraphQL server in Rust using async-graphql and having a hard time doing relay-like pagination. The only resource I found is:
- https://github.com/vectordotdev/vector/blob/master/src/api/schema/relay.rs#L105 and vector.dev/blog/graphql-api/#take-it-for-a-spin-in-the-vector-playground
If this repo supports
Relay-like pagination
, We will have more resources to follow.Thanks.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
Jobs
Jooble