Skip to content
Open
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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,25 @@
## Repo Structure

- [`server`](./server/): backend

setup:
1. install Node.js
2. install yarn
3. install Postgres (Even though our actual Postgres instance runs in a Docker container, we need to install Postgres to install the official pg Node package.)
4. install docker (we run Postgres in docker container)

to run the system: (in terminal)
1. `yarn install`
2. `cp .env.example .env` (you might need to add more info on env(such as S3_REGION) enable to run the system)
3. `docker-compose up -d`
4. `yarn run db:migrate`
5. `yarn dev`

- [`client`](./client/): frontend
setup:
1. install Node.js
2. install yarn

to run the system:
1. `yarn install`
2. `yarn dev`
30 changes: 29 additions & 1 deletion server/api/validators/ResponseRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Type } from 'class-transformer';
export class Application implements IApplication {
@IsDefined()
@IsPhoneNumber()
phoneNumber: string;
phoneNumber: string; //this IsPhoneNumber check is very strict, you need +country code in front

@IsDefined()
@IsNotEmpty()
Expand Down Expand Up @@ -116,6 +116,34 @@ export class Application implements IApplication {

@Allow() // optional
additionalComments: string;

// ### Optional Demographic Fields ###
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these be @Allow() if they aren't required?

@IsDefined()
underrepresented: string; // added

@IsDefined()
educationLevel: string; // added

@IsDefined()
tshirtSize: string; // added

@IsDefined()
address1Shipping: string; // added

@IsDefined()
address2Shipping: string; // added

@IsDefined()
cityShipping: string; // added

@IsDefined()
stateShipping: string; // added

@IsDefined()
countryShipping: string; // added

@IsDefined()
zipcodeShipping: string; // added
}

export class CreateApplicationRequest implements ICreateApplicationRequest {
Expand Down
85 changes: 85 additions & 0 deletions server/tests/application.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import 'reflect-metadata';
import { validate } from 'class-validator';
import { Application } from '../api/validators/ResponseRequests';

const VALID_APPLICATION = {
age: '19',
phoneNumber: '+18563188585',
university: 'University of California, San Diego',
levelOfStudy: 'Undergraduate University (3+ year)',
country: 'United States',
linkedin: 'https://www.linkedin.com/in/example-andrew-zhang/',
mlhCodeOfConduct: 'YES',
mlhAuthorization: 'YES',
mlhEmailAuthorization: 'NO',
dietary: ['None'],
underrepresented: 'No',
gender: 'Man',
pronouns: 'He/Him',
ethnicity: ['Asian'],
orientation: ['Heterosexual or straight'],
educationLevel: 'Undergraduate University (3+ year)',
tshirtSize: 'M',
address1Shipping: '1234 Sample St',
address2Shipping: 'Apt 567',
cityShipping: 'San Diego',
stateShipping: 'CA',
countryShipping: 'United States',
zipcodeShipping: '92092',
major: 'Computer science, computer engineering, or software engineering',
interests: ['AI', 'Web Development', 'Hackathons'],
referrer: ['Friend', 'ACM UCSD'],
motivation: '__INTEGRATION_TEST__',
resumeLink: 'https://example.com/resume.pdf',
willAttend: 'YES',
additionalComments: 'No special requests. Excited to join!',
};

const INVALID_APPLICATION = {
age: '19',
phoneNumber: '+18563188585',
university: 'University of California, San Diego',
levelOfStudy: 'Undergraduate University (3+ year)',
country: 'United States',
linkedin: 'https://www.linkedin.com/in/example-andrew-zhang/',
mlhCodeOfConduct: 'YES',
mlhAuthorization: 'YES',
mlhEmailAuthorization: 'NO',
dietary: ['None'],
underrepresented: 'No',
gender: 'Man',
pronouns: 'He/Him',
ethnicity: ['Asian'],
orientation: ['Heterosexual or straight'],
educationLevel: 'Undergraduate University (3+ year)',
tshirtSize: 'M',
address1Shipping: '1234 Sample St',
cityShipping: 'San Diego',
stateShipping: 'CA',
countryShipping: 'United States',
zipcodeShipping: '92092',
major: 'Computer science, computer engineering, or software engineering',
interests: ['AI', 'Web Development', 'Hackathons'],
referrer: ['Friend', 'ACM UCSD'],
motivation: '__INTEGRATION_TEST__',
resumeLink: 'https://example.com/resume.pdf',
willAttend: 'YES',
additionalComments: 'No special requests. Excited to join!',
};
// missing address2Shipping field

describe('Application Validation', () => {
it('should validate a correct application', async () => {
const application = Object.assign(new Application(), VALID_APPLICATION);
const errors = await validate(application);
expect(errors.length).toBe(0);
});
});

describe('Application Validation', () => {
it('should invalidate an incorrect application', async () => {
const application = Object.assign(new Application(), INVALID_APPLICATION);
const errors = await validate(application);
expect(errors.length).toBeGreaterThan(0);
});
});
39 changes: 31 additions & 8 deletions server/types/Application.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
export interface Application {
phoneNumber: string;
//link to Hackathon Organizers Guide:
//https://guide.mlh.io/general-information/managing-registrations/registrations#important-registration-fields
//(Some of following are multiple-choice questions, and options are in this guide.)

// ### Important Registration Fields ###
// firstName: string; from user model
// lastName: string; from user model
// email: string; from user model
age: string;
phoneNumber: string;
university: string;
levelOfStudy: string;
country: string;
linkedin: string;
gender: string;

// ### MLH Checkboxes ###
mlhCodeOfConduct: string;
mlhAuthorization: string;
mlhEmailAuthorization: string;

// ### Optional Demographic Fields ###
dietary: string[];
underrepresented: string; // added
gender: string;
pronouns: string;
orientation: string[];
ethnicity: string[];
dietary: string[];
interests: string[];
orientation: string[];
educationLevel: string; // added
tshirtSize: string; // added
address1Shipping: string; // added
address2Shipping: string; // added
cityShipping: string; // added
stateShipping: string; // added
countryShipping: string; // added
zipcodeShipping: string; // added
major: string;

// ### Not in official requirements list ###
interests: string[];
referrer: string[];
motivation: string;
resumeLink: string;
willAttend: string;
mlhCodeOfConduct: string;
mlhAuthorization: string;
mlhEmailAuthorization: string;
additionalComments: string;
}

Expand Down