fix ship problem
This commit is contained in:
parent
e08df26ab3
commit
b2e2ef5f0b
@ -4,10 +4,11 @@ import { createShip } from "@/src/services/shipService";
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
const getShipController: RequestHandler = async (_req, res) => {
|
const getShipController: RequestHandler = async (req, res) => {
|
||||||
const accountId = _req.query.accountId;
|
const accountId = req.query.accountId;
|
||||||
const ship = await Ship.findOne({ ShipOwnerId: accountId });
|
const ship = await Ship.findOne({ ShipOwnerId: accountId });
|
||||||
if (!ship) {
|
if (!ship) {
|
||||||
|
// previously registered account
|
||||||
const account = await Account.findOne({ _id: accountId });
|
const account = await Account.findOne({ _id: accountId });
|
||||||
if (account) {
|
if (account) {
|
||||||
await createShip(account._id);
|
await createShip(account._id);
|
||||||
|
@ -8,9 +8,9 @@ const createShip = async (accountOwnerId: Types.ObjectId) => {
|
|||||||
await ship.save();
|
await ship.save();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof 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");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user