mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-01 03:18:06 +03:00
rename /api/v1/ir to /ir
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"bcrypt": "^5.0.1",
|
||||
"bee-queue": "^1.3.1",
|
||||
"bee-queue": "^1.4.0",
|
||||
"commander": "^7.2.0",
|
||||
"connect-redis": "^5.2.0",
|
||||
"csv-parse": "^4.15.4",
|
||||
|
||||
Generated
+4
-4
@@ -15,7 +15,7 @@ specifiers:
|
||||
'@typescript-eslint/eslint-plugin': ^4.22.0
|
||||
'@typescript-eslint/parser': ^4.22.0
|
||||
bcrypt: ^5.0.1
|
||||
bee-queue: ^1.3.1
|
||||
bee-queue: ^1.4.0
|
||||
commander: ^7.2.0
|
||||
connect-redis: ^5.2.0
|
||||
csv-parse: ^4.15.4
|
||||
@@ -50,7 +50,7 @@ specifiers:
|
||||
|
||||
dependencies:
|
||||
bcrypt: 5.0.1
|
||||
bee-queue: 1.3.1
|
||||
bee-queue: 1.4.0
|
||||
commander: 7.2.0
|
||||
connect-redis: 5.2.0
|
||||
csv-parse: 4.15.4
|
||||
@@ -921,8 +921,8 @@ packages:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/bee-queue/1.3.1:
|
||||
resolution: {integrity: sha512-oF4NdjYy9wj9H8D7oLMGoo+eQZMKX4Pfu/EPkxQLleCIjdG4Yt46RxC4Dy8wWXKez/y9UVx4O8h95WfG60F9sQ==}
|
||||
/bee-queue/1.4.0:
|
||||
resolution: {integrity: sha512-sAXVUcXe4LIKkVrMN18CrudWbq5atC9VLeBjy1BkODAupXf/MVGfGfxdiv8Uit8JIkztnLU0jQFRQtB1uKuHow==}
|
||||
engines: {node: '>= 4'}
|
||||
dependencies:
|
||||
p-finally: 1.0.0
|
||||
|
||||
@@ -7,17 +7,17 @@ import mockApi from "../../../../test-utils/mock-api";
|
||||
import { TestingBarbatosScore } from "../../../../test-utils/test-data";
|
||||
import db from "../../../../external/mongo/db";
|
||||
|
||||
t.test("POST /api/v1/ir/barbatos/score/submit", async (t) => {
|
||||
t.test("POST /ir/barbatos/score/submit", async (t) => {
|
||||
const cookie = await CreateFakeAuthCookie(mockApi);
|
||||
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
// @TODO NEEDS TO USE PROPER AUTHENTICATION!!!
|
||||
RequireNeutralAuthentication("/api/v1/ir/barbatos/score/submit", "POST");
|
||||
RequireNeutralAuthentication("/ir/barbatos/score/submit", "POST");
|
||||
|
||||
t.test("Should import a valid score", async (t) => {
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/barbatos/score/submit")
|
||||
.post("/ir/barbatos/score/submit")
|
||||
.set("Cookie", cookie)
|
||||
.send(TestingBarbatosScore);
|
||||
|
||||
@@ -35,10 +35,7 @@ t.test("POST /api/v1/ir/barbatos/score/submit", async (t) => {
|
||||
});
|
||||
|
||||
t.test("Should reject an invalid body", async (t) => {
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/barbatos/score/submit")
|
||||
.set("Cookie", cookie)
|
||||
.send({});
|
||||
const res = await mockApi.post("/ir/barbatos/score/submit").set("Cookie", cookie).send({});
|
||||
|
||||
t.equal(res.body.success, false, "Should not be successful.");
|
||||
t.equal(res.status, 400, "Should return 400.");
|
||||
|
||||
@@ -8,18 +8,18 @@ import ResetDBState from "../../../../test-utils/reset-db-state";
|
||||
import { GetKTDataJSON } from "../../../../test-utils/test-data";
|
||||
import deepmerge from "deepmerge";
|
||||
|
||||
t.test("POST /api/v1/ir/chunitachi/import", async (t) => {
|
||||
t.test("POST /ir/chunitachi/import", async (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
const cookie = await CreateFakeAuthCookie(mockApi);
|
||||
|
||||
RequireNeutralAuthentication("/api/v1/ir/chunitachi/import", "POST");
|
||||
RequireNeutralAuthentication("/ir/chunitachi/import", "POST");
|
||||
|
||||
const chunitachiBody = GetKTDataJSON("./batch-manual/chunitachi.json");
|
||||
|
||||
t.test("Should work for CHUNITACHI requests", async (t) => {
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/chunitachi/import")
|
||||
.post("/ir/chunitachi/import")
|
||||
.set("Cookie", cookie)
|
||||
.send(chunitachiBody);
|
||||
|
||||
@@ -36,7 +36,7 @@ t.test("POST /api/v1/ir/chunitachi/import", async (t) => {
|
||||
|
||||
t.test("Should reject invalid batch-manual", async (t) => {
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/chunitachi/import")
|
||||
.post("/ir/chunitachi/import")
|
||||
.set("Cookie", cookie)
|
||||
.send({});
|
||||
|
||||
@@ -47,7 +47,7 @@ t.test("POST /api/v1/ir/chunitachi/import", async (t) => {
|
||||
|
||||
t.test("Should reject batch-manual requests if game is not chunithm", async (t) => {
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/chunitachi/import")
|
||||
.post("/ir/chunitachi/import")
|
||||
.set("Cookie", cookie)
|
||||
.send(deepmerge(chunitachiBody, { head: { game: "iidx" } }));
|
||||
|
||||
@@ -58,7 +58,7 @@ t.test("POST /api/v1/ir/chunitachi/import", async (t) => {
|
||||
|
||||
t.test("Should reject batch-manual requests if service is not Chunitachi", async (t) => {
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/chunitachi/import")
|
||||
.post("/ir/chunitachi/import")
|
||||
.set("Cookie", cookie)
|
||||
.send(deepmerge(chunitachiBody, { head: { service: "foo bar" } }));
|
||||
|
||||
|
||||
@@ -7,16 +7,16 @@ import mockApi from "../../../../test-utils/mock-api";
|
||||
import ResetDBState from "../../../../test-utils/reset-db-state";
|
||||
import { GetKTDataJSON } from "../../../../test-utils/test-data";
|
||||
|
||||
t.test("POST /api/v1/ir/direct-manual/import", async (t) => {
|
||||
t.test("POST /ir/direct-manual/import", async (t) => {
|
||||
const cookie = await CreateFakeAuthCookie(mockApi);
|
||||
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
RequireNeutralAuthentication("/api/v1/ir/direct-manual/import", "POST");
|
||||
RequireNeutralAuthentication("/ir/direct-manual/import", "POST");
|
||||
|
||||
t.test("Should upload BATCH-MANUAL data from the request body.", async (t) => {
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/direct-manual/import")
|
||||
.post("/ir/direct-manual/import")
|
||||
.set("Cookie", cookie)
|
||||
.send(GetKTDataJSON("./batch-manual/small-file.json"));
|
||||
|
||||
@@ -33,7 +33,7 @@ t.test("POST /api/v1/ir/direct-manual/import", async (t) => {
|
||||
|
||||
t.test("Should reject invalid BATCH-MANUAL data from the request body.", async (t) => {
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/direct-manual/import")
|
||||
.post("/ir/direct-manual/import")
|
||||
.set("Cookie", cookie)
|
||||
.send({});
|
||||
|
||||
|
||||
@@ -102,26 +102,26 @@ function TestHeaders(url: string, cookie: string[], data: any) {
|
||||
});
|
||||
}
|
||||
|
||||
t.test("POST /api/v1/ir/fervidex/class/submit", async (t) => {
|
||||
t.test("POST /ir/fervidex/class/submit", async (t) => {
|
||||
const cookie = await CreateFakeAuthCookie(mockApi);
|
||||
|
||||
// @todo #108
|
||||
TestHeaders("/api/v1/ir/fervidex/class/submit", cookie, {});
|
||||
TestHeaders("/ir/fervidex/class/submit", cookie, {});
|
||||
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("POST /api/v1/ir/fervidex/score/submit", async (t) => {
|
||||
t.test("POST /ir/fervidex/score/submit", async (t) => {
|
||||
const cookie = await CreateFakeAuthCookie(mockApi);
|
||||
|
||||
t.beforeEach(ResetDBState);
|
||||
TestHeaders("/api/v1/ir/fervidex/score/submit", cookie, GetKTDataJSON("./fervidex/base.json"));
|
||||
TestHeaders("/ir/fervidex/score/submit", cookie, GetKTDataJSON("./fervidex/base.json"));
|
||||
|
||||
t.test("Should import a valid score", async (t) => {
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/fervidex/score/submit")
|
||||
.post("/ir/fervidex/score/submit")
|
||||
.set("Cookie", cookie)
|
||||
.set("User-Agent", "fervidex/1.3.0")
|
||||
.set("X-Software-Model", "LDJ:J:B:A:2020092900")
|
||||
@@ -142,7 +142,7 @@ t.test("POST /api/v1/ir/fervidex/score/submit", async (t) => {
|
||||
|
||||
t.test("Should import a valid score with 2dx-gsm", async (t) => {
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/fervidex/score/submit")
|
||||
.post("/ir/fervidex/score/submit")
|
||||
.set("Cookie", cookie)
|
||||
.set("User-Agent", "fervidex/1.3.0")
|
||||
.set("X-Software-Model", "LDJ:J:B:A:2020092900")
|
||||
@@ -163,7 +163,7 @@ t.test("POST /api/v1/ir/fervidex/score/submit", async (t) => {
|
||||
|
||||
t.test("Should reject an invalid body", async (t) => {
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/fervidex/score/submit")
|
||||
.post("/ir/fervidex/score/submit")
|
||||
.set("User-Agent", "fervidex/1.3.0")
|
||||
.set("Cookie", cookie)
|
||||
.send({});
|
||||
@@ -176,12 +176,12 @@ t.test("POST /api/v1/ir/fervidex/score/submit", async (t) => {
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("POST /api/v1/ir/fervidex/profile/submit", async (t) => {
|
||||
t.test("POST /ir/fervidex/profile/submit", async (t) => {
|
||||
const cookie = await CreateFakeAuthCookie(mockApi);
|
||||
|
||||
t.beforeEach(ResetDBState);
|
||||
TestHeaders(
|
||||
"/api/v1/ir/fervidex/class/submit",
|
||||
"/ir/fervidex/class/submit",
|
||||
cookie,
|
||||
GetKTDataJSON("./fervidex-static/base.json")
|
||||
);
|
||||
@@ -195,7 +195,7 @@ t.test("POST /api/v1/ir/fervidex/profile/submit", async (t) => {
|
||||
await db.charts.iidx.insert(GetKTDataJSON("./kamaitachi/ktblack-charts-iidx.json"));
|
||||
|
||||
const res = await mockApi
|
||||
.post("/api/v1/ir/fervidex/profile/submit")
|
||||
.post("/ir/fervidex/profile/submit")
|
||||
.set("Cookie", cookie)
|
||||
.set("User-Agent", "fervidex/1.3.0")
|
||||
.set("X-Software-Model", "P2D:J:B:A:2020092900")
|
||||
|
||||
@@ -34,14 +34,14 @@ function TestAuth(url: string) {
|
||||
});
|
||||
}
|
||||
|
||||
t.test("GET /api/v1/ir/usc", async (t) => {
|
||||
t.test("GET /ir/usc", async (t) => {
|
||||
await InsertFakeUSCAuth();
|
||||
|
||||
t.beforeEach(ResetDBState);
|
||||
|
||||
TestAuth("/api/v1/ir/usc");
|
||||
TestAuth("/ir/usc");
|
||||
|
||||
const res = await mockApi.get("/api/v1/ir/usc").set("Authorization", "Bearer foo");
|
||||
const res = await mockApi.get("/ir/usc").set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res.body.statusCode, 20, "Should return 20");
|
||||
t.hasStrict(
|
||||
@@ -56,13 +56,13 @@ t.test("GET /api/v1/ir/usc", async (t) => {
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("GET /api/v1/ir/usc/charts/:chartHash", (t) => {
|
||||
t.test("GET /ir/usc/charts/:chartHash", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
t.beforeEach(InsertFakeUSCAuth);
|
||||
|
||||
t.test("Should return 20 if the chartHash matches a chart.", async (t) => {
|
||||
const res = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/USC_CHART_HASH")
|
||||
.get("/ir/usc/charts/USC_CHART_HASH")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res.body.statusCode, 20, "Should return 20");
|
||||
@@ -72,7 +72,7 @@ t.test("GET /api/v1/ir/usc/charts/:chartHash", (t) => {
|
||||
|
||||
t.test("Should return 42 if the chartHash doesn't match a chart.", async (t) => {
|
||||
const res = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/INVALID_HASH")
|
||||
.get("/ir/usc/charts/INVALID_HASH")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res.body.statusCode, 42, "Should return 42");
|
||||
@@ -125,14 +125,14 @@ const USC_SCORE_PB: PBScoreDocument = {
|
||||
},
|
||||
};
|
||||
|
||||
t.test("GET /api/v1/ir/usc/:chartHash/record", (t) => {
|
||||
t.test("GET /ir/usc/:chartHash/record", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
t.beforeEach(InsertFakeUSCAuth);
|
||||
TestAuth("/api/v1/ir/usc/:chartHash/record");
|
||||
TestAuth("/ir/usc/:chartHash/record");
|
||||
|
||||
t.test("Should return 42 if the chartHash doesn't match a chart.", async (t) => {
|
||||
const res = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/INVALID_HASH/record")
|
||||
.get("/ir/usc/charts/INVALID_HASH/record")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res.body.statusCode, 42, "Should return 42");
|
||||
@@ -142,7 +142,7 @@ t.test("GET /api/v1/ir/usc/:chartHash/record", (t) => {
|
||||
|
||||
t.test("Should return 44 if there are no scores on the chart.", async (t) => {
|
||||
const res = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/USC_CHART_HASH/record")
|
||||
.get("/ir/usc/charts/USC_CHART_HASH/record")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res.body.statusCode, 44, "Should return 42");
|
||||
@@ -165,7 +165,7 @@ t.test("GET /api/v1/ir/usc/:chartHash/record", (t) => {
|
||||
} as any);
|
||||
|
||||
const res = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/USC_CHART_HASH/record")
|
||||
.get("/ir/usc/charts/USC_CHART_HASH/record")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res.body.statusCode, 20, "Should return 20");
|
||||
@@ -196,17 +196,17 @@ t.test("GET /api/v1/ir/usc/:chartHash/record", (t) => {
|
||||
t.test("GET /charts/:chartHash/leaderboard", (t) => {
|
||||
t.beforeEach(ResetDBState);
|
||||
t.beforeEach(InsertFakeUSCAuth);
|
||||
TestAuth("/api/v1/ir/usc/:chartHash/leaderboard");
|
||||
TestAuth("/ir/usc/:chartHash/leaderboard");
|
||||
|
||||
t.test("Should return 40 if mode is invalid", async (t) => {
|
||||
const res = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/USC_CHART_HASH/leaderboard")
|
||||
.get("/ir/usc/charts/USC_CHART_HASH/leaderboard")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res.body.statusCode, 40);
|
||||
|
||||
const res2 = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=invalid")
|
||||
.get("/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=invalid")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res2.body.statusCode, 40);
|
||||
@@ -216,13 +216,13 @@ t.test("GET /charts/:chartHash/leaderboard", (t) => {
|
||||
|
||||
t.test("Should return 40 if N is invalid", async (t) => {
|
||||
const res = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=best")
|
||||
.get("/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=best")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res.body.statusCode, 40);
|
||||
|
||||
const res2 = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=best&n=foo")
|
||||
.get("/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=best&n=foo")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res2.body.statusCode, 40);
|
||||
@@ -232,7 +232,7 @@ t.test("GET /charts/:chartHash/leaderboard", (t) => {
|
||||
|
||||
t.test("Should return empty arr for mode = best if no scores", async (t) => {
|
||||
const res = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=best&n=5")
|
||||
.get("/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=best&n=5")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res.body.statusCode, 20);
|
||||
@@ -271,7 +271,7 @@ t.test("GET /charts/:chartHash/leaderboard", (t) => {
|
||||
] as any);
|
||||
|
||||
const res = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=best&n=2")
|
||||
.get("/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=best&n=2")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res.body.statusCode, 20);
|
||||
@@ -307,7 +307,7 @@ t.test("GET /charts/:chartHash/leaderboard", (t) => {
|
||||
);
|
||||
|
||||
const res2 = await mockApi
|
||||
.get("/api/v1/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=best&n=1")
|
||||
.get("/ir/usc/charts/USC_CHART_HASH/leaderboard?mode=best&n=1")
|
||||
.set("Authorization", "Bearer foo");
|
||||
|
||||
t.equal(res2.body.statusCode, 20);
|
||||
|
||||
Reference in New Issue
Block a user