Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed company offers route to /company/:companyid/offers #342

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions src/api/routes/company.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as validators from "../middleware/validators/company.js";
import * as companyMiddleware from "../middleware/company.js";
import * as authMiddleware from "../middleware/auth.js";
import * as offerMiddleware from "../middleware/offer.js";
import * as companyValidators from "../middleware/validators/company.js";
import CompanyService from "../../services/company.js";
import { ErrorTypes } from "../middleware/errorHandler.js";
import ValidationReasons from "../middleware/validators/validationReasons.js";
Expand Down Expand Up @@ -253,4 +254,19 @@ export default (app) => {
}
}
);

/**
* Gets all the offers of a certain company from the db
*/
router.get("/:companyId/offers", companyValidators.getOffers, async (req, res, next) => {
try {
const offers = await (new OfferService())
.getOffersByCompanyId(req.params.companyId, req.targetOwner, req.hasAdminPrivileges);

return res.json(offers);
} catch (err) {
return next(err);
}
});

};
15 changes: 0 additions & 15 deletions src/api/routes/offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { ErrorTypes, APIError } from "../middleware/errorHandler.js";
import ValidationReasons from "../middleware/validators/validationReasons.js";
import { or, when } from "../middleware/utils.js";
import OfferConstants from "../../models/constants/Offer.js";
import * as companyValidators from "../middleware/validators/company.js";

const router = Router();

Expand Down Expand Up @@ -63,20 +62,6 @@ export default (app) => {
}
});

/**
* Gets all the offers of a certain company from the db
*/
router.get("/company/:companyId", companyValidators.getOffers, async (req, res, next) => {
try {
const offers = await (new OfferService())
.getOffersByCompanyId(req.params.companyId, req.targetOwner, req.hasAdminPrivileges);

return res.json(offers);
} catch (err) {
return next(err);
}
});

/**
* Creates a new Offer
*/
Expand Down
Loading