From b2e2ef5f0b61d17339c76bf9d496559f166dd38c Mon Sep 17 00:00:00 2001 From: Master Date: Mon, 5 Jun 2023 04:34:58 +0800 Subject: [PATCH] fix ship problem --- src/controllers/api/getShipController.ts | 5 +++-- src/services/shipService.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/controllers/api/getShipController.ts b/src/controllers/api/getShipController.ts index 2da6f8b2..74643645 100644 --- a/src/controllers/api/getShipController.ts +++ b/src/controllers/api/getShipController.ts @@ -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); diff --git a/src/services/shipService.ts b/src/services/shipService.ts index 8d131f1a..964775a3 100644 --- a/src/services/shipService.ts +++ b/src/services/shipService.ts @@ -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"); } };