-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
91 changed files
with
2,531 additions
and
2,315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Organization, User as PrismaUser } from '@prisma/client'; | ||
|
||
declare global { | ||
namespace Express { | ||
export interface Request { | ||
currentUser: PrismaUser; | ||
organization: Organization; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
import { NextFunction, Request, Response } from 'express'; | ||
import CarsService from '../services/car.services'; | ||
import { getCurrentUser } from '../utils/auth.utils'; | ||
import { getOrganizationId } from '../utils/utils'; | ||
|
||
export default class CarsController { | ||
static async getAllCars(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
const organizationId = getOrganizationId(req.headers); | ||
await getCurrentUser(res); | ||
const cars = await CarsService.getAllCars(organizationId); | ||
const cars = await CarsService.getAllCars(req.organization); | ||
|
||
res.status(200).json(cars); | ||
return res.status(200).json(cars); | ||
} catch (error: unknown) { | ||
next(error); | ||
return next(error); | ||
} | ||
} | ||
|
||
static async createCar(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
const organizationId = getOrganizationId(req.headers); | ||
const user = await getCurrentUser(res); | ||
const { name } = req.body; | ||
const car = await CarsService.createCar(organizationId, user, name); | ||
const car = await CarsService.createCar(req.organization, req.currentUser, name); | ||
|
||
res.status(201).json(car); | ||
return res.status(201).json(car); | ||
} catch (error: unknown) { | ||
next(error); | ||
return next(error); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 17 additions & 25 deletions
42
src/backend/src/controllers/description-bullets.controllers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,60 @@ | ||
import { NextFunction, Request, Response } from 'express'; | ||
import DescriptionBulletsService from '../services/description-bullets.services'; | ||
import { getCurrentUser } from '../utils/auth.utils'; | ||
import { getOrganizationId } from '../utils/utils'; | ||
|
||
export default class DescriptionBulletsController { | ||
static async checkDescriptionBullet(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
const { descriptionId } = req.body; | ||
const user = await getCurrentUser(res); | ||
const organizationId = getOrganizationId(req.headers); | ||
|
||
const updatedDB = await DescriptionBulletsService.checkDescriptionBullet(user, descriptionId, organizationId); | ||
res.status(200).json(updatedDB); | ||
const updatedDB = await DescriptionBulletsService.checkDescriptionBullet( | ||
req.currentUser, | ||
descriptionId, | ||
req.organization | ||
); | ||
return res.status(200).json(updatedDB); | ||
} catch (error: unknown) { | ||
next(error); | ||
return next(error); | ||
} | ||
} | ||
|
||
static async getAllDescriptionBulletTypes(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
const organizationId = getOrganizationId(req.headers); | ||
|
||
const descriptionBulletTypes = await DescriptionBulletsService.getAllDescriptionBulletTypes(organizationId); | ||
res.status(200).json(descriptionBulletTypes); | ||
const descriptionBulletTypes = await DescriptionBulletsService.getAllDescriptionBulletTypes(req.organization); | ||
return res.status(200).json(descriptionBulletTypes); | ||
} catch (error: unknown) { | ||
next(error); | ||
return next(error); | ||
} | ||
} | ||
|
||
static async createDescriptionBulletType(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
const { name, workPackageRequired, projectRequired } = req.body; | ||
const organizationId = getOrganizationId(req.headers); | ||
const user = await getCurrentUser(res); | ||
|
||
const newDescriptionBulletType = await DescriptionBulletsService.createDescriptionBulletType( | ||
user, | ||
req.currentUser, | ||
name, | ||
workPackageRequired, | ||
projectRequired, | ||
organizationId | ||
req.organization | ||
); | ||
res.status(201).json(newDescriptionBulletType); | ||
} catch (error: unknown) { | ||
next(error); | ||
return next(error); | ||
} | ||
} | ||
|
||
static async editDescriptionBulletType(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
const { name, workPackageRequired, projectRequired } = req.body; | ||
const organizationId = getOrganizationId(req.headers); | ||
const user = await getCurrentUser(res); | ||
|
||
const updatedDescriptionBulletType = await DescriptionBulletsService.editDescriptionBulletType( | ||
user, | ||
req.currentUser, | ||
name, | ||
workPackageRequired, | ||
projectRequired, | ||
organizationId | ||
req.organization | ||
); | ||
res.status(200).json(updatedDescriptionBulletType); | ||
return res.status(200).json(updatedDescriptionBulletType); | ||
} catch (error: unknown) { | ||
next(error); | ||
return next(error); | ||
} | ||
} | ||
} |
Oops, something went wrong.