aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/http/server.ts25
-rw-r--r--core/http/types.ts3
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>;
};