-
Notifications
You must be signed in to change notification settings - Fork 51
feat(proxy): demo warp based REST API endpoints #250
Conversation
proxy/src/http/project.rs
Outdated
} | ||
} | ||
|
||
impl Serialize for project::Project { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should Serialize impl'ed on crate::project
instead of here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on the fence, on one side it's nice to use the derive macros. On the other hand there will be slight diversion between the core types and how they are represented over something like a JSON API. And that is really a concern of the API layer for us http
. Happy to hear arguments in the other direction.
This looks like a good demo of how to do a REST API in Warp. Thanks @xla , this addresses the issues I ran into trying to do it myself. I've read through the implementation here and I'm prepared to move forward with it for the REST API over the Rocket implementation, echoing your concerns about dependency footprints. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressive change-set!! 🌟 🥇 🍰
From my perspective the proxy part could be merged if it can run in parallel to the existing graphql endpoints until we have a good migration strategy for the front-end.
The front-end still feels like it needs quite a lot of work to make the features that got migrated to the REST back-end work as they did before.
If we want to move forward, I'd recommend splitting it up into to PRs and merging the back-end and continue working on the front-end.
.buildkite/run.sh
Outdated
mkdir -p "$CACHE_FOLDER/npm" | ||
mkdir -p "$CACHE_FOLDER/yarn" | ||
mkdir -p "$CACHE_FOLDER/cargo" | ||
mkdir -p "$CACHE_FOLDER/rustup" | ||
|
||
|
||
export CYPRESS_CACHE_FOLDER="$CACHE_FOLDER/cypress" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this and L24 didn't make any difference to the CI build stability and can be removed again.
package.json
Outdated
"wait-on": "^4.0.1" | ||
}, | ||
"scripts": { | ||
"start": "run-p --race svelte:watch proxy:start graphiql:serve electron:start", | ||
"start": "run-p --race svelte:watch proxy:start:test graphiql:serve electron:start", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this will be reverted before merge?
package.json
Outdated
@@ -87,7 +91,7 @@ | |||
"svelte:watch": "yarn svelte:clean && rollup -c -w", | |||
"proxy:build": "cd proxy && cargo build --all-features --all-targets", | |||
"proxy:build:release": "cd proxy && cargo build --release --all-features --all-targets", | |||
"proxy:start": "cd proxy && cargo run --release -- --registry=emulator", | |||
"proxy:start": "cd proxy && cargo run -- --registry=emulator", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
package.json
Outdated
@@ -101,7 +105,7 @@ | |||
"prettier": "prettier \"**/*.@(js|json|svelte|css|html)\" --ignore-path .gitignore", | |||
"prettier:check": "yarn prettier --check", | |||
"prettier:write": "yarn prettier --write", | |||
"lint": "eslint . --ignore-path .gitignore --ext .js,.svelte" | |||
"lint": "eslint . --ignore-path .gitignore --ext js,.svelte,.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "js" vs ".js" a typo here?
proxy/API.md
Outdated
|
||
The examples provided use [curl](https://curl.haxx.se/) and the [window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) function available in the JavaScript environments of modern browsers. | ||
|
||
### GET /projects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add a yarn
script to start up the swagger live doc server and explain here how to use it and remove all the examples from this file.
proxy/Cargo.toml
Outdated
@@ -30,7 +30,7 @@ tempfile = "3.1" | |||
tokio = { version = "0.2", features = [ "macros" ] } | |||
url17 = { package = "url", version = "1.7" } | |||
url = "2.1" | |||
warp = "0.2" | |||
warp = { git = "https://github.com/radicle-dev/warp", branch = "openapi", features = [ "openapi" ] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a fork for this? Will the openapi stuff get merged into mainline, so we don't have to maintain our own fork?
proxy/src/http/error.rs
Outdated
"message".into(), | ||
document::string() | ||
.description("Human readable description of the error case") | ||
.example("Malformed ID, supported charactes: [a-zA-Z0-9]"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.example("Malformed ID, supported charactes: [a-zA-Z0-9]"), | |
.example("Malformed ID, supported characters: [a-zA-Z0-9]"), |
ui/App.svelte
Outdated
@@ -62,6 +63,7 @@ | |||
} | |||
`; | |||
|
|||
// TODO(sos): dev mode in which you don't have to sign in on reload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't be necessary once identities are integrated at a protocol level in the backend. You'll create the identity once and it will persist across reboots.
proxy/src/http/identity.rs
Outdated
|
||
state.end() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the avatar related code be moved out of the file when implementing the rest of the queries (avatar query and later adding avatars to orgs), or would this part of the code be repeated?
ui/src/identity.ts
Outdated
b: number; | ||
}; | ||
emoji: string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the types from avatar.ts
here to avoid duplication?
Superseeded by #296 |
Follow-up to #250 * Implement project registration REST call * Implement register REST call * Remove outdated network query * Replace gql user endpoints with REST * Migrate to user REST endpoints * Migrate to control REST endpoints * Please le clippy * Remove outdated graphql docs * Fix typo * Remove last traces * Update proxy/src/lib.rs Co-Authored-By: Rūdolfs Ošiņš <[email protected]>
Alternative follow-up to #220, in response to the issues I see with pulling in Rocket as a dependency, which is at the core of the great prior work of @garbados in #226. Also just for brevity so we can compare our options as this approach uses our existing web stack based on warp.
To show an end-to-end integration I focused on the endpoint around projects as it forced me to handle CoCo and Registry equally as well as read and write operations. This includes serialisation of request inputs and response bodies, while trying to adhere to our strict separation of core domain and materialisation in one of our API. This approach is comparable to what we tried to achieve with our GraphQL API and the isolation of it in the
graphql
module.