2023-06-05 04:16:49 +08:00
|
|
|
import { Ship } from "@/src/models/shipModel";
|
2023-05-19 15:22:48 -03:00
|
|
|
import { RequestHandler } from "express";
|
|
|
|
|
2023-06-05 04:16:49 +08:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
2023-06-05 00:17:01 +02:00
|
|
|
const getShipController: RequestHandler = async (req, res) => {
|
|
|
|
const accountId = req.query.accountId;
|
2023-06-05 04:16:49 +08:00
|
|
|
const ship = await Ship.findOne({ ShipOwnerId: accountId });
|
|
|
|
if (!ship) {
|
2023-06-05 00:17:01 +02:00
|
|
|
res.status(500).json({ error: "error finding a corresponding ship" });
|
|
|
|
return;
|
2023-06-05 04:16:49 +08:00
|
|
|
}
|
|
|
|
res.json(ship);
|
2023-05-19 15:22:48 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
export { getShipController };
|