From 9cdc4b28c313f1c12936b6622f45a995b56e00aa Mon Sep 17 00:00:00 2001 From: akaster99 Date: Wed, 20 Sep 2023 16:03:23 +0900 Subject: [PATCH] feat: model check --- src/ainize.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ainize.ts b/src/ainize.ts index 68b849e..fed66ad 100644 --- a/src/ainize.ts +++ b/src/ainize.ts @@ -1,6 +1,6 @@ import * as NodeCache from "node-cache"; import Middleware from "./middlewares/middleware"; -import { DEFAULT_BILLING_CONFIG, getBlockChainEndpoint } from "./constants"; +import { DEFAULT_BILLING_CONFIG, Path, getBlockChainEndpoint } from "./constants"; import Handler from "./handlers/handler"; import AppController from "./controllers/appController"; import Model from "./model"; @@ -66,7 +66,12 @@ export default class Ainize { return this.model(modelName); } - model(modelName: string): Model { + async model(modelName: string): Promise { + const modelPath = Path.app(modelName).root(); + const modelData = await this.ain.getValue(modelPath); + if(!modelData) { + throw new Error("Model not found"); + } return new Model(modelName); }