Skip to content

Commit

Permalink
refactor: make endpoint not default to /api
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed Jun 7, 2021
1 parent 61e1d6e commit 8149c0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
21 changes: 14 additions & 7 deletions src/core/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const user = {
run: async (token: string): Promise<Required<ConfigRC>["user"]> => {
const {
data: { fullname, email }
} = await fetch<Required<ConfigRC>["user"]>("/whoami", token);
} = await fetch<Required<ConfigRC>["user"]>("/cli/whoami", token);

return {
token,
Expand All @@ -75,7 +75,7 @@ export const dico = {
select: {
all: {
run: async (token?: string): Promise<Dico[]> => {
const { data } = await fetch<Dico[]>("/dico", token);
const { data } = await fetch<Dico[]>("/cli/dico", token);

return data;
}
Expand All @@ -87,7 +87,10 @@ export const structure = {
select: {
byDicoSlug: {
run: async (slug: string, token?: string): Promise<Structure> => {
const { data } = await fetch<Structure>(`/structure/${slug}`, token);
const { data } = await fetch<Structure>(
`/cli/structure/${slug}`,
token
);

return data;
}
Expand All @@ -101,10 +104,14 @@ export const structure = {
schema: ConfigJSON["schema"],
token?: string
): Promise<Structure> => {
const { data } = await fetch<Structure>(`/structure/${slug}`, token, {
method: "PUT",
body: { schema }
});
const { data } = await fetch<Structure>(
`/cli/structure/${slug}`,
token,
{
method: "PUT",
body: { schema }
}
);

return data;
}
Expand Down

0 comments on commit 8149c0f

Please sign in to comment.