diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-07-11 00:46:07 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-07-11 00:46:07 +0200 |
commit | 479836dbf3c7cc6e5940abe698ccc5e1d7b440c7 (patch) | |
tree | b799e4f584ea893e9c4f642dcbfb97c095104a8f /core | |
parent | 659f5acfd161d91dc8a9d0101535dcee585455ad (diff) |
fix http client/server and irregular suru/kuru readings for api/word.ts
Diffstat (limited to 'core')
-rw-r--r-- | core/http/server.ts | 25 | ||||
-rw-r--r-- | core/http/types.ts | 3 |
2 files changed, 16 insertions, 12 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)); }, }; diff --git a/core/http/types.ts b/core/http/types.ts index 51c221a..9edc2dc 100644 --- a/core/http/types.ts +++ b/core/http/types.ts @@ -7,7 +7,6 @@ export interface CoreRequest { }; export interface CoreResponse { - command: string; response: any; // final: boolean; }; @@ -21,7 +20,6 @@ export interface CoreRequestSearchSentence extends CoreRequest { }; export interface CoreResponseSearchSentence extends CoreResponse { - command: "search.sentence"; response: SearchSentenceResult; }; @@ -33,6 +31,5 @@ export interface CoreRequestSearchTerms extends CoreRequest { }; export interface CoreResponseSearchTerms extends CoreResponse { - command: "search.terms"; response: Array<SearchTermResult>; }; |