-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(templates): fix error handling and route method call
- Loading branch information
1 parent
c263563
commit f91c4fe
Showing
6 changed files
with
40 additions
and
16 deletions.
There are no files selected for viewing
12 changes: 9 additions & 3 deletions
12
application-templates/javascript/event/src/routes/event.route.js
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,13 +1,19 @@ | ||
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('/', async (req, res, next) => { | ||
logger.info('Event message received'); | ||
res.status(200); | ||
res.send(); | ||
|
||
try { | ||
await post(req.body); | ||
res.status(200).send(); | ||
} catch (error) { | ||
next(error); | ||
} | ||
}); | ||
|
||
export default eventRouter; |
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
13 changes: 10 additions & 3 deletions
13
application-templates/javascript/service/src/routes/service.route.js
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,12 +1,19 @@ | ||
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('/', async (req, res, next) => { | ||
logger.info('Cart update extension executed'); | ||
res.status(200); | ||
res.send(); | ||
|
||
try { | ||
// Add your custom logic here | ||
await post(req.body); | ||
res.status(200).send(); | ||
} catch (error) { | ||
next(error); | ||
} | ||
}); | ||
|
||
export default serviceRouter; |
11 changes: 8 additions & 3 deletions
11
application-templates/typescript/event/src/routes/event.route.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,13 +1,18 @@ | ||
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('/', async (req, res, next) => { | ||
logger.info('Event message received'); | ||
res.status(200); | ||
res.send(); | ||
try { | ||
await post(req, res); | ||
res.status(200).send(); | ||
} catch (error) { | ||
next(error); | ||
} | ||
}); | ||
|
||
export default eventRouter; |
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
16 changes: 11 additions & 5 deletions
16
application-templates/typescript/service/src/routes/service.route.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,12 +1,18 @@ | ||
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('/', async (req, res, next) => { | ||
logger.info('Service post message received'); | ||
|
||
try { | ||
await post(req, res); | ||
res.status(200).send(); | ||
} catch (error) { | ||
next(error); | ||
} | ||
}); | ||
|
||
export default serviceRouter; | ||
export default serviceRouter; |