Skip to content

Commit

Permalink
fix(templates): fix error handling and route method call (#83)
Browse files Browse the repository at this point in the history
* fix(templates): fix error handling and route method call

* fix(routes): fix routes parameter calls
  • Loading branch information
ruidias-commercetools authored Jul 22, 2024
1 parent 492cca2 commit 5010723
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 20 deletions.
11 changes: 8 additions & 3 deletions application-templates/javascript/event/src/routes/event.route.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { Router } from 'express';

import { logger } from '../utils/logger.utils.js';
import { post } from '../controllers/event.controller.js';

const eventRouter = Router();

eventRouter.post('/', async (req, res) => {
eventRouter.post('/', (req, res, next) => {
logger.info('Event message received');
res.status(200);
res.send();

try {
post(req, res);
} catch (error) {
next(error);
}
});

export default eventRouter;
5 changes: 2 additions & 3 deletions application-templates/javascript/job/src/routes/job.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import { post } from '../controllers/job.controller.js';
// Create the router for our app
const jobRouter = Router();

jobRouter.post('/', async (req, res, next) => {
jobRouter.post('/', (req, res, next) => {
try {
await post(req, res);
next();
post(req, res);
} catch (error) {
next(error);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { Router } from 'express';
import { logger } from '../utils/logger.utils.js';
import { post } from '../controllers/service.controller.js';

const serviceRouter = Router();

serviceRouter.post('/', async (req, res) => {
serviceRouter.post('/', (req, res, next) => {
logger.info('Cart update extension executed');
res.status(200);
res.send();

try {
post(req, res);
} catch (error) {
next(error);
}
});

export default serviceRouter;
10 changes: 7 additions & 3 deletions application-templates/typescript/event/src/routes/event.route.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { Router } from 'express';

import { logger } from '../utils/logger.utils';
import { post } from '../controllers/event.controller';

const eventRouter: Router = Router();

eventRouter.post('/', async (req, res) => {
eventRouter.post('/', (req, res, next) => {
logger.info('Event message received');
res.status(200);
res.send();
try {
post(req, res);
} catch (error) {
next(error);
}
});

export default eventRouter;
5 changes: 2 additions & 3 deletions application-templates/typescript/job/src/routes/job.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import { post } from '../controllers/job.controller';
// Create the router for our app
const jobRouter: Router = Router();

jobRouter.post('/', async (req, res, next) => {
jobRouter.post('/', (req, res, next) => {
try {
await post(req, res);
next();
post(req, res);
} catch (error) {
next(error);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { Router } from 'express';
import { logger } from '../utils/logger.utils';
import { post } from '../controllers/service.controller';

const serviceRouter = Router();

serviceRouter.post('/', async (req, res) => {
logger.info('Cart update extension executed');
res.status(200);
res.send();
serviceRouter.post('/', (req, res, next) => {
logger.info('Service post message received');

try {
post(req, res);
} catch (error) {
next(error);
}
});

export default serviceRouter;
export default serviceRouter;

0 comments on commit 5010723

Please sign in to comment.