From 2e55a0cc5b2e01349548e68fdcbb9798b4996dc0 Mon Sep 17 00:00:00 2001 From: zkldi Date: Wed, 12 May 2021 06:18:30 +0100 Subject: [PATCH] rename internal-api to api, that's us! --- .../{internal-api/internal-api.ts => api/api.ts} | 0 server/src/{internal-api => api}/auth/auth.ts | 6 +++--- .../{internal-api => api}/import/import.test.ts | 14 +++++++------- server/src/{internal-api => api}/import/import.ts | 2 +- server/src/server.ts | 4 ++-- server/src/test-utils/fake-session.ts | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) rename server/src/{internal-api/internal-api.ts => api/api.ts} (100%) rename server/src/{internal-api => api}/auth/auth.ts (95%) rename server/src/{internal-api => api}/import/import.test.ts (91%) rename server/src/{internal-api => api}/import/import.ts (96%) diff --git a/server/src/internal-api/internal-api.ts b/server/src/api/api.ts similarity index 100% rename from server/src/internal-api/internal-api.ts rename to server/src/api/api.ts diff --git a/server/src/internal-api/auth/auth.ts b/server/src/api/auth/auth.ts similarity index 95% rename from server/src/internal-api/auth/auth.ts rename to server/src/api/auth/auth.ts index 41a44bcbb..7ac016949 100644 --- a/server/src/internal-api/auth/auth.ts +++ b/server/src/api/auth/auth.ts @@ -26,7 +26,7 @@ const SHOULD_COOKIES_SECURE = process.env.NODE_ENV === "production"; /** * Logs in a user. - * @name /internal-api/auth/login + * @name /api/auth/login */ router.post( "/login", @@ -145,7 +145,7 @@ router.post( /** * Registers a new user. - * @name /internal-api/auth/register + * @name /api/auth/register */ router.post( "/register", @@ -258,7 +258,7 @@ router.post( /** * Logs out the requesting user. - * @name /internal-api/auth/logout + * @name /api/auth/logout */ router.post("/logout", RequireLoggedIn, (req, res) => { req.session.destroy(() => 0); diff --git a/server/src/internal-api/import/import.test.ts b/server/src/api/import/import.test.ts similarity index 91% rename from server/src/internal-api/import/import.test.ts rename to server/src/api/import/import.test.ts index fca5db1cc..2b9f7bc26 100644 --- a/server/src/internal-api/import/import.test.ts +++ b/server/src/api/import/import.test.ts @@ -24,19 +24,19 @@ async function LoadKTBlackIIDXData() { // reset DB handles the post-stuff -t.test("POST /internal-api/import/file", async (t) => { +t.test("POST /api/import/file", async (t) => { const cookie = await CreateFakeAuthCookie(mockApi); t.beforeEach(ResetDBState); - RequireNeutralAuthentication("/internal-api/import/file", "POST"); + RequireNeutralAuthentication("/api/import/file", "POST"); t.test("file/csv:eamusement-iidx", (t) => { t.beforeEach(LoadKTBlackIIDXData); t.test("Mini HV import", async (t) => { let res = await mockApi - .post("/internal-api/import/file") + .post("/api/import/file") .set("Cookie", cookie) .attach( "scoreData", @@ -67,7 +67,7 @@ t.test("POST /internal-api/import/file", async (t) => { t.test("Valid Rootage CSV import", async (t) => { let res = await mockApi - .post("/internal-api/import/file") + .post("/api/import/file") .set("Cookie", cookie) .attach("scoreData", TestingIIDXEamusementCSV26, "my_csv.csv") .field("importType", "file/csv:eamusement-iidx") @@ -92,7 +92,7 @@ t.test("POST /internal-api/import/file", async (t) => { t.test("Valid Heroic Verse CSV import", async (t) => { let res = await mockApi - .post("/internal-api/import/file") + .post("/api/import/file") .set("Cookie", cookie) .attach("scoreData", TestingIIDXEamusementCSV27, "my_csv.csv") .field("importType", "file/csv:eamusement-iidx") @@ -121,7 +121,7 @@ t.test("POST /internal-api/import/file", async (t) => { t.test("file/json:batch-manual", (t) => { t.test("Empty import", async (t) => { let res = await mockApi - .post("/internal-api/import/file") + .post("/api/import/file") .set("Cookie", cookie) .attach( "scoreData", @@ -151,7 +151,7 @@ t.test("POST /internal-api/import/file", async (t) => { t.test("Single import", async (t) => { let res = await mockApi - .post("/internal-api/import/file") + .post("/api/import/file") .set("Cookie", cookie) .attach( "scoreData", diff --git a/server/src/internal-api/import/import.ts b/server/src/api/import/import.ts similarity index 96% rename from server/src/internal-api/import/import.ts rename to server/src/api/import/import.ts index dcc19e2c7..6627d4e09 100644 --- a/server/src/internal-api/import/import.ts +++ b/server/src/api/import/import.ts @@ -42,7 +42,7 @@ const parseMultipartScoredata = (req: Request, res: Response, next: NextFunction /** * Import scores from a file. Expects the post request to be multipart, and to provide a scoreData file. - * @name /internal-api/import/file + * @name /api/import/file */ router.post( "/file", diff --git a/server/src/server.ts b/server/src/server.ts index 29fa511d4..c7bc93b66 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -50,9 +50,9 @@ process.on("unhandledRejection", (reason, promise) => { // limit them so as not to choke the api app.use(express.json({ limit: "1mb" })); -import internalApiRouter from "./internal-api/internal-api"; +import internalApiRouter from "./api/api"; -app.use("/internal-api", internalApiRouter); +app.use("/api", internalApiRouter); /** * If any user gets to this point, we send them index.html and let react router do the routing (and 404ing) diff --git a/server/src/test-utils/fake-session.ts b/server/src/test-utils/fake-session.ts index 719bca3a7..cdff5cafc 100644 --- a/server/src/test-utils/fake-session.ts +++ b/server/src/test-utils/fake-session.ts @@ -8,7 +8,7 @@ export async function CreateFakeAuthCookie(mockApi: supertest.SuperTest