Skip to content

Commit 2fd84cb

Browse files
committed
build(deps): update Cargo.lock, Cargo.toml, main.rs and +page.svelte
1 parent 4ec155b commit 2fd84cb

File tree

4 files changed

+37
-40
lines changed

4 files changed

+37
-40
lines changed

Diff for: my_api/Cargo.lock

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: my_api/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
salvo = { version = "*", features = ["oapi"] }
9+
salvo = { version = "*", features = ["oapi", "cors"] }
1010
tokio = { version = "1", features = ["macros"] }
1111
tracing = "0.1.40"
1212
tracing-subscriber = "0.3"

Diff for: my_api/src/main.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use salvo::cors::Cors;
2+
use salvo::hyper::Method;
13
use salvo::oapi::extract::*;
24
use salvo::prelude::*;
35

@@ -14,9 +16,15 @@ async fn main() {
1416

1517
let doc = OpenApi::new("test api", "0.0.1").merge_router(&router);
1618

19+
let cors = Cors::new()
20+
.allow_origin("*")
21+
.allow_methods(vec![Method::GET, Method::POST, Method::DELETE])
22+
.into_handler();
23+
1724
let router = router
1825
.push(doc.into_router("/api-doc/openapi.json"))
19-
.push(SwaggerUi::new("/api-doc/openapi.json").into_router("ui"));
26+
.push(SwaggerUi::new("/api-doc/openapi.json").into_router("ui"))
27+
.hoop(cors);
2028

2129
let acceptor = TcpListener::new("127.0.0.1:5800").bind().await;
2230
Server::new(acceptor).serve(router).await;

Diff for: web-frontend/src/routes/+page.svelte

+15-38
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
<script>
2-
import Counter from "./Counter.svelte";
3-
import welcome from "$lib/images/svelte-welcome.webp";
4-
import welcome_fallback from "$lib/images/svelte-welcome.png";
5-
import { BaseAPI, Configuration } from "../api";
2+
import { Configuration, DefaultApi } from "../api";
3+
import { onMount } from "svelte";
64
7-
const config = new Configuration({
8-
basePath: "http://localhost:5800",
9-
});
5+
let test = "this is a test";
6+
7+
onMount(async () => {
8+
console.log("onMount");
9+
10+
const config = new Configuration({
11+
basePath: "http://localhost:5800",
12+
});
13+
14+
const api = new DefaultApi(config);
1015
11-
const api = new BaseAPI(config);
16+
test = await api.
17+
});
1218
</script>
1319

1420
<svelte:head>
@@ -18,21 +24,8 @@
1824

1925
<section>
2026
<h1>
21-
<span class="welcome">
22-
<picture>
23-
<source srcset={welcome} type="image/webp" />
24-
<img src={welcome_fallback} alt="Welcome" />
25-
</picture>
26-
</span>
27-
28-
to your new<br />SvelteKit app
27+
{test}
2928
</h1>
30-
31-
<h2>
32-
try editing <strong>src/routes/+page.svelte</strong>
33-
</h2>
34-
35-
<Counter />
3629
</section>
3730

3831
<style>
@@ -47,20 +40,4 @@
4740
h1 {
4841
width: 100%;
4942
}
50-
51-
.welcome {
52-
display: block;
53-
position: relative;
54-
width: 100%;
55-
height: 0;
56-
padding: 0 0 calc(100% * 495 / 2048) 0;
57-
}
58-
59-
.welcome img {
60-
position: absolute;
61-
width: 100%;
62-
height: 100%;
63-
top: 0;
64-
display: block;
65-
}
6643
</style>

0 commit comments

Comments
 (0)