Skip to content

Commit

Permalink
🐛 Change client endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Jun 7, 2021
1 parent 609c45a commit 67c3017
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api/_constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const BASE_URL = "https://registerable.vercel.app/";
export const BASE_URL = "https://api-registerable.vercel.app/";
export const VERSION = "v1";
2 changes: 1 addition & 1 deletion api/check_name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default async (req: ServerRequest) => {
if (N(validateResult)) {
return req.respond({
headers,
status: 403,
status: 400,
body: JSON.stringify({ error }),
});
}
Expand Down
18 changes: 9 additions & 9 deletions api/check_name_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { assertEquals } from "../dev_deps.ts";
import { RegisterableResult } from "../types/mod.ts";
import { REGISTRIES } from "../constants/registry.ts";
import { BASE_URL, VERSION } from "./_constants.ts";
const ENTPOINT = new URL(`api/${VERSION}`, BASE_URL).toString();
const ENTPOINT = new URL(VERSION, BASE_URL).toString();

Deno.test("check-name", async () => {
const table: [
Expand All @@ -14,7 +14,7 @@ Deno.test("check-name", async () => {
][] = [
[
ENTPOINT,
403,
400,
false,
{
error: "Name parameter is necessary",
Expand All @@ -38,23 +38,23 @@ Deno.test("check-name", async () => {
],
[
`${ENTPOINT}?name=fonction&hoge=huga`,
403,
400,
false,
{
error: "Invalid query parameter (hoge)",
},
],
[
`${ENTPOINT}?name=fonction&hoge=huga&test=test`,
403,
400,
false,
{
error: "Invalid query parameter (hoge, test)",
},
],
[
`${ENTPOINT}?hoge=huga&test=test`,
403,
400,
false,
{
error: "Invalid query parameter (hoge, test)",
Expand Down Expand Up @@ -91,7 +91,7 @@ Deno.test("check-name", async () => {
],
[
`${ENTPOINT}?name=fonction&registry=hoge.land`,
403,
400,
false,
{
error: `Invalid registry member (hoge.land) [valid: ${
Expand All @@ -103,7 +103,7 @@ Deno.test("check-name", async () => {
],
[
`${ENTPOINT}?name=fonction&registry=hoge.land&registry=huga.land`,
403,
400,
false,
{
error: `Invalid registry member (hoge.land, huga.land) [valid: ${
Expand All @@ -115,15 +115,15 @@ Deno.test("check-name", async () => {
],
[
`${ENTPOINT}?name=fonction&registry`,
403,
400,
false,
{
error: `Invalid registry member () [valid: ${REGISTRIES.join(", ")}]`,
},
],
[
`${ENTPOINT}?name=fonction&registry=`,
403,
400,
false,
{
error: `Invalid registry member () [valid: ${REGISTRIES.join(", ")}]`,
Expand Down
2 changes: 1 addition & 1 deletion api/stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Registry } from "../types/mod.ts";
import { BASE_URL, VERSION } from "./_constants.ts";

const stringify = (val: { name: string; registry: Registry[] }): string => {
const url = new URL(`api/${VERSION}`, BASE_URL);
const url = new URL(VERSION, BASE_URL);
url.search = constructSearchParams(val).toString();

return url.toString();
Expand Down
4 changes: 2 additions & 2 deletions api/stringify_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Deno.test("stringify", () => {
const table: [{ name: string; registry: Registry[] }, string][] = [[{
name: "fonction",
registry: [],
}, `${new URL(`api/${VERSION}`, BASE_URL)}?name=fonction`], [
}, `${new URL(VERSION, BASE_URL)}?name=fonction`], [
{
name: "fonction",
registry: ["deno.land", "nest.land"],
},
`${new URL(
`api/${VERSION}`,
VERSION,
BASE_URL,
)}?name=fonction&registry=deno.land&registry=nest.land`,
]];
Expand Down

0 comments on commit 67c3017

Please sign in to comment.