??idkfrontend things?

This commit is contained in:
LinlyBoi
2022-12-25 00:13:06 +02:00
parent 87d96d938f
commit f456749a66
5 changed files with 42 additions and 47 deletions

View File

@@ -659,7 +659,7 @@ function initSync(module) {
async function init(input) {
if (typeof input === 'undefined') {
input = new URL('db-frontend-78ce040a256470ee_bg.wasm', import.meta.url);
input = new URL('db-frontend-5a949c39a51fa2c9_bg.wasm', import.meta.url);
}
const imports = getImports();

View File

@@ -2,10 +2,10 @@
<meta charset="utf-8">
<title>Ze greatest</title>
<link rel="preload" href="/db-frontend-78ce040a256470ee_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/db-frontend-78ce040a256470ee.js"></head>
<link rel="preload" href="/db-frontend-5a949c39a51fa2c9_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/db-frontend-5a949c39a51fa2c9.js"></head>
<body>
<script type="module">import init from '/db-frontend-78ce040a256470ee.js';init('/db-frontend-78ce040a256470ee_bg.wasm');</script><script>(function () {
<script type="module">import init from '/db-frontend-5a949c39a51fa2c9.js';init('/db-frontend-5a949c39a51fa2c9_bg.wasm');</script><script>(function () {
var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
var url = protocol + '//' + window.location.host + '/_trunk/ws';
var poll_interval = 5000;

33
src/api.rs Normal file
View File

@@ -0,0 +1,33 @@
use actix_web::{
get,
web::{self, Json},
HttpResponse, Responder,
};
use backend::{
admin_data::get_admin, driver_data::get_driver, establish_connection, ticket_data::get_ticket,
};
use common::{CommonAdmin, CommonDriver, CommonTicket};
//Ticket Table Services
#[get("api/ticket/{id}")]
async fn api_ticket(id: web::Path<i32>) -> Json<CommonTicket> {
let fetched_ticket_data = get_ticket(&mut establish_connection(), *id);
Json(fetched_ticket_data)
}
// Getting admin data or smth idk
#[get("api/admin/{id}")]
async fn api_admin(id: web::Path<i32>) -> Json<CommonAdmin> {
let fetched_admin_data = get_admin(&mut establish_connection(), *id);
Json(fetched_admin_data)
}
#[get("api/driver/{id}")]
async fn api_driver(id: web::Path<i32>) -> Json<CommonDriver> {
let fetched_driver_data = get_driver(&mut establish_connection(), *id);
Json(fetched_driver_data)
}
#[get("api/test")]
async fn api_test() -> impl Responder {
HttpResponse::Ok().body("My balls are on fire :(")
}

View File

@@ -1,47 +1,9 @@
use actix_web::{
get,
web::{self, Json},
App, HttpResponse, HttpServer, Responder,
};
use backend::{
admin_data::get_admin, driver_data::get_driver, establish_connection, ticket_data::get_ticket,
};
use common::{CommonAdmin, CommonDriver, CommonTicket};
// //Admin Services
// #[get("/api/admin/{id}")]
// async fn admin(id: web::Path<i32>) -> Json<CommonAdmin> {
// Json(get_admin(&mut establish_connection(), *id))
// }
// #[get("/api/admins{amount}")]
// async fn admins(amount: web::Path<i64>) -> Json<Vec<CommonAdmin>> {
// Json(get_admins(&mut establish_connection(), *amount))
// }
//Ticket Table Services
#[get("api/ticket/{id}")]
async fn api_ticket(id: web::Path<i32>) -> Json<CommonTicket> {
let fetched_ticket_data = get_ticket(&mut establish_connection(), *id);
Json(fetched_ticket_data)
}
// Getting admin data or smth idk
#[get("api/admin/{id}")]
async fn api_admin(id: web::Path<i32>) -> Json<CommonAdmin> {
let fetched_admin_data = get_admin(&mut establish_connection(), *id);
Json(fetched_admin_data)
}
#[get("api/driver/{id}")]
async fn api_driver(id: web::Path<i32>) -> Json<CommonDriver> {
let fetched_driver_data = get_driver(&mut establish_connection(), *id);
Json(fetched_driver_data)
}
#[get("api/test")]
async fn api_test() -> impl Responder {
HttpResponse::Ok().body("My balls are on fire :(")
}
pub mod api;
use crate::api::*;
pub(crate) use actix_web::{App, HttpServer};
//Main function where all the api calls are
//attached as services to backend
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {