From dfc154b711039a6fc436049170b655cea5e92a11 Mon Sep 17 00:00:00 2001 From: monoid Date: Fri, 15 Jan 2021 20:20:55 +0900 Subject: [PATCH] interface --- src/client/accessor/document.ts | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/client/accessor/document.ts b/src/client/accessor/document.ts index 36d25fa..89b4f56 100644 --- a/src/client/accessor/document.ts +++ b/src/client/accessor/document.ts @@ -15,6 +15,12 @@ export class FetchFailError implements Error{ } } export class ClientDocumentAccessor implements DocumentAccessor{ + async findByPath(basepath: string, filename?: string): Promise{ + throw new Error("not allowed"); + }; + async findDeleted(content_type: string): Promise{ + throw new Error("not allowed"); + }; async findList(option?: QueryListOption | undefined): Promise{ let res = await fetch(`${baseurl}/search?${option !== undefined ? toQueryString(option) : ""}`); if(res.status !== 200) throw new FetchFailError("findList Failed"); @@ -38,7 +44,10 @@ export class ClientDocumentAccessor implements DocumentAccessor{ const {id,...rest} = c; const res = await fetch(`${baseurl}/${id}`,{ method: "POST", - body: JSON.stringify(rest) + body: JSON.stringify(rest), + headers:{ + 'content-type':"application/json" + } }); const ret = await res.json(); return ret; @@ -47,7 +56,10 @@ export class ClientDocumentAccessor implements DocumentAccessor{ throw new Error("not allow"); const res = await fetch(`${baseurl}`,{ method: "POST", - body: JSON.stringify(c) + body: JSON.stringify(c), + headers:{ + 'content-type':"application/json" + } }); const ret = await res.json(); return ret; @@ -63,7 +75,10 @@ export class ClientDocumentAccessor implements DocumentAccessor{ const {id,...rest} = c; const res = await fetch(`${baseurl}/${id}/tags/${tag_name}`,{ method: "POST", - body: JSON.stringify(rest) + body: JSON.stringify(rest), + headers:{ + 'content-type':"application/json" + } }); const ret = await res.json(); return ret; @@ -72,7 +87,10 @@ export class ClientDocumentAccessor implements DocumentAccessor{ const {id,...rest} = c; const res = await fetch(`${baseurl}/${id}/tags/${tag_name}`,{ method: "DELETE", - body: JSON.stringify(rest) + body: JSON.stringify(rest), + headers:{ + 'content-type':"application/json" + } }); const ret = await res.json(); return ret;