diff --git a/zyenyo-backend/Cargo.toml b/zyenyo-backend/Cargo.toml index 8c84fdf..52751c5 100644 --- a/zyenyo-backend/Cargo.toml +++ b/zyenyo-backend/Cargo.toml @@ -5,6 +5,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[[bin]] +name = "zyenyo-backend" +path = "src/main.rs" + [dependencies] actix-web = "4" mongodb = "2" diff --git a/zyenyo-backend/Dockerfile b/zyenyo-backend/Dockerfile index f1f422e..2118a64 100644 --- a/zyenyo-backend/Dockerfile +++ b/zyenyo-backend/Dockerfile @@ -1,30 +1,23 @@ # syntax=docker/dockerfile:1.4 FROM rust:buster AS base - WORKDIR /code -RUN cargo init -COPY Cargo.toml /code/Cargo.toml -RUN cargo fetch -COPY . /code FROM base AS development - +COPY . . EXPOSE 8000 - CMD [ "cargo", "run" ] FROM base AS builder +COPY dummy.rs . +COPY Cargo.toml . +RUN sed -i 's#src/main.rs#dummy.rs#' Cargo.toml +RUN cargo build --release +RUN sed -i 's#dummy.rs#src/main.rs#' Cargo.toml +COPY src ./src RUN cargo build --release FROM debian:buster-slim AS production - -ARG MONGO_URI -ENV ZYENYO_ENVIRONMENT=development -ENV MONGO_URI=$MONGO_URI - EXPOSE 8000 - COPY --from=builder /code/target/release/zyenyo-backend /zyenyo-backend - CMD [ "/zyenyo-backend" ] diff --git a/zyenyo-backend/dummy.rs b/zyenyo-backend/dummy.rs new file mode 100644 index 0000000..f328e4d --- /dev/null +++ b/zyenyo-backend/dummy.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/zyenyo-backend/src/main.rs b/zyenyo-backend/src/main.rs index c7205e1..3d26aaa 100644 --- a/zyenyo-backend/src/main.rs +++ b/zyenyo-backend/src/main.rs @@ -35,7 +35,7 @@ async fn get_user(context: web::Data, discordId: web::Path) -> match collection.find_one(doc! { "discordId": &discord_id }, None).await { Ok(Some(user)) => HttpResponse::Ok().json(user), Ok(None) => { - HttpResponse::NotFound().body(format!("No user found with discordId {discord_id}")) + HttpResponse::NotFound().body(format!("No user found with discord ID {discord_id}")) } Err(err) => HttpResponse::InternalServerError().body(err.to_string()), } @@ -44,7 +44,6 @@ async fn get_user(context: web::Data, discordId: web::Path) -> #[actix_web::main] async fn main() -> std::io::Result<()> { env::set_var("RUST_LOG", "debug"); - let uri = env::var("MONGO_URI").expect("database URI not provided"); let client = Client::with_uri_str(uri).await.expect("failed to connect to database"); let environment = env::var("ZYENYO_ENVIRONMENT").expect("ENVIRONMENT not provided"); @@ -54,13 +53,12 @@ async fn main() -> std::io::Result<()> { environment, }; - - HttpServer::new(move || { - let cors = Cors::default() - .allowed_origin("http://localhost:80") - .allowed_origin("http://localhost:8080") - .allowed_methods(vec!["GET", "POST"]); + let cors = match context.environment.as_str() { + "development" => Cors::permissive(), + "production" => Cors::default().allowed_origin("http://localhost:80").allowed_methods(vec!["GET", "POST"]), + _ => panic!() + }; App::new() .wrap(cors) diff --git a/zyenyo-frontend/package-lock.json b/zyenyo-frontend/package-lock.json index 52e398f..55a8359 100644 --- a/zyenyo-frontend/package-lock.json +++ b/zyenyo-frontend/package-lock.json @@ -8,6 +8,7 @@ "name": "zyenyo-frontend", "version": "0.1.0", "dependencies": { + "@heroicons/react": "^2.1.1", "axios": "^1.6.2", "next": "14.0.4", "react": "^18", @@ -114,6 +115,14 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@heroicons/react": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.1.1.tgz", + "integrity": "sha512-JyyN9Lo66kirbCMuMMRPtJxtKJoIsXKS569ebHGGRKbl8s4CtUfLnyKJxteA+vIKySocO4s1SkTkGS4xtG/yEA==", + "peerDependencies": { + "react": ">= 16" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.13", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", diff --git a/zyenyo-frontend/package.json b/zyenyo-frontend/package.json index 1f7a251..8c3a397 100644 --- a/zyenyo-frontend/package.json +++ b/zyenyo-frontend/package.json @@ -9,6 +9,7 @@ "lint": "next lint" }, "dependencies": { + "@heroicons/react": "^2.1.1", "axios": "^1.6.2", "next": "14.0.4", "react": "^18", diff --git a/zyenyo-frontend/src/app/page.tsx b/zyenyo-frontend/src/app/page.tsx index d5c43a3..9de9026 100644 --- a/zyenyo-frontend/src/app/page.tsx +++ b/zyenyo-frontend/src/app/page.tsx @@ -1,13 +1,14 @@ import Image from 'next/image' import axios from 'axios' import TestComponent from '@/components/TestComponent' +import Dashboard from '@/components/HomePage/Dashboard' export default function Home() { return ( -
-
-
Zyenyo
Bot
-
+
+ + +
) diff --git a/zyenyo-frontend/src/components/HomePage/Dashboard.tsx b/zyenyo-frontend/src/components/HomePage/Dashboard.tsx new file mode 100644 index 0000000..ce4842b --- /dev/null +++ b/zyenyo-frontend/src/components/HomePage/Dashboard.tsx @@ -0,0 +1,48 @@ +"use client" + +import { StarIcon } from "@heroicons/react/24/outline"; +import { TrophyIcon } from "@heroicons/react/24/outline"; +import { CommandLineIcon } from "@heroicons/react/24/outline"; + + + +import Link from "next/link"; + + + +import {useEffect, useState} from "react" + +const Dashboard = () => { + + return ( + <> +
+
Zyenyo
Bot
+
+
+ + + + + Get Zyenyo + + + + + + Commands + + + + + + Leaderboards + + +
+ + + ) +} + +export default Dashboard