Clean up src

This commit is contained in:
Lucas Schumacher 2023-11-01 17:15:29 -04:00
parent eba7e4b0b7
commit eb9cbd9f66
3 changed files with 0 additions and 81 deletions

View File

@ -17,18 +17,8 @@ async function login(ev) {
}
}
console.log(user.value)
console.log(pass.value)
console.log(api_url)
console.log(payload)
console.log(fetch_options)
let resp = await fetch(api_url, fetch_options)
console.log(resp)
if (resp.ok) {
let ans = await resp.json()
console.log(ans)
window.location.hash = "/"
} else {
user.value = ''
@ -38,7 +28,6 @@ async function login(ev) {
onMounted(async () => {
let resp = await fetch("/api/user")
console.log(resp)
if (resp.ok) {
window.location.hash = "/"
}
@ -71,11 +60,6 @@ onMounted(async () => {
</template>
<style scoped>
/* html,
body {
height: 100%;
} */
.form-signin {
max-width: 330px;
padding: 1rem;

View File

@ -10,7 +10,6 @@ const err = ref('')
async function signup(ev) {
ev.preventDefault()
console.log(ev)
const api_url = '/api/user'
const payload = { username: user.value, password: pass.value, referral: refe.value }
const fetch_options = {
@ -21,19 +20,10 @@ async function signup(ev) {
}
}
console.log(user.value)
console.log(pass.value)
console.log(api_url)
console.log(payload)
console.log(fetch_options)
let resp = await fetch(api_url, fetch_options)
console.log(resp)
if (resp.ok) {
err.value = ''
let ans = await resp.json()
console.log(ans)
window.location.hash = "/"
}
else {

View File

@ -22,57 +22,6 @@ use serde::{Deserialize, Serialize};
use sqlx::{Pool, Sqlite};
use tokio::sync::broadcast::Sender;
#[handler]
fn index() -> Html<&'static str> {
Html(
r###"
<body>
<form id="loginForm">
Name: <input id="nameInput" type="text" />
<button type="submit">Login</button>
</form>
<form id="sendForm" hidden>
Text: <input id="msgInput" type="text" />
<button type="submit">Send</button>
</form>
<textarea id="msgsArea" cols="50" rows="30" hidden></textarea>
</body>
<script>
let ws;
const loginForm = document.querySelector("#loginForm");
const sendForm = document.querySelector("#sendForm");
const nameInput = document.querySelector("#nameInput");
const msgInput = document.querySelector("#msgInput");
const msgsArea = document.querySelector("#msgsArea");
nameInput.focus();
loginForm.addEventListener("submit", function(event) {
event.preventDefault();
loginForm.hidden = true;
sendForm.hidden = false;
msgsArea.hidden = false;
msgInput.focus();
let protocol = window.location.protocol == "https:" ? "wss://" : "ws://";
ws = new WebSocket(protocol + window.location.host + "/api/ws");
ws.onmessage = function(event) {
msgsArea.value += event.data + "\r\n";
}
});
sendForm.addEventListener("submit", function(event) {
event.preventDefault();
ws.send(msgInput.value);
msgInput.value = "";
});
</script>
"###,
)
}
#[derive(Debug, Object, Clone, Eq, PartialEq, Serialize, Deserialize)]
struct User {
#[oai(validator(max_length = 64))]
@ -277,9 +226,7 @@ impl Api {
}
#[oai(path = "/num", method = "get", tag = "ApiTags::User")]
//async fn get_num(&self, session: &Session) -> Json<u32> {
async fn get_num(&self, session: &Session) -> NumResponse {
//if session.get("user")
if let None = session.get::<String>("user") {
return NumResponse::AuthError;
}
@ -314,7 +261,6 @@ async fn main() -> anyhow::Result<()> {
let channel = tokio::sync::broadcast::channel::<String>(128).0;
//let dbpool = SqlitePool::connect("sqlite:chat.db").await?;
let dbpool = Pool::<Sqlite>::connect("sqlite:chat.db").await?;
let api = OpenApiService::new(
Api {
@ -328,7 +274,6 @@ async fn main() -> anyhow::Result<()> {
let static_endpoint = StaticFilesEndpoint::new("./client/dist").index_file("index.html");
let app = Route::new()
.at("/api/test", get(index))
.nest("/", static_endpoint)
.nest("/api", api)
.with(session);