-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Create two APIs for data operations #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
* feat(ntc-vault-cli): initial layout * style(ntc-vault-cli): add rustfmt.toml * feat(ntc-vault-cli): add clap-based CLI skeleton * feat(ntc-vault-cli): flesh out structure, implement identity subcommand * refactor(ntc-vault-cli): separate code into two crates: core, cli * refactor(ntc-vault-cli): move rand-using code from core to cli * test(ntc-vault-cli): generate_secure_seed smoke test * feat(ntc-vault-cli): data package and JSON Schema work-in-progress * refactor: move crates into rust-workspace * docs: add comment about using "cargo +nightly fmt" * docs: add ARCHITECTURE.md * refactor: rename package "ntc-vault-core" → "ntc-data-packages" * feat(ntc-data-packages): replace anyhow with thiserror * build(ntc-data-packages): drop jsonschema's default features We don't need jsonschema's CLI, or the file / HTTP resolving features. This greatly reduces our dependency tree. * build: declare rust-version * docs: add package descriptions * feat(ntc-data-packages): better validation error messages * ci(rust-workspace): add check and test workflows for GitHub Actions * docs: fix rustdoc link issues * build(rust-workspace): add rust-toolchain.toml, with channel = "stable" * docs(README): add link to ARCHITECTURE.md * deps(ntc-vault-cli): update confy revision for store_path fix Upstream PR: rust-cli/confy#60 (fix: `store_path` should create missing directories, like `load_path`) * refactor(ntc-data-packages): move tests to API-based integration tests Motivation: https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html * refactor(ntc-vault-cli): move try_exists to compat module * refactor(ntc-vault-cli): VaultIdentityConfig: make pub * deps(ntc-vault-cli): add dev dependencies for CLI tests * test(ntc-vault-cli): add snapshot-based CLI tests * deps(ntc-data-packages): add serde * feat(ntc-data-packages): add Metadata::from_json_bytes * feat(ntc-vault-cli): add fs_io, with read_metadata * feat(ntc-vault-cli): implement more of the "data" subcommand * chore: add todos to keep track of changes that needs to be made to allign with design * chore(deps): update dependencies and bump jsonschema to 0.16 Co-authored-by: Herman <[email protected]>
* build(rust-sgx-workspace): add workspace for SGX code * build(ntc-tee-server): add SGX project for the TEE server * build(ntc-tee-server): bump Rust edition: "2018" → "2021" * build(ntc-tee-server): better error message for missing Enclave_u library * ci(rust-sgx-workspace): add check and test workflows for GitHub Actions * ci: use nested checkout for the multiple repositories to prevent _temp being deleted * style: fix clippy warnings * ci: remove --all-targets build arg to fix enclave builds and checks Co-authored-by: Herman <[email protected]>
Co-authored-by: Jean-Pierre de Villiers <[email protected]>
* feat(ntc-oracle-node): connect to PureStake Indexer using algonaut * feat(ntc-oracle-node): add config crate * feat(ntc-oracle-node): add initial server with axum * feat(ntc-oracle-node): implement get_auth_data * feat(ntc-oracle-node): use ed25519 to sign AuthData with ring-compat * style(ntc-oracle-node): apply rustfmt.toml * refactor(ntc-oracle-node): move auth_data functions into handler * feat(ntc-oracle-node): add anyhow error handling * feat(ntc-oracle-node): add unit test for sign_auth_data * feat(ntc-oracle-node): use serde_with to base64 encode SignedAuthData response * refactor(ntc-oracle-node): use cfg(test) in place of allow(dead_code)
* feat(web-server): copy web-server from Nautilus Wallet * docs(web-server): fix comments in rust-toolchain and rustfmt toml files * refactor: move http-service-impl and sgx-helpers into rust-sgx-workspace * refactor: move sgx-wallet-impl into rust-sgx-workspace but exclude as member * refactor: move sgx-wallet into rust-sgx-workspace but exclude as member * refactor: move sgx-wallet-test into rust-sgx-workspace but exclude as member * refactor: remove web-server * docs(http-service-impl): fix sgx-wallet-impl broken intra doc link * fix(sgx-wallet): fix path to sgx-wallet-impl in Makefile
5fed21d
to
462ed04
Compare
ccb5652
to
392c6d6
Compare
Started with two tutorials for using CosmosDB with Mongo APIs (recommended by Bill): Found another helpful tutorial: https://jbarszczewski.com/rust-actix-cosmosdb-mongodb-tutorial-api Created 2 API functions:
Set connection string when starting project:
Test POST - (Upload/Add data)(Copy source code)
Test GET - (View/Get data)(Copy source code)
|
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.
Run the following to format your code:
cargo make format
cargo make format-toml
use std::sync::Mutex; | ||
use chrono::prelude::*; | ||
use serde::Deserialize; | ||
use std::env; |
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.
unused import
env::set_var("RUST_LOG", "actix_web=debug"); | ||
// Remember to set connection string when starting the server | ||
let mongo_url = env::var("CONNECTION_STRING").unwrap(); | ||
let mut client_options = ClientOptions::parse(&mongo_url).await.unwrap(); |
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.
remove mut
as variable does not have to be mutable
#[derive(Deserialize)] | ||
pub struct NewDataPool { | ||
pub id: String, | ||
pub poolName: String, //User defined pool name |
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.
can we use snake case name :)
pool_name
sealed_data
} | ||
|
||
// This function accepts application data | ||
async fn get_data(data: web::Data<Mutex<Client>>, existingUser: web::Json<UserData>) -> impl Responder { |
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.
snake case naming: existingUser
--> existing_user
.database(MONGO_DB) | ||
.collection(MONGO_COLLECTION); | ||
|
||
let userId = &existingUser.id; |
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.
user_id
7fa0869
to
b1313e2
Compare
* feat: add Vault CLI & data package library (#1) * feat(ntc-vault-cli): initial layout * style(ntc-vault-cli): add rustfmt.toml * feat(ntc-vault-cli): add clap-based CLI skeleton * feat(ntc-vault-cli): flesh out structure, implement identity subcommand * refactor(ntc-vault-cli): separate code into two crates: core, cli * refactor(ntc-vault-cli): move rand-using code from core to cli * test(ntc-vault-cli): generate_secure_seed smoke test * feat(ntc-vault-cli): data package and JSON Schema work-in-progress * refactor: move crates into rust-workspace * docs: add comment about using "cargo +nightly fmt" * docs: add ARCHITECTURE.md * refactor: rename package "ntc-vault-core" → "ntc-data-packages" * feat(ntc-data-packages): replace anyhow with thiserror * build(ntc-data-packages): drop jsonschema's default features We don't need jsonschema's CLI, or the file / HTTP resolving features. This greatly reduces our dependency tree. * build: declare rust-version * docs: add package descriptions * feat(ntc-data-packages): better validation error messages * ci(rust-workspace): add check and test workflows for GitHub Actions * docs: fix rustdoc link issues * build(rust-workspace): add rust-toolchain.toml, with channel = "stable" * docs(README): add link to ARCHITECTURE.md * deps(ntc-vault-cli): update confy revision for store_path fix Upstream PR: rust-cli/confy#60 (fix: `store_path` should create missing directories, like `load_path`) * refactor(ntc-data-packages): move tests to API-based integration tests Motivation: https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html * refactor(ntc-vault-cli): move try_exists to compat module * refactor(ntc-vault-cli): VaultIdentityConfig: make pub * deps(ntc-vault-cli): add dev dependencies for CLI tests * test(ntc-vault-cli): add snapshot-based CLI tests * deps(ntc-data-packages): add serde * feat(ntc-data-packages): add Metadata::from_json_bytes * feat(ntc-vault-cli): add fs_io, with read_metadata * feat(ntc-vault-cli): implement more of the "data" subcommand * chore: add todos to keep track of changes that needs to be made to allign with design * chore(deps): update dependencies and bump jsonschema to 0.16 Co-authored-by: Herman <[email protected]> * feat: add initial TEE server (#3) * build(rust-sgx-workspace): add workspace for SGX code * build(ntc-tee-server): add SGX project for the TEE server * build(ntc-tee-server): bump Rust edition: "2018" → "2021" * build(ntc-tee-server): better error message for missing Enclave_u library * ci(rust-sgx-workspace): add check and test workflows for GitHub Actions * ci: use nested checkout for the multiple repositories to prevent _temp being deleted * style: fix clippy warnings * ci: remove --all-targets build arg to fix enclave builds and checks Co-authored-by: Herman <[email protected]> * license: relicense to AGPL-3.0 (#17) * ci: use ntls-io fork of rust-sgx-sdk-env (#39) Co-authored-by: Jean-Pierre de Villiers <[email protected]> * feat: create oracle-node API (#18) * feat(ntc-oracle-node): connect to PureStake Indexer using algonaut * feat(ntc-oracle-node): add config crate * feat(ntc-oracle-node): add initial server with axum * feat(ntc-oracle-node): implement get_auth_data * feat(ntc-oracle-node): use ed25519 to sign AuthData with ring-compat * style(ntc-oracle-node): apply rustfmt.toml * refactor(ntc-oracle-node): move auth_data functions into handler * feat(ntc-oracle-node): add anyhow error handling * feat(ntc-oracle-node): add unit test for sign_auth_data * feat(ntc-oracle-node): use serde_with to base64 encode SignedAuthData response * refactor(ntc-oracle-node): use cfg(test) in place of allow(dead_code) * feat: add Vault backend (#61) * feat(web-server): copy web-server from Nautilus Wallet * docs(web-server): fix comments in rust-toolchain and rustfmt toml files * refactor: move http-service-impl and sgx-helpers into rust-sgx-workspace * refactor: move sgx-wallet-impl into rust-sgx-workspace but exclude as member * refactor: move sgx-wallet into rust-sgx-workspace but exclude as member * refactor: move sgx-wallet-test into rust-sgx-workspace but exclude as member * refactor: remove web-server * docs(http-service-impl): fix sgx-wallet-impl broken intra doc link * fix(sgx-wallet): fix path to sgx-wallet-impl in Makefile * refactor(rust-sgx-workspace): rename 'wallet' to 'vault' (#62) * refactor(sgx-vault-impl): change vault id to algorand address (#65) * refactor: remove Onfido operations and XRP related code (#66) * feat(rust-sgx-workspace): add Docker build definition for Vault server (#67) * feat: Create two APIs for data operations * Merge branch 'data-operations' of https://github.com/ntls-io/nautilus-trusted-compute into data-operations * feat(data-operations-api): create new project dir * feat: Add base crate * feat: Add basic Actix server * feat: Configure server + add logs_handlers * feat: Fetching logs * feat: Adding logs * refactor: Update log -> data * feat: Add filter functionality * refactor: remove unused imports + fix snake_case * feat(backend-services): initial commit for api * feat(backend-services): initial commit for api * fix(backend-services): add env to .gitignore. * fix (backend-services): .gitignore and datetime * feature (backend-services): add example json and schema files --------- Co-authored-by: Pi Delport <[email protected]> Co-authored-by: Herman <[email protected]> Co-authored-by: Jean-Pierre de Villiers <[email protected]> Co-authored-by: Jean-Pierre de Villiers <[email protected]> Co-authored-by: Bill Guo <[email protected]> Co-authored-by: Bill Guo <[email protected]> Co-authored-by: binglekruger <[email protected]>
Create a new branch for the Data Service API