SpaceNinjaServer/src/controllers/api/getShipController.ts

17 lines
502 B
TypeScript
Raw Normal View History

2023-06-05 05:55:36 +08:00
import { RequestHandler } from "express";
2023-06-05 01:22:52 +08:00
import { Ship } from "@/src/models/shipModel";
2023-06-05 03:13:46 +08:00
2023-06-05 01:22:52 +08:00
// eslint-disable-next-line @typescript-eslint/no-misused-promises
2023-06-05 05:55:36 +08:00
const getShipController: RequestHandler = async (req, res) => {
const accountId = req.query.accountId;
2023-06-05 01:22:52 +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 01:22:52 +08:00
}
res.json(ship);
2023-05-19 15:22:48 -03:00
};
export { getShipController };