Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial setup #101

Merged
merged 2 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions zyenyo-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 7 additions & 14 deletions zyenyo-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
1 change: 1 addition & 0 deletions zyenyo-backend/dummy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
14 changes: 6 additions & 8 deletions zyenyo-backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn get_user(context: web::Data<Context>, discordId: web::Path<String>) ->
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()),
}
Expand All @@ -44,7 +44,6 @@ async fn get_user(context: web::Data<Context>, discordId: web::Path<String>) ->
#[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");
Expand All @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions zyenyo-frontend/package-lock.json

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

1 change: 1 addition & 0 deletions zyenyo-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@heroicons/react": "^2.1.1",
"axios": "^1.6.2",
"next": "14.0.4",
"react": "^18",
Expand Down
9 changes: 5 additions & 4 deletions zyenyo-frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<main className="flex min-h-screen flex-col items-center p-24 bg-[#1E1F22] text-white">
<div className='flex flex-row gap-0 text-9xl mb-10'>
<div className='text-white'>Zyenyo</div><div className='text-[#F51A1F]'>Bot</div>
</div>
<main className="flex min-h-screen flex-col items-center p-24 bg-zinc-900 text-white">

<Dashboard/>

<TestComponent />
</main>
)
Expand Down
48 changes: 48 additions & 0 deletions zyenyo-frontend/src/components/HomePage/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -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";

<CommandLineIcon className="h-6 w-6 text-gray-500" />

import Link from "next/link";

<StarIcon className="h-6 w-6 text-gray-500" />

import {useEffect, useState} from "react"

const Dashboard = () => {

return (
<>
<div className='flex flex-row gap-0 text-6xl md:text-9xl'>
<div className='text-white underline underline-offset-8'>Zyenyo</div><div className='text-[#F51A1F]'>Bot</div>
</div>
<div className="flex flex-col mt-auto mb-auto gap-3">

<a className="relative hover:bg-zinc-800 ease-in p-6 gap-3 min-w-[250px] text-center border-2 border-white rounded-3xl text-lg font-bold" href="https://discord.com/api/oauth2/authorize?client_id=696614233944752130&permissions=137439283200&scope=bot" target="_blank">

<StarIcon className="absolute left-5 top-auto bottom-auto h-8 -translate-y-[2px] w-8 text-[#F51A1F]" />
Get Zyenyo
</a>

<Link className="relative hover:bg-zinc-800 ease-in p-6 gap-3 min-w-[250px] text-center border-2 border-white rounded-3xl text-lg font-bold" href="/">

<CommandLineIcon className="absolute left-5 top-auto bottom-auto -translate-y-[2px] h-8 w-8 text-[#F51A1F]" />
Commands
</Link>

<Link className="relative hover:bg-zinc-800 ease-in p-6 gap-3 min-w-[250px] text-center border-2 border-white rounded-3xl text-lg font-bold" href="/">

<TrophyIcon className="absolute left-5 top-auto bottom-auto -translate-y-[2px] h-8 w-8 text-[#F51A1F]" />
Leaderboards
</Link>

</div>
</>

)
}

export default Dashboard
Loading