Skip to content

Commit

Permalink
Merge branch 'main' into dev/timothy/move-to-central-config
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy-Gonzalez committed Nov 3, 2023
2 parents b70b02a + 28c1a04 commit 76f6ef5
Show file tree
Hide file tree
Showing 24 changed files with 7,533 additions and 6,773 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.eslintrc.cjs
tsconfig.json
coverage
8 changes: 6 additions & 2 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Vercel CLI
run: npm install --global vercel@latest
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Install modules
run: yarn
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Vercel CLI
run: npm install --global vercel@latest
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Install modules
run: yarn
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ dist
# Auto-generated HTML files
docs/
apidocs/
devdocs/
devdocs/
2 changes: 2 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import profileRouter from "./services/profile/profile-router.js";
import staffRouter from "./services/staff/staff-router.js";
import newsletterRouter from "./services/newsletter/newsletter-router.js";
import versionRouter from "./services/version/version-router.js";
import admissionRouter from "./services/admission/admission-router.js";

import { InitializeConfigReader } from "./middleware/config-reader.js";
import Models from "./database/models.js";
Expand Down Expand Up @@ -36,6 +37,7 @@ app.use("/newsletter/", newsletterRouter);
app.use("/profile/", profileRouter);
app.use("/staff/", staffRouter);
app.use("/user/", userRouter);
app.use("/admission/", admissionRouter);
app.use("/version/", versionRouter);

