Changed relative paths to absolute paths
This commit is contained in:
parent
b3e39e32b0
commit
a2fdf862dd
|
@ -1,7 +1,7 @@
|
||||||
import compression from "compression";
|
import compression from "compression";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import listEndpoints from "express-list-endpoints";
|
import listEndpoints from "express-list-endpoints";
|
||||||
import ImageController from "./controllers/ImageController";
|
import ImageController from "src/controllers/ImageController";
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import ImageService from "../services/ImageService";
|
import ImageService from "src/services/ImageService";
|
||||||
|
|
||||||
class ImageController {
|
class ImageController {
|
||||||
async get(req: Request, res: Response) {
|
async get(req: Request, res: Response) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { env } from "bun";
|
import { env } from "bun";
|
||||||
import app from "./app";
|
import app from "src/app";
|
||||||
|
|
||||||
const PORT = env.PORT;
|
const PORT = env.PORT;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { env } from "bun";
|
import { env } from "bun";
|
||||||
import { BotApiResponse } from "../types/BotApiResponse";
|
import { BotApiResponse } from "src/types/BotApiResponse";
|
||||||
|
|
||||||
class BotApiService {
|
class BotApiService {
|
||||||
readonly BOT_API_URI = env.BOT_API_URI;
|
readonly BOT_API_URI = env.BOT_API_URI;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import GelbooruApiResponse from "../types/GelbooruApiResponse";
|
import GelbooruApiResponse from "src/types/GelbooruApiResponse";
|
||||||
import GelbooruServiceResponse from "../types/GelbooruServiceResponse";
|
import GelbooruServiceResponse from "src/types/GelbooruServiceResponse";
|
||||||
|
|
||||||
class GelbooruApiService {
|
class GelbooruApiService {
|
||||||
async get(): Promise<GelbooruServiceResponse> {
|
async get(): Promise<GelbooruServiceResponse> {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import GelbooruServiceResponse from "../types/GelbooruServiceResponse";
|
import GelbooruServiceResponse from "src/types/GelbooruServiceResponse";
|
||||||
import Image from "../types/Image";
|
import Image from "src/types/Image";
|
||||||
import BotApiService from "./BotApiService";
|
import BotApiService from "src/services/BotApiService";
|
||||||
import GelbooruApiService from "./GelbooruApiService";
|
import GelbooruApiService from "src/services/GelbooruApiService";
|
||||||
|
|
||||||
class ImageService {
|
class ImageService {
|
||||||
postsQueue: Image[] = [];
|
postsQueue: Image[] = [];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import BotImage from "./BotImage";
|
import BotImage from "src/types/BotImage";
|
||||||
|
|
||||||
export interface BotApiResponse {
|
export interface BotApiResponse {
|
||||||
images: BotImage[]
|
images: BotImage[]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import GelbooruPost from "./GelbooruPost";
|
import GelbooruPost from "src/types/GelbooruPost";
|
||||||
|
|
||||||
export default interface GelbooruServiceResponse {
|
export default interface GelbooruServiceResponse {
|
||||||
posts: GelbooruPost[];
|
posts: GelbooruPost[];
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import { afterEach, describe, expect, it, mock, jest } from "bun:test";
|
import { afterEach, describe, expect, it, mock, jest } from "bun:test";
|
||||||
import Image from "../../src/types/Image";
|
import Image from "src/types/Image";
|
||||||
import ImageService from "../../src/services/ImageService";
|
import ImageService from "src/services/ImageService";
|
||||||
import GelbooruApiResponse from "../../src/types/GelbooruServiceResponse";
|
import GelbooruApiResponse from "src/types/GelbooruServiceResponse";
|
||||||
import { BotApiResponse } from "../../src/types/BotApiResponse";
|
import { BotApiResponse } from "src/types/BotApiResponse";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import ImageController from "../../src/controllers/ImageController";
|
import ImageController from "src/controllers/ImageController";
|
||||||
import app from "../../src/app";
|
import app from "src/app";
|
||||||
import request from "supertest";
|
import request from "supertest";
|
||||||
|
|
||||||
const imageServiceOriginal = ImageService;
|
const imageServiceOriginal = ImageService;
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
mock.restore();
|
mock.restore();
|
||||||
mock.module("../../src/services/ImageService", () => ({
|
mock.module("src/services/ImageService", () => ({
|
||||||
default: imageServiceOriginal,
|
default: imageServiceOriginal,
|
||||||
}));
|
}));
|
||||||
})
|
})
|
||||||
|
@ -26,7 +26,7 @@ describe("endpoint returns the correct status codes", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return 500 if any error happens", async () => {
|
it("should return 500 if any error happens", async () => {
|
||||||
mock.module("../../src/services/ImageService", () => {
|
mock.module("src/services/ImageService", () => {
|
||||||
return {
|
return {
|
||||||
default: {
|
default: {
|
||||||
get: () => {
|
get: () => {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { afterEach, describe, expect, it, mock, spyOn } from "bun:test";
|
import { afterEach, describe, expect, it, mock, spyOn } from "bun:test";
|
||||||
import Image from "../../src/types/Image";
|
import Image from "src/types/Image";
|
||||||
import ImageService from "../../src/services/ImageService";
|
import ImageService from "src/services/ImageService";
|
||||||
import GelbooruApiResponse from "../../src/types/GelbooruServiceResponse";
|
import GelbooruApiResponse from "src/types/GelbooruServiceResponse";
|
||||||
import { BotApiResponse } from "../../src/types/BotApiResponse";
|
import { BotApiResponse } from "src/types/BotApiResponse";
|
||||||
import GelbooruApiService from "../../src/services/GelbooruApiService";
|
import GelbooruApiService from "src/services/GelbooruApiService";
|
||||||
import BotApiService from "../../src/services/BotApiService";
|
import BotApiService from "src/services/BotApiService";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
|
|
||||||
const imageServiceOriginal = ImageService;
|
const imageServiceOriginal = ImageService;
|
||||||
|
@ -13,13 +13,13 @@ const botApiServiceOriginal = BotApiService;
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
mock.restore();
|
mock.restore();
|
||||||
mock.module("../../src/services/ImageService", () => ({
|
mock.module("src/services/ImageService", () => ({
|
||||||
default: imageServiceOriginal,
|
default: imageServiceOriginal,
|
||||||
}));
|
}));
|
||||||
mock.module("../../src/services/GelbooruApiService", () => ({
|
mock.module("src/services/GelbooruApiService", () => ({
|
||||||
default: gelbooruApiServiceOriginal,
|
default: gelbooruApiServiceOriginal,
|
||||||
}));
|
}));
|
||||||
mock.module("../../src/services/BotApiService", () => ({
|
mock.module("src/services/BotApiService", () => ({
|
||||||
default: botApiServiceOriginal
|
default: botApiServiceOriginal
|
||||||
}));
|
}));
|
||||||
})
|
})
|
||||||
|
@ -29,7 +29,7 @@ describe("endpoint gets a non repeated image", () => {
|
||||||
const REPEATED_URL = "https://fastly.picsum.photos/id/1/10/20.jpg?hmac=gY6PvUXFacKfYpBpTTVcNLxumpyMmoCamM-J5DOPwNc";
|
const REPEATED_URL = "https://fastly.picsum.photos/id/1/10/20.jpg?hmac=gY6PvUXFacKfYpBpTTVcNLxumpyMmoCamM-J5DOPwNc";
|
||||||
const UNIQUE_URL = "https://fastly.picsum.photos/id/2/10/20.jpg?hmac=zy6lz21CuRIstr9ETx9h5AuoH50s_L2uIEct3dROpY8";
|
const UNIQUE_URL = "https://fastly.picsum.photos/id/2/10/20.jpg?hmac=zy6lz21CuRIstr9ETx9h5AuoH50s_L2uIEct3dROpY8";
|
||||||
|
|
||||||
mock.module("../../src/services/GelbooruApiService", () => {
|
mock.module("src/services/GelbooruApiService", () => {
|
||||||
let alreadyCalled = false;
|
let alreadyCalled = false;
|
||||||
return {
|
return {
|
||||||
default: {
|
default: {
|
||||||
|
@ -45,7 +45,7 @@ describe("endpoint gets a non repeated image", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mock.module("../../src/services/BotApiService", () => ({
|
mock.module("src/services/BotApiService", () => ({
|
||||||
default: {
|
default: {
|
||||||
getAll: (): BotApiResponse => ({
|
getAll: (): BotApiResponse => ({
|
||||||
images: [
|
images: [
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"types": [
|
"types": [
|
||||||
"bun-types" // add Bun global
|
"bun-types" // add Bun global
|
||||||
]
|
],
|
||||||
|
"baseUrl": "./",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue