diff options
Diffstat (limited to 'core/http/server.ts')
-rw-r--r-- | core/http/server.ts | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/core/http/server.ts b/core/http/server.ts index 7781a22..7e77e19 100644 --- a/core/http/server.ts +++ b/core/http/server.ts @@ -4,21 +4,28 @@ import "../../util/string.ts"; import RawCore from "../raw/api.ts"; import { ConnectionProps, ConnectionPropsDefault } from "./props.ts"; -import { CoreRequest, CoreRequestParseSentence, CoreResponseParseSentence } from "./types.ts"; +import { CoreRequest, CoreRequestSearchSentence, CoreRequestSearchTerms, CoreResponseSearchSentence, CoreResponseSearchTerms } from "./types.ts"; export default class RemoteCoreServer extends RawCore { private props: ConnectionProps; private handlers: Record<string, (req: CoreRequest) => Promise<Response>> = { - parseSentence: async _req => { - var req = _req as CoreRequestParseSentence; - var input = req.options?.input - var options = req.options?.options; - if (!input) return new Response("", { status: 404 }); + "search.terms": async _req => { + var req = _req as CoreRequestSearchTerms; + var term = req.options?.term; + if (!term) return new Response("", { status: 404 }); return new Response(JSON.stringify({ - command: "parseSentence", - response: await this.parseSentence(input, options), - } as CoreResponseParseSentence)); + response: await this.search.terms(term), + } as CoreResponseSearchTerms)); + }, + "search.sentence": async _req => { + var req = _req as CoreRequestSearchSentence; + var sentence = req.options?.sentence + var optional = req.options?.optional; + if (!sentence) return new Response("", { status: 404 }); + return new Response(JSON.stringify({ + response: await this.search.sentence(sentence, optional), + } as CoreResponseSearchSentence)); }, }; |