Created
February 22, 2019 17:37
-
-
Save khaosdoctor/f8b22061003ea15d0b1ae1c3b9734da0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export function factory (service: ShipService, portService: PortService) { | |
return [ | |
/** | |
* Route handler | |
* ============= | |
*/ | |
rescue(async (req, res) => { | |
const ship = await service.delete(req.params.shipId, req.onBehalfOf) | |
await portService.undockShip(ship, 'Ship was deleted', req.onBehalfOf) | |
res.status(204).end() | |
}), | |
(err, _req, _res, next) => { | |
if (err instanceof ShipNotFoundError) return next(new HttpError.NotFound({ message: err.message, code: 'ship_not_found' })) | |
next(err) | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment