-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
622 additions
and
95 deletions.
There are no files selected for viewing
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 @@ | ||
[target.aarch64-unknown-linux-gnu] | ||
linker = "aarch64-linux-gnu-gcc" | ||
|
||
[target.aarch64-unknown-linux-musl] | ||
linker = "aarch64-linux-gnu-gcc" |
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 @@ | ||
edition = "2021" | ||
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#merge_imports | ||
# imports_granularity = "Crate" | ||
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#max_width | ||
max_width = 120 |
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,24 @@ | ||
[workspace] | ||
members = ["isbn_wasm_mod", "lambdas/index-html-server"] | ||
resolver = "2" | ||
|
||
[workspace.dependencies] | ||
lambda_runtime = { version = "0.12", default-features = false } | ||
tokio = { version = "1.16", features = [ | ||
"macros", | ||
"io-util", | ||
"sync", | ||
"rt-multi-thread", | ||
] } | ||
serde = { version = "1", features = ["derive"] } | ||
serde_json = "1" | ||
tracing = { version = "0.1", features = ["log"] } | ||
tracing-subscriber = { version = "0.3", features = ["env-filter"] } | ||
aws-config = { version = "1.1.7", features = ["behavior-version-latest"] } | ||
aws_lambda_events = "0.15.1" | ||
aws-sdk-s3 = "1.40.0" | ||
regex = "1.10.5" | ||
|
||
[profile.release] | ||
lto = true | ||
codegen-units = 1 |
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,15 +1,15 @@ | ||
{ | ||
"files": { | ||
"main.css": "./static/css/main.00b9f5c0.css", | ||
"main.js": "./static/js/main.3ab7bc97.js", | ||
"static/media/isbn_mod_bg.wasm": "./static/media/isbn_mod_bg.c9c44fb02c839a858597.wasm", | ||
"main.js": "./static/js/main.8af119ea.js", | ||
"static/media/isbn_mod_bg.wasm": "./static/media/isbn_mod_bg.7eb38663a2358fff1703.wasm", | ||
"static/media/welcome-bg.jpg": "./static/media/welcome-bg.b44b41f244b5885c2660.jpg", | ||
"index.html": "./index.html", | ||
"main.00b9f5c0.css.map": "./static/css/main.00b9f5c0.css.map", | ||
"main.3ab7bc97.js.map": "./static/js/main.3ab7bc97.js.map" | ||
"main.8af119ea.js.map": "./static/js/main.8af119ea.js.map" | ||
}, | ||
"entrypoints": [ | ||
"static/css/main.00b9f5c0.css", | ||
"static/js/main.3ab7bc97.js" | ||
"static/js/main.8af119ea.js" | ||
] | ||
} |
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 @@ | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="ie=edge"><meta name="description" content="Record and share books you come across"><meta name="referrer" content="no-referrer"/><title>📖📚📚</title><link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/img/favicon-16x16.png"><meta name="theme-color" content="#ffffff"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta id="ogImage" property="og:image" content="/img/og-thumb.png"/><meta id="ogTitle" property="og:title" content="Scan ISBN to record or share a book"/><script defer="defer" src="/static/js/main.3ab7bc97.js"></script><link href="/static/css/main.00b9f5c0.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="app"></div></body></html> | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="ie=edge"><meta name="description" content="Record and share books you come across"><meta name="referrer" content="no-referrer"/><title>📖📚📚</title><link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/img/favicon-16x16.png"><meta name="theme-color" content="#ffffff"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta id="ogImage" property="og:image" content="/img/og-thumb.png"/><meta id="ogTitle" property="og:title" content="Scan ISBN to record or share a book"/><script defer="defer" src="/static/js/main.8af119ea.js"></script><link href="/static/css/main.00b9f5c0.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="app"></div></body></html> |
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
build/static/js/main.3ab7bc97.js → build/static/js/main.8af119ea.js
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "index-html-server" | ||
version = "0.2.0" | ||
authors = ["rimutaka <[email protected]>"] | ||
edition = "2021" | ||
description = "Returns modified index.html from S3" | ||
license = "AGPL-3.0" | ||
|
||
[dependencies] | ||
wasm_mod = { path = "../../isbn_wasm_mod" } | ||
tokio = { workspace = true } | ||
serde = { workspace = true } | ||
serde_json = { workspace = true } | ||
tracing = { workspace = true } | ||
tracing-subscriber = { workspace = true } | ||
lambda_runtime = { workspace = true } | ||
aws_lambda_events = { workspace = true } | ||
aws-sdk-s3 = { workspace = true } | ||
aws-config = { workspace = true } | ||
regex = { workspace = true } | ||
reqwest = { version = "0.12", features = ["json", "rustls-tls-native-roots"] } |
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,114 @@ | ||
{ | ||
"body": null, | ||
"headers": { | ||
"Host": "mqd1wllexd.execute-api.us-east-1.amazonaws.com", | ||
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0", | ||
"X-Amzn-Trace-Id": "Root=1-66872833-6f9600b6174d52360b458d06", | ||
"X-Forwarded-For": "206.83.103.59", | ||
"X-Forwarded-Port": "443", | ||
"X-Forwarded-Proto": "https", | ||
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", | ||
"accept-encoding": "gzip, deflate, br, zstd", | ||
"accept-language": "en-US,en;q=0.5", | ||
"dnt": "1", | ||
"priority": "u=1", | ||
"referer": "https://us-east-1.console.aws.amazon.com/", | ||
"sec-fetch-dest": "document", | ||
"sec-fetch-mode": "navigate", | ||
"sec-fetch-site": "cross-site", | ||
"sec-fetch-user": "?1", | ||
"upgrade-insecure-requests": "1" | ||
}, | ||
"httpMethod": "GET", | ||
"isBase64Encoded": false, | ||
"multiValueHeaders": { | ||
"Host": [ | ||
"mqd1wllexd.execute-api.us-east-1.amazonaws.com" | ||
], | ||
"User-Agent": [ | ||
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0" | ||
], | ||
"X-Amzn-Trace-Id": [ | ||
"Root=1-66872833-6f9600b6174d52360b458d06" | ||
], | ||
"X-Forwarded-For": [ | ||
"206.83.103.59" | ||
], | ||
"X-Forwarded-Port": [ | ||
"443" | ||
], | ||
"X-Forwarded-Proto": [ | ||
"https" | ||
], | ||
"accept": [ | ||
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8" | ||
], | ||
"accept-encoding": [ | ||
"gzip, deflate, br, zstd" | ||
], | ||
"accept-language": [ | ||
"en-US,en;q=0.5" | ||
], | ||
"dnt": [ | ||
"1" | ||
], | ||
"priority": [ | ||
"u=1" | ||
], | ||
"referer": [ | ||
"https://us-east-1.console.aws.amazon.com/" | ||
], | ||
"sec-fetch-dest": [ | ||
"document" | ||
], | ||
"sec-fetch-mode": [ | ||
"navigate" | ||
], | ||
"sec-fetch-site": [ | ||
"cross-site" | ||
], | ||
"sec-fetch-user": [ | ||
"?1" | ||
], | ||
"upgrade-insecure-requests": [ | ||
"1" | ||
] | ||
}, | ||
"multiValueQueryStringParameters": null, | ||
"path": "/understanding-caricature-by-greg-houston/9781580935647/", | ||
"pathParameters": null, | ||
"queryStringParameters": null, | ||
"requestContext": { | ||
"accountId": "512295225992", | ||
"apiId": "mqd1wllexd", | ||
"deploymentId": "tafunn", | ||
"domainName": "mqd1wllexd.execute-api.us-east-1.amazonaws.com", | ||
"domainPrefix": "mqd1wllexd", | ||
"extendedRequestId": "aaM4FE9IoAMEWzA=", | ||
"httpMethod": "GET", | ||
"identity": { | ||
"accessKey": null, | ||
"accountId": null, | ||
"caller": null, | ||
"cognitoAuthenticationProvider": null, | ||
"cognitoAuthenticationType": null, | ||
"cognitoIdentityId": null, | ||
"cognitoIdentityPoolId": null, | ||
"principalOrgId": null, | ||
"sourceIp": "206.83.103.59", | ||
"user": null, | ||
"userAgent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0", | ||
"userArn": null | ||
}, | ||
"path": "/dev/understanding-caricature-by-greg-houston/9781580935647/", | ||
"protocol": "HTTP/1.1", | ||
"requestId": "f69e3e2a-c5d7-48aa-89eb-e56a05411534", | ||
"requestTime": "04/Jul/2024:22:54:43 +0000", | ||
"requestTimeEpoch": 1720133683448, | ||
"resourceId": "p0yn8b2fu0", | ||
"resourcePath": "/", | ||
"stage": "dev" | ||
}, | ||
"resource": "/", | ||
"stageVariables": 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,9 @@ | ||
{ | ||
"cookies": [], | ||
"isBase64Encoded": false, | ||
"statusCode": 200, | ||
"headers": { | ||
"content-type": "text/text" | ||
}, | ||
"body": "Hello from Lambda!" | ||
} |
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,97 @@ | ||
/// Logic for fetching book data from Google Books API | ||
/// | ||
/// Volume search by ISBN: | ||
/// - https://www.googleapis.com/books/v1/volumes?q=isbn:9781761186769 | ||
/// | ||
/// Response: isbn_wasm_mod/data-samples/google-books-volume.json | ||
/// | ||
/// | ||
/// | ||
// | ||
use super::BrowserRuntime; | ||
use crate::utils::{execute_http_request, log}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
// /// Part of GoogleBooks API response | ||
// #[derive(Deserialize, Serialize, Debug)] | ||
// #[serde(rename_all = "camelCase")] | ||
// pub struct IndustryIdentifier { | ||
// pub r#type: String, | ||
// pub identifier: String, | ||
// } | ||
|
||
/// Part of GoogleBooks API response | ||
#[derive(Deserialize, Serialize, Debug)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct ImageLinks { | ||
pub small_thumbnail: String, | ||
pub thumbnail: String, | ||
} | ||
|
||
// /// Part of GoogleBooks API response | ||
// #[derive(Deserialize, Serialize, Debug)] | ||
// #[serde(rename_all = "camelCase")] | ||
// pub struct ListPrice { | ||
// #[serde(skip_serializing_if = "Option::is_none")] | ||
// pub amount: Option<f64>, | ||
// #[serde(skip_serializing_if = "Option::is_none")] | ||
// pub currency_code: Option<String>, | ||
// } | ||
|
||
// /// Part of GoogleBooks API response | ||
// #[derive(Deserialize, Serialize, Debug)] | ||
// #[serde(rename_all = "camelCase")] | ||
// pub struct SaleInfo { | ||
// #[serde(skip_serializing_if = "Option::is_none")] | ||
// pub list_price: Option<ListPrice>, | ||
// } | ||
|
||
/// Part of GoogleBooks API response | ||
#[derive(Deserialize, Serialize, Debug)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct VolumeInfo { | ||
pub title: String, | ||
#[serde(default = "Vec::new")] | ||
pub authors: Vec<String>, | ||
// #[serde(skip_serializing_if = "Option::is_none")] | ||
// pub description: Option<String>, | ||
// #[serde(default = "Vec::new")] | ||
// pub industry_identifiers: Vec<IndustryIdentifier>, | ||
// #[serde(skip_serializing_if = "Option::is_none")] | ||
// pub page_count: Option<i64>, | ||
// #[serde(default = "Vec::new")] | ||
// pub categories: Vec<String>, | ||
// #[serde(skip_serializing_if = "Option::is_none")] | ||
pub image_links: Option<ImageLinks>, | ||
} | ||
|
||
/// Part of GoogleBooks API response | ||
#[derive(Deserialize, Serialize, Debug)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Volume { | ||
pub id: String, | ||
pub self_link: String, | ||
pub volume_info: VolumeInfo, | ||
// #[serde(skip_serializing_if = "Option::is_none")] | ||
// pub sale_info: Option<SaleInfo>, | ||
} | ||
|
||
/// The root of GoogleBooks API response | ||
#[derive(Deserialize, Serialize, Debug)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Volumes { | ||
pub kind: String, | ||
pub total_items: i64, | ||
#[serde(default = "Vec::new")] | ||
pub items: Vec<Volume>, | ||
} | ||
|
||
/// Fetches book data from Google Books API | ||
pub(crate) async fn get_book_data(isbn: &str, runtime: &BrowserRuntime) -> super::Result<Volumes> { | ||
log!("get_book_data for: {isbn}"); | ||
|
||
let url = format!("https://www.googleapis.com/books/v1/volumes?q=isbn:{isbn}"); | ||
|
||
execute_http_request::<Volumes, u8>(&url, None, runtime).await | ||
} |
Oops, something went wrong.