-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Astraly-Labs/feat/poc
🎉 Proof of Concept
- Loading branch information
Showing
31 changed files
with
2,971 additions
and
247 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
-- Your SQL goes here | ||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | ||
|
||
CREATE TABLE entries ( | ||
id SERIAL PRIMARY KEY, | ||
id uuid DEFAULT uuid_generate_v4(), | ||
pair_id VARCHAR NOT NULL, | ||
publisher TEXT NOT NULL, | ||
timestamp TIMESTAMP NOT NULL, | ||
price NUMERIC NOT NULL | ||
price NUMERIC NOT NULL, | ||
PRIMARY KEY (id) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- This file should undo anything in `up.sql` | ||
ALTER TABLE entries | ||
DROP COLUMN source; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- Your SQL goes here | ||
ALTER TABLE entries | ||
ADD COLUMN source VARCHAR NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- This file should undo anything in `up.sql` | ||
DROP TABLE publishers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- Your SQL goes here | ||
CREATE TABLE publishers ( | ||
id uuid DEFAULT uuid_generate_v4(), | ||
name VARCHAR NOT NULL, | ||
master_key VARCHAR NOT NULL, | ||
active_key VARCHAR NOT NULL, | ||
active BOOLEAN NOT NULL, | ||
PRIMARY KEY (id) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- This file should undo anything in `up.sql` | ||
ALTER TABLE publishers | ||
DROP COLUMN account_address; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- Your SQL goes here | ||
ALTER TABLE publishers | ||
ADD COLUMN account_address VARCHAR NOT NULL DEFAULT ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[toolchain] | ||
channel = "nightly-2023-08-24" | ||
components = ["rustfmt", "clippy", "rust-analyzer"] | ||
targets = ["wasm32-unknown-unknown"] | ||
profile = "minimal" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod entry; | ||
pub mod publisher; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use axum::http::StatusCode; | ||
use axum::response::IntoResponse; | ||
use axum::Json; | ||
use serde_json::json; | ||
use uuid::Uuid; | ||
|
||
use crate::infra::errors::InfraError; | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct PublisherModel { | ||
pub id: Uuid, | ||
pub name: String, | ||
pub master_key: String, | ||
pub active_key: String, | ||
pub account_address: String, | ||
pub active: bool, | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum PublisherError { | ||
#[error("internal server error")] | ||
InternalServerError, | ||
#[error("publisher not found: {0}")] | ||
NotFound(String), | ||
#[error("infra error: {0}")] | ||
InfraError(InfraError), | ||
#[error("invalid key : {0}")] | ||
InvalidKey(String), | ||
#[error("invalid address : {0}")] | ||
InvalidAddress(String), | ||
} | ||
|
||
impl IntoResponse for PublisherError { | ||
fn into_response(self) -> axum::response::Response { | ||
let (status, err_msg) = match self { | ||
Self::NotFound(name) => ( | ||
StatusCode::NOT_FOUND, | ||
format!("PublisherModel with name {} has not been found", name), | ||
), | ||
Self::InfraError(db_error) => ( | ||
StatusCode::INTERNAL_SERVER_ERROR, | ||
format!("Internal server error: {}", db_error), | ||
), | ||
_ => ( | ||
StatusCode::INTERNAL_SERVER_ERROR, | ||
String::from("Internal server error"), | ||
), | ||
}; | ||
( | ||
status, | ||
Json( | ||
json!({"resource":"PublisherModel", "message": err_msg, "happened_at" : chrono::Utc::now() }), | ||
), | ||
) | ||
.into_response() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.