From 0890e9d0e4dbc370ce8625158bb6d19a9b8754d3 Mon Sep 17 00:00:00 2001 From: Andrew882024 Date: Sun, 30 Nov 2025 15:20:23 -0800 Subject: [PATCH 1/7] update the type: Application and readme --- README.md | 13 +++++++++++++ server/types/Application.ts | 39 +++++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8b07c23..25b5c79 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,17 @@ ## Repo Structure - [`server`](./server/): backend + +to run the system: + +1, yarn install +2, docker-compose up -d +3, yarn run db:migrate +4, yarn dev + - [`client`](./client/): frontend + +to run the system: + +1, yarn install +2, yarn dev diff --git a/server/types/Application.ts b/server/types/Application.ts index ab5ddae..128e5c2 100644 --- a/server/types/Application.ts +++ b/server/types/Application.ts @@ -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; } From 34f51017b34593621d20d3335f0b518a6fec1411 Mon Sep 17 00:00:00 2001 From: Andrew882024 Date: Sun, 30 Nov 2025 16:03:10 -0800 Subject: [PATCH 2/7] make all item not optional --- server/types/Application.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/types/Application.ts b/server/types/Application.ts index 128e5c2..15ba7ba 100644 --- a/server/types/Application.ts +++ b/server/types/Application.ts @@ -21,19 +21,19 @@ export interface Application { // ### Optional Demographic Fields ### dietary: string[]; - underrepresented?: string; // added + underrepresented: string; // added gender: string; pronouns: string; ethnicity: 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 + 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 ### From 3eb2b209f4418a5cf2dc0569b34a154bb81e221a Mon Sep 17 00:00:00 2001 From: Andrew882024 Date: Sun, 30 Nov 2025 17:59:11 -0800 Subject: [PATCH 3/7] save --- server/api/validators/ResponseRequests.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/server/api/validators/ResponseRequests.ts b/server/api/validators/ResponseRequests.ts index a2d9c12..7a6f35a 100644 --- a/server/api/validators/ResponseRequests.ts +++ b/server/api/validators/ResponseRequests.ts @@ -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() @@ -116,6 +116,26 @@ export class Application implements IApplication { @Allow() // optional additionalComments: string; + + // ### Optional Demographic Fields ### + @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 { From 2e5ec800f8b65ea37d3d41617f615279319b0fe8 Mon Sep 17 00:00:00 2001 From: Andrew882024 Date: Sun, 30 Nov 2025 22:01:07 -0800 Subject: [PATCH 4/7] add test --- server/tests/application.test.ts | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 server/tests/application.test.ts diff --git a/server/tests/application.test.ts b/server/tests/application.test.ts new file mode 100644 index 0000000..81330da --- /dev/null +++ b/server/tests/application.test.ts @@ -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); + }); +}); From df2bcd7a1ad1efcfb5a892d3e7c46a1c52a4641d Mon Sep 17 00:00:00 2001 From: Andrew882024 Date: Mon, 1 Dec 2025 12:01:05 -0800 Subject: [PATCH 5/7] update readme --- README.md | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 25b5c79..b51cbd9 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,24 @@ - [`server`](./server/): backend -to run the system: + 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) -1, yarn install -2, docker-compose up -d -3, yarn run db:migrate -4, yarn dev + 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 + to run the system: + 1. `yarn install` + 2. `yarn dev` From 1b3c64305988c4e40a313af1b812cc2ebf6c70b7 Mon Sep 17 00:00:00 2001 From: Andrew882024 Date: Mon, 1 Dec 2025 12:17:08 -0800 Subject: [PATCH 6/7] fix code style --- server/api/validators/ResponseRequests.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/api/validators/ResponseRequests.ts b/server/api/validators/ResponseRequests.ts index 7a6f35a..d9eea25 100644 --- a/server/api/validators/ResponseRequests.ts +++ b/server/api/validators/ResponseRequests.ts @@ -120,20 +120,28 @@ export class Application implements IApplication { // ### Optional Demographic Fields ### @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 } From f11c44fb71460bf66f35761e64048a73097e8924 Mon Sep 17 00:00:00 2001 From: Andrew882024 Date: Mon, 1 Dec 2025 12:22:55 -0800 Subject: [PATCH 7/7] fix test style --- server/tests/application.test.ts | 120 +++++++++++++++---------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/server/tests/application.test.ts b/server/tests/application.test.ts index 81330da..a924c72 100644 --- a/server/tests/application.test.ts +++ b/server/tests/application.test.ts @@ -1,70 +1,70 @@ import 'reflect-metadata'; import { validate } from 'class-validator'; -import {Application} from '../api/validators/ResponseRequests'; +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!" + 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!" + 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