SpaceNinjaServer/src/services/shipService.ts

18 lines
569 B
TypeScript
Raw Normal View History

2023-06-05 04:16:49 +08:00
import { Ship } from "@/src/models/shipModel";
2023-06-05 00:17:01 +02:00
import new_ship from "@/static/fixed_responses/ship.json";
2023-06-05 04:16:49 +08:00
import { Types } from "mongoose";
const createShip = async (accountOwnerId: Types.ObjectId) => {
try {
const ship = new Ship({ ...new_ship, ShipOwnerId: accountOwnerId });
await ship.save();
} catch (error) {
if (error instanceof Error) {
2023-06-05 00:17:01 +02:00
throw new Error(`error creating ship" ${error.message}`);
2023-06-05 04:16:49 +08:00
}
2023-06-05 00:17:01 +02:00
throw new Error("error creating ship that is not of instance Error");
2023-06-05 04:16:49 +08:00
}
};
export { createShip };