fix ship problem

This commit is contained in:
Master 2023-06-05 04:34:58 +08:00
parent e08df26ab3
commit b2e2ef5f0b
2 changed files with 5 additions and 4 deletions

View File

@ -4,10 +4,11 @@ import { createShip } from "@/src/services/shipService";
import { RequestHandler } from "express";
// eslint-disable-next-line @typescript-eslint/no-misused-promises
const getShipController: RequestHandler = async (_req, res) => {
const accountId = _req.query.accountId;
const getShipController: RequestHandler = async (req, res) => {
const accountId = req.query.accountId;
const ship = await Ship.findOne({ ShipOwnerId: accountId });
if (!ship) {
// previously registered account
const account = await Account.findOne({ _id: accountId });
if (account) {
await createShip(account._id);

View File

@ -8,9 +8,9 @@ const createShip = async (accountOwnerId: Types.ObjectId) => {
await ship.save();
} catch (error) {
if (error instanceof Error) {
throw new Error(`error creating inventory" ${error.message}`);
throw new Error(`error creating ship" ${error.message}`);
}
throw new Error("error creating inventory that is not of instance Error");
throw new Error("error creating ship that is not of instance Error");
}
};