From 8149c0f3b822e82ab3269d338d8d1e7fa1a3b56d Mon Sep 17 00:00:00 2001 From: lihbr Date: Mon, 7 Jun 2021 10:45:00 +0200 Subject: [PATCH] refactor: make endpoint not default to /api --- src/const.ts | 2 +- src/core/client.ts | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/const.ts b/src/const.ts index d3b0b34..3ad93e6 100644 --- a/src/const.ts +++ b/src/const.ts @@ -6,7 +6,7 @@ export const DESCRIPTION = pkg.description; export const VERSION = pkg.version; export const RC_FILE = ".dicorc"; export const CONFIG_FILE = "dico.config.json"; -export const API_ENDPOINT = "https://api.dico.app/v1/cli"; +export const API_ENDPOINT = "https://api.dico.app/v1"; export const DEFAULT_SOURCES_PATTERN = [ "src/**/*.(js|jsx)", "src/**/*.(ts|tsx)", diff --git a/src/core/client.ts b/src/core/client.ts index 8a68ea1..451c9b8 100644 --- a/src/core/client.ts +++ b/src/core/client.ts @@ -60,7 +60,7 @@ export const user = { run: async (token: string): Promise["user"]> => { const { data: { fullname, email } - } = await fetch["user"]>("/whoami", token); + } = await fetch["user"]>("/cli/whoami", token); return { token, @@ -75,7 +75,7 @@ export const dico = { select: { all: { run: async (token?: string): Promise => { - const { data } = await fetch("/dico", token); + const { data } = await fetch("/cli/dico", token); return data; } @@ -87,7 +87,10 @@ export const structure = { select: { byDicoSlug: { run: async (slug: string, token?: string): Promise => { - const { data } = await fetch(`/structure/${slug}`, token); + const { data } = await fetch( + `/cli/structure/${slug}`, + token + ); return data; } @@ -101,10 +104,14 @@ export const structure = { schema: ConfigJSON["schema"], token?: string ): Promise => { - const { data } = await fetch(`/structure/${slug}`, token, { - method: "PUT", - body: { schema } - }); + const { data } = await fetch( + `/cli/structure/${slug}`, + token, + { + method: "PUT", + body: { schema } + } + ); return data; }