// Ensure that API is running
Expand Down
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const Config = {
DEFAULT_POINT_VALUE: 0,
DEFAULT_FOOD_WAVE: 0,

/* Limits */
LEADERBOARD_QUERY_LIMIT: 25,

/* Misc */
EVENT_ID_LENGTH: 32,
EVENT_BYTES_GEN: 16,
Expand Down
48 changes: 48 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
abstract class Constants {
// URLs
static readonly ADMIN_DEVICE: string = "admin";
static readonly DEV_DEVICE: string = "dev";
static readonly WEB_DEVICE: string = "web";
static readonly IOS_DEVICE: string = "ios";
static readonly ANDROID_DEVICE: string = "android";
static readonly DEFAULT_DEVICE: string = Constants.WEB_DEVICE;

private static readonly ADMIN_REDIRECT: string = "https://admin.hackillinois.org/auth/";
private static readonly DEV_REDIRECT: string = "https://adonix.hackillinois.org/auth/dev/";
private static readonly WEB_REDIRECT: string = "https://www.hackillinois.org/auth/";
private static readonly IOS_REDIRECT: string = "hackillinois://login/";
private static readonly ANDROID_REDIRECT: string = "hackillinois://login/";
static readonly DEFAULT_REDIRECT: string = this.WEB_REDIRECT;

static readonly REDIRECT_MAPPINGS: Map<string, string> = new Map<string, string>([
[this.ADMIN_DEVICE, this.ADMIN_REDIRECT],
[this.WEB_DEVICE, this.WEB_REDIRECT],
[this.IOS_DEVICE, this.IOS_REDIRECT],
[this.ANDROID_DEVICE, this.ANDROID_REDIRECT],
[Constants.DEFAULT_DEVICE, this.DEFAULT_REDIRECT],
[this.DEV_DEVICE, this.DEV_REDIRECT],
]);

static readonly GITHUB_OAUTH_CALLBACK: string = "https://adonix.hackillinois.org/auth/github/callback/";
static readonly GOOGLE_OAUTH_CALLBACK: string = "https://adonix.hackillinois.org/auth/google/callback/";
// static readonly GOOGLE_OAUTH_CALLBACK: string = "http://127.0.0.1:3000/auth/google/callback/";
// static readonly GITHUB_OAUTH_CALLBACK: string = "http://localhost:3000/auth/github/callback/";

static readonly METADATA_URL: string = "https://hackillinois.github.io/adonix-metadata/config.json";

static readonly SYSTEM_ADMIN_LIST: string[] = (process.env.SYSTEM_ADMINS ?? "").split(",");

static readonly DEFAULT_JWT_OFFSET: string = "24h";

// Constants for general usage
static readonly ZERO: number = 0;
static readonly EVENT_ID_LENGTH: number = 32;
static readonly EVENT_BYTES_GEN: number = 16;
static readonly MILLISECONDS_PER_SECOND: number = 1000;
static readonly DEFAULT_POINT_VALUE: number = 0;
static readonly DEFAULT_FOOD_WAVE: number = 0;
static readonly LEADERBOARD_QUERY_LIMIT: number = 25;
static readonly QR_EXPIRY_TIME: string = "20s";
}

export default Constants;
2 changes: 1 addition & 1 deletion src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export enum Database {
AUTH = "auth",
USER = "user",
EVENT = "event",
DECISION = "decision",
ADMISSION = "admission",
ATTENDEE = "attendee",
NEWSLETTER = "newsletter",
REGISTRATION = "registration",
Expand Down
19 changes: 4 additions & 15 deletions src/database/decision-db.ts → src/database/admission-db.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { prop } from "@typegoose/typegoose";

enum DecisionStatus {
export enum DecisionStatus {
TBD = "TBD",
ACCEPTED = "ACCEPTED",
REJECTED = "REJECTED",
WAITLISTED = "WAITLISTED",
}

enum DecisionResponse {
export enum DecisionResponse {
PENDING = "PENDING",
ACCEPTED = "ACCEPTED",
DECLINED = "DECLINED",
}

export class DecisionInfo {
export class AdmissionDecision {
@prop({ required: true })
public userId: string;

Expand All @@ -22,21 +22,10 @@ export class DecisionInfo {

@prop({ required: true })
public response: DecisionResponse;
}

export class DecisionEntry {
@prop({ required: true })
public userId: string;

@prop({ required: true })
public wave: number;

@prop({ required: true })
public reviewer: string;

@prop({ required: true })
public timestamp: number;

@prop({ required: true })
public decision: DecisionStatus;
public emailSent: boolean;
}
4 changes: 2 additions & 2 deletions src/database/event-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class PublicEvent extends BaseEvent {
@prop({ required: true })
public displayOnStaffCheckIn: boolean;

@prop({ required: true })
@prop()
public sponsor: string;

@prop({ required: true })
Expand All @@ -101,7 +101,7 @@ export class PublicEvent extends BaseEvent {
this.eventType = baseEvent.publicEventType ?? "OTHER";
this.isPrivate = baseEvent.isPrivate ?? false;
this.displayOnStaffCheckIn = baseEvent.displayOnStaffCheckIn ?? false;
this.sponsor = baseEvent.sponsor ?? "None";
this.sponsor = baseEvent.sponsor ?? "";
this.points = baseEvent.points ?? Config.DEFAULT_POINT_VALUE;
}
}
Expand Down
27 changes: 14 additions & 13 deletions src/database/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { Database, generateConfig } from "../database.js";

import { AuthInfo } from "./auth-db.js";
import { AttendeeMetadata, AttendeeProfile } from "./attendee-db.js";
import { DecisionEntry, DecisionInfo } from "./decision-db.js";
import { AdmissionDecision } from "./admission-db.js";
import { EventAttendance, EventMetadata, PublicEvent, StaffEvent } from "./event-db.js";
import { NewsletterSubscription } from "./newsletter-db.js";
import { Application, RegistrationInfo } from "./registration-db.js";
import { RegistrationApplication, RegistrationInfo } from "./registration-db.js";
import { UserAttendance, UserInfo } from "./user-db.js";
import { AnyParamConstructor } from "@typegoose/typegoose/lib/types.js";

Expand All @@ -22,9 +22,8 @@ enum AuthCollection {
INFO = "info",
}

enum DecisionCollection {
INFO = "info",
ENTRIES = "entries",
enum AdmissionCollection {
DECISION = "decision",
}

enum EventCollection {
Expand Down Expand Up @@ -61,9 +60,8 @@ export default class Models {
static AttendeeProfile: mongoose.Model<AttendeeProfile> = undefined!;
// Auth
static AuthInfo: mongoose.Model<AuthInfo> = undefined!;
// Decision
static DecisionInfo: mongoose.Model<DecisionInfo> = undefined!;
static DecisionEntry: mongoose.Model<DecisionEntry> = undefined!;
// Admission
static AdmissionDecision: mongoose.Model<AdmissionDecision> = undefined!;
// Event
static StaffEvent: mongoose.Model<StaffEvent> = undefined!;
static PublicEvent: mongoose.Model<PublicEvent> = undefined!;
Expand All @@ -73,7 +71,7 @@ export default class Models {
static NewsletterSubscription: mongoose.Model<NewsletterSubscription> = undefined!;
// Registration
static RegistrationInfo: mongoose.Model<RegistrationInfo> = undefined!;
static Application: mongoose.Model<Application> = undefined!;
static RegistrationApplication: mongoose.Model<RegistrationApplication> = undefined!;
// User
static UserInfo: mongoose.Model<UserInfo> = undefined!;
static UserAttendance: mongoose.Model<UserAttendance> = undefined!;
Expand All @@ -82,15 +80,18 @@ export default class Models {
this.AttendeeMetadata = getModel(AttendeeMetadata, Database.ATTENDEE, AttendeeCollection.METADATA);
this.AttendeeProfile = getModel(AttendeeProfile, Database.ATTENDEE, AttendeeCollection.PROFILE);
this.AuthInfo = getModel(AuthInfo, Database.AUTH, AuthCollection.INFO);
this.DecisionInfo = getModel(DecisionInfo, Database.DECISION, DecisionCollection.INFO);
this.DecisionEntry = getModel(DecisionEntry, Database.DECISION, DecisionCollection.ENTRIES);
this.AdmissionDecision = getModel(AdmissionDecision, Database.ADMISSION, AdmissionCollection.DECISION);
this.StaffEvent = getModel(StaffEvent, Database.EVENT, EventCollection.STAFF_EVENTS);
this.PublicEvent = getModel(PublicEvent, Database.EVENT, EventCollection.PUBLIC_EVENTS);
this.EventMetadata = getModel(EventMetadata, Database.EVENT, EventCollection.METADATA);
this.EventAttendance = getModel(EventAttendance, Database.EVENT, EventCollection.ATTENDANCE);
this.NewsletterSubscription = getModel(NewsletterSubscription, Database.NEWSLETTER, NewsletterCollection.SUBSCRIPTIONS);
this.RegistrationInfo = getModel(RegistrationInfo, Database.DECISION, RegistrationCollection.INFO);
this.Application = getModel(Application, Database.DECISION, RegistrationCollection.APPLICATION);
this.RegistrationInfo = getModel(RegistrationInfo, Database.REGISTRATION, RegistrationCollection.INFO);
this.RegistrationApplication = getModel(
RegistrationApplication,
Database.REGISTRATION,
RegistrationCollection.APPLICATION,
);
this.UserInfo = getModel(UserInfo, Database.USER, UserCollection.INFO);
this.UserAttendance = getModel(UserAttendance, Database.USER, UserCollection.ATTENDANCE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/database/registration-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class RegistrationInfo {
public userName: string;
}

export class Application {
export class RegistrationApplication {
@prop({ required: true })
public _id: string;

Expand Down
6 changes: 6 additions & 0 deletions src/services/admission/admission-formats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { DecisionStatus } from "database/admission-db.js";

export interface ApplicantDecisionFormat {
userId: string;
status: DecisionStatus;
}
Loading

0 comments on commit 76f6ef5

Please sign in to comment.