Skip to content

Commit

Permalink
feat: users and applications CRUD operations, authentication & author…
Browse files Browse the repository at this point in the history
…ization (#8)

* Updated gitignore for MacOS

* Nest initial scaffolding,
Vite react-ts initial scaffolding, with working auth0 authentication,
token creation and axios client

* Revert "Nest initial scaffolding,"

This reverts commit f4edcad.

* wiped ci scripts

* Setup pnpm workspace

* Body validation working
Next step authorization

* Deleted remnaince of typeorm messup

* Authorization using jwt with a global guard
(may need revisiting for authorization)

* Revert "Authorization using jwt with a global guard"

This reverts commit 093356e.

* Auth with oauth2 official middleware

* Moved auth0 constants to config

* Small commit pre-merge

* Revert "Revert "Authorization using jwt with a global guard""

This reverts commit 018711c.

* Using app guard

* Now encoding user role in request,
better swagger annotations

* In the process of implementing authorization
IMPORTANT: changed build system, now both frontend and backend import typescript, compile it, watch it, do their own thing

* Fixed preview command with updated compiled file path

* First phase of authorization: simple rules
next step:
- casl + prisma (or other supported orms) to avoid weird logic,
and to filter the resource for the rows that are accessible to the current user
- oauth0 service to verify that some fields match the user's data on user creation

* Added access control to all user routes

* avaiabilitiesTable updated

* Proper validation with Joi of all request fields & prettier reformat

* Integrated previously written frontend with monorepo
moved fronted to vite cause speed (and typescript transpiling)
Formatting scripts

* Moved to env variables with env files instead of yaml config file for the api

* Ultima commit di Marco

* Application shared validation schemas

* Application entities, Create Application DTO

* Updated application schema

* Applications service and controller

* Added /v1 as a prefix to all APIs

* Updated shared application validation schemas

* Created ApplicationResponseDto

Added library to convert from DTOs to entities and viceversa

* Added UpdateApplicationDto

* Application controller, service, and repository

* Added CASL abilities on Applications

* Added ApplicationModule to the app modules

* Fixed query validation

* Updated gitignore

* Updated gitignore

* Updated gitignore

* Updated gitignore

* Updated gitignore

* Fixed avaiabilities Table placeholder

* Added required constraint on updateApplicationSchema, fixed typo

* feat(api): Application service unit tests

* refactor(api): Switched from fastify to express

* feat(api): Upload CV and Grades files to Google Drive

Restored GDrive module

Added googleapis and google-auth-library

* refactor(api): Moved business logic to ApplicationService

Remove files from Google Drive if an error occurs while creating the application

* Ran prettier

* test(api): Create applications of all types, Remove file if error occurs

* doc: Restored previous documentation, added API Routes section

* test(shared): Application validation, createApplicationSchema validation

* test(shared): Validation adn Ability tests for applications

* test(api): Applications controller tests

* fix: EoL set to 'lf' for system compatibility

* fix(api): modified mocks for timers

* Avaiabilities table fix

* Commit

* Tentativo di comunicazione col backend

* feat(shared): Slot, TimeSlot, Availability interfaces

* test(shared): Availability update schema

* Decoding access token

* Disabled google tests; formatted frontend

* Attempt to replace placeholders in the fill variable with interviews

* fix: Updated broken imports

* fix(server): TypeORM single table inheritance discriminator field

* test(server): updated Applications tests to account for new returned fields

* feat(server) Timeslot controller: POST and DELETE timeslots, with tests

* refactor: uncommented tests, added .skip to not execute them

* fix: pnpm version mismatch

---------

Co-authored-by: Vincenzo Pellegrini <[email protected]>
Co-authored-by: Marco Pappalardo <[email protected]>
Co-authored-by: Marco De Luca <[email protected]>
  • Loading branch information
4 people committed Nov 10, 2023
1 parent 9828dea commit 4dc60a1
Show file tree
Hide file tree
Showing 70 changed files with 5,289 additions and 55 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Use LF line endings
*.ts text eol=lf
*.tsx text eol=lf
*.js text eol=lf
*.jsx text eol=lf
*.json text eol=lf
*.css text eol=lf
*.text text eol=lf
*.md text eol=lf
2 changes: 1 addition & 1 deletion .github/workflows/fullstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 7
version: 8
run_install: false

- name: Get pnpm store directory
Expand Down
6 changes: 0 additions & 6 deletions api/.gitignore

This file was deleted.

3 changes: 2 additions & 1 deletion api/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all"
"trailingComma": "all",
"endOfLine": "lf"
}
8 changes: 8 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"@nestjs/typeorm": "^9.0.1",
"@types/js-yaml": "^4.0.5",
"@types/passport-jwt": "^3.0.7",
"class-transformer": "^0.5.1",
"google-auth-library": "^8.7.0",
"googleapis": "^118.0.0",
"dotenv": "^16.0.3",
"joi": "^17.7.0",
"js-yaml": "^4.1.0",
Expand All @@ -46,6 +49,7 @@
"webpack": "^5.75.0"
},
"devDependencies": {
"@types/multer": "^1.4.7",
"@automock/jest": "^1.0.1",
"@golevelup/ts-jest": "^0.3.6",
"@nestjs/cli": "^9.0.0",
Expand Down Expand Up @@ -93,6 +97,10 @@
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"moduleNameMapper": {
"^@mocks/(.*)$": "<rootDir>/src/mocks/$1"
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
4 changes: 4 additions & 0 deletions api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
import { UsersModule } from './users/users.module';
import { ApplicationsModule } from './application/applications.module';
import { TimeSlotsModule } from './timeslots/timeslots.module';
import { AuthenticationModule } from './authentication/authentication.module';
import { APP_GUARD } from '@nestjs/core';
import { JwtGuard } from './authentication/jwt-guard.guard';
Expand Down Expand Up @@ -29,6 +31,8 @@ import { AuthorizationGuard } from './authorization/authorization.guard';
inject: [ConfigService],
}),
UsersModule,
ApplicationsModule,
TimeSlotsModule,
AuthenticationModule,
AuthorizationModule,
],
Expand Down
30 changes: 30 additions & 0 deletions api/src/application/application-response.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
Application,
ApplicationState,
ApplicationType,
LangLevel,
} from '@hkrecruitment/shared';
import { Exclude, Expose } from 'class-transformer';

@Exclude()
export class ApplicationResponseDto implements Partial<Application> {
@Expose() id: number;
@Expose() submission: string;
@Expose() state: ApplicationState;
@Expose() itaLevel: LangLevel;
@Expose() type: ApplicationType;

@Expose() bscStudyPath?: string;
@Expose() bscAcademicYear?: number;
@Expose() bscGradesAvg?: number;
@Expose() cfu?: number;

@Expose() mscStudyPath?: string;
@Expose() mscGradesAvg?: number;
@Expose() mscAcademicYear?: number;

@Expose() phdDescription?: string;

// @Expose()
// applicant: ApplicantDto
}
4 changes: 4 additions & 0 deletions api/src/application/application-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type ApplicationFiles = {
cv: Express.Multer.File[];
grades?: Express.Multer.File[];
};
87 changes: 87 additions & 0 deletions api/src/application/application.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import {
Column,
Entity,
ChildEntity,
PrimaryGeneratedColumn,
TableInheritance,
} from 'typeorm';
import {
Application as ApplicationInterface,
ApplicationState,
ApplicationType,
LangLevel,
} from '@hkrecruitment/shared';
// import { TimeSlot } from '@hkrecruitment/shared/slot';

@Entity()
@TableInheritance({ column: 'type' }) // TypeORM column to discriminate child entities
export class Application implements ApplicationInterface {
@PrimaryGeneratedColumn('increment')
id: number;

@Column()
type: ApplicationType;

@Column('varchar', { length: 64, name: 'applicant_id' })
applicantId: string;

@Column()
submission: Date;

@Column()
state: ApplicationState;

@Column({ name: 'last_modified', nullable: true })
lastModified: Date;

@Column({ nullable: true, length: 255 })
notes?: string;

@Column({ length: 255 })
cv: string;

// @Column()
// availability: TimeSlot[];

// @Column({ "name": "interview_id" })
// interviewId: number;

@Column({ name: 'ita_level' })
itaLevel: LangLevel;
}

@ChildEntity(ApplicationType.BSC)
export class BscApplication extends Application {
@Column({ name: 'bsc_study_path', nullable: true })
bscStudyPath: string;

@Column({ name: 'bsc_academic_year', nullable: true })
bscAcademicYear: number;

@Column({ name: 'bsc_grades_avg', nullable: true })
bscGradesAvg: number;

@Column({ nullable: true })
cfu: number;

@Column({ nullable: true, length: 255 })
grades: string;
}

@ChildEntity(ApplicationType.MSC)
export class MscApplication extends Application {
@Column({ name: 'msc_study_path', nullable: true })
mscStudyPath: string;

@Column({ name: 'msc_grades_avg', nullable: true })
mscGradesAvg: number;

@Column({ name: 'msc_academic_year', nullable: true })
mscAcademicYear: number;
}

@ChildEntity(ApplicationType.PHD)
export class PhdApplication extends Application {
@Column({ name: 'phd_description', nullable: true })
phdDescription: string;
}
Loading

0 comments on commit 4dc60a1

Please sign in to comment.