Skip to content

Commit

Permalink
feat: frontend is rolling
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlwn123 committed May 27, 2024
1 parent 537834c commit 18afb7e
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 2 deletions.
35 changes: 35 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions fedimint-nwc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ authors.workspace = true

[dependencies]
anyhow = "1.0.75"
axum = { version = "0.7.1", features = ["json"] }
axum-macros = "0.4.0"
bincode = "1.3.3"
clap = { version = "4.5.4", features = ["derive", "env"] }
dotenv = "0.15.0"
Expand All @@ -24,5 +26,6 @@ redb = "2.1.0"
serde = "1.0.193"
serde_json = "1.0.108"
tokio = { version = "1.34.0", features = ["full"] }
tower-http = { version = "0.5.2", features = ["fs"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
69 changes: 69 additions & 0 deletions fedimint-nwc/frontend/assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sample HTML Document</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
header {
background-color: #333;
color: #fff;
padding: 1rem 0;
text-align: center;
}
nav ul {
list-style: none;
padding: 0;
}
nav ul li {
display: inline;
margin: 0 1rem;
}
nav ul li a {
color: #fff;
text-decoration: none;
}
main {
padding: 2rem;
}
footer {
background-color: #333;
color: #fff;
text-align: center;
padding: 1rem 0;
position: absolute;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<header>
<h1>Welcome to My Website</h1>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<main>
<h2>Home</h2>
<p>This is a sample HTML document to demonstrate the basic structure of an HTML page. You can use this as a starting point for your own web projects.</p>
<h2>About</h2>
<p>Learn more about the purpose of this website and the content it provides.</p>
<h2>Contact</h2>
<p>If you have any questions or comments, feel free to reach out through the contact form.</p>
</main>
<footer>
<p>&copy; 2024 My Website</p>
</footer>
</body>
</html>
Empty file.
17 changes: 15 additions & 2 deletions fedimint-nwc/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
use anyhow::Result;
use clap::Parser;
use nostr_sdk::{JsonUtil, Kind, RelayPoolNotification};
use tokio::pin;
use tokio::{pin, task};
use tracing::{error, info};

pub mod config;
pub mod database;
pub mod nwc;
pub mod services;
pub mod state;

pub mod state;
use axum::Router;
use state::AppState;
use tower_http::services::ServeDir;

use crate::config::Cli;

Expand All @@ -28,6 +30,17 @@ async fn main() -> Result<()> {
state.nostr_service.connect().await;
state.nostr_service.broadcast_info_event().await?;

let server = Router::new().nest_service("/", ServeDir::new("frontend/assets"));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();

// Spawn a new Tokio task for the server
let server_task = task::spawn(async move {
axum::serve(listener, server).await.unwrap();
});

// Wait for the server task to complete if necessary
server_task.await?;

// Start the event loop
event_loop(state.clone()).await?;

Expand Down

0 comments on commit 18afb7e

Please sign in to comment.