Giter VIP home page Giter VIP logo

deerhacks-backend's Introduction

DeerHacks API

DeerHacks Image

DeerHacks Hackathon 2024 Backend API

Website Status

Setup

  1. Run go build to install dependencies
  2. Add the required .env file with the schema specified below
  3. Gather credentials from microservices and add it to the .env file

Relevant URL'S

Getting Started

First, run the development server:

go run main.go

Send API requests to http://localhost:8000 (assuming port specified in .env file is 8000) with tools like Postman

.env format

PORT=8000
DB_URL  =  "host=<server name here> user=<username here> password=<password here> dbname=<same as username> port=5432 sslmode=disable"
SECRET  =  "youcantypeanythingyouwanthere"

# From the Discord Developer Portal
CLIENT_ID  =  ""
CLIENT_SECRET  =  ""
BOT_TOKEN  =  ""
REDIRECT_URI  =  ""

# The discord server your discord bot will be in
GUILD_ID  =  "967161405017055342"

#Change this to "production" if public
APP_ENV  =  "development"
REGISTRATION_CUTOFF=1704085200  # (2024-01-01 00:00:00 EST)

# AWS IAM Credentials. Ensure full S3 access is given
AWS_ACCESS_KEY_ID  =  ""
AWS_SECRET_ACCESS_KEY  =  ""

# For sending emails
BREVO_API_KEY  =  ""

deerhacks-backend's People

Contributors

anthonytedja avatar dependabot[bot] avatar eruditeme avatar hana-dowe avatar hani64 avatar kevshinxp avatar multivalence avatar r4z33n4l1 avatar

Stargazers

 avatar

deerhacks-backend's Issues

Create QR-Check In Endpoint

Image

Frontend Types Schema:

export type QRCheckInReq = {
  qrId: string
  context: QRCheckInContext
}

export type QRCheckInResp = {
  success: boolean
  message: string
}

export type QRCheckInContext = keyof typeof QRCheckInContextEnum
const enum QRCheckInContextEnum {
  REGISTRATION = 'registration',
  DAY_1_DINNER = 'day_1_dinner',
  DAY_2_BREAKFAST = 'day_2_breakfast',
  DAY_2_LUNCH = 'day_2_lunch',
  DAY_2_DINNER = 'day_2_dinner',
  DAY_3_BREAKFAST = 'day_3_breakfast',
}

Create Update User endpoint

Request Schema:

POST Update User (/user-update)
*** can only update before registering
Request:
{
	name?: string
	email?: string
}

No Response only status code.

Reconfigure Rate Limits for Resume

  • get-resume should return update count and update-resume should only allow 3 requests per user. Modify the rate limiting for update-resume for this to happen
  • Remove rate limit for get-resume

Create Get Application Data endpoint

Request Schema:

GET Get Application Data (/application-get)
Request:
{Authorization in Cookies}
Response:
{
	is_draft: boolean
	application: {
Application data …
}
}

Setup Discord Bot to work with Backend

  • Make roles automatically update on discord based on the user status on the dashboard
  • Include a method in back-end to get discord token again if expired using refresh token

Create Update Application endpoint

Request Schema:

POST Update Application (/application-update)
Request & No Response (Look for 200 status code)
{
	is_draft: boolean
	application: {
Application data …
}
}

Ensure the validity of data:

  • Follows a given format (e.g. emails always have a @ and .)
  • Is not malicious (e.g. Code or SQL queries)
  • Follows enums specified in Front-end (e.g. Gender can only be Male, Female, Other. If it is something else, something is wrong)

Leave Resume for now. This will require integration with S3 which is not configured yet

Add Rejection emails

Add rejection emails in admin-user-update. Use templates with the brevo api instead of typing them into the code directly.

Implement Email Validation after registration

Criteria to follow as of October 30 2023:

  • Only allow 20 email updates per user per day.

  • Create a new table for email verifications which holds the context, token, user id, and expiry date (make expiry 1 day)

Update /user-update endpoint such that:

  • If email is parameter & update_limit field still has time left, return a forbidden status
  • If email is parameter & user status is pending, Send verification email & update user email to the new one given in request
  • If email is parameter & user status is registering, resend verification email if DB email is different & make status back to pending otherwise do nothing

Implementation Details:

  • Update user table to include a "update_limit" field. Every time someone changes their email, they must wait 2 hours to update it again

  • Generate a random uuid to represent the token for the email verification. You can do this with the existing uuid package in the project.

  • Save the token, expiry date, and user id to the new table you created and set the context to "email" (All email requests to user-update fall into the email context)

  • Send an email to the user which has the link "https://deerhacks.ca/verify?token={token here}"

  • If we are unable to send an email due to passing the 300 email limit, post pone the sending to tomorrow. Ensure we don't have more than 300 post poned emails.

Add /email-verify endpoint:

Image

  • Given the token, fetch the context and user from the table you created. If the context is "email" and the token is valid, update that corresponding user's status to "registering"

  • If the token is "rsvp" set status to "accepted"

Add Validation to Update Application Endpoint

Objectives:

  • Replace the validation within helpers/validateApplication.go with go-validator
  • Use Regex to enforce word limit for deerhack registration pitches (250 words but double check with docs)
  • Add validation for string options where an enum is used in the frontend

Update Resume Malware Detection

Research and implement a way to detect if malware is being uploaded through the resume-update endpoint and prevent it from being uploaded to s3 if so

Setup S3 for Resumes in Application

Setup S3 for Resumes such that the update-application endpoint uploads an applicants resume to S3. This data should then be fetched in the get-application endpoint.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.