chore: update port to 4000 in tests and compose
This commit is contained in:
+3
-3
@@ -10,7 +10,7 @@ services:
|
|||||||
- STORAGE_CHANNEL_ID=${STORAGE_CHANNEL_ID}
|
- STORAGE_CHANNEL_ID=${STORAGE_CHANNEL_ID}
|
||||||
- BASE_URL=${BASE_URL}
|
- BASE_URL=${BASE_URL}
|
||||||
- DATABASE_URL=${DATABASE_URL}
|
- DATABASE_URL=${DATABASE_URL}
|
||||||
- PORT=3000
|
- PORT=4000
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- LOG_LEVEL=info
|
- LOG_LEVEL=info
|
||||||
- TRUST_PROXY=true
|
- TRUST_PROXY=true
|
||||||
@@ -46,7 +46,7 @@ services:
|
|||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
- CMD-SHELL
|
- CMD-SHELL
|
||||||
- "bun -e \"fetch('http://localhost:3000/health').then(r => r.status === 200 ? process.exit(0) : process.exit(1))\""
|
- "bun -e \"fetch('http://localhost:4000/health').then(r => r.status === 200 ? process.exit(0) : process.exit(1))\""
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
@@ -59,7 +59,7 @@ services:
|
|||||||
- "traefik.http.routers.filedrop.entrypoints=websecure"
|
- "traefik.http.routers.filedrop.entrypoints=websecure"
|
||||||
- "traefik.http.routers.filedrop.tls=true"
|
- "traefik.http.routers.filedrop.tls=true"
|
||||||
- "traefik.http.routers.filedrop.tls.certresolver=cloudflare"
|
- "traefik.http.routers.filedrop.tls.certresolver=cloudflare"
|
||||||
- "traefik.http.services.filedrop.loadbalancer.server.port=3000"
|
- "traefik.http.services.filedrop.loadbalancer.server.port=4000"
|
||||||
- "traefik.http.middlewares.filedrop-rl.ratelimit.average=300"
|
- "traefik.http.middlewares.filedrop-rl.ratelimit.average=300"
|
||||||
- "traefik.http.middlewares.filedrop-rl.ratelimit.burst=100"
|
- "traefik.http.middlewares.filedrop-rl.ratelimit.burst=100"
|
||||||
- "traefik.http.middlewares.filedrop-rl.ratelimit.period=1m"
|
- "traefik.http.middlewares.filedrop-rl.ratelimit.period=1m"
|
||||||
|
|||||||
+6
-6
@@ -151,7 +151,7 @@ describe('File Route Handlers', () => {
|
|||||||
it('should return 404 if file is not found in database', async () => {
|
it('should return 404 if file is not found in database', async () => {
|
||||||
mockFindByPublicId.mockImplementationOnce(async () => null);
|
mockFindByPublicId.mockImplementationOnce(async () => null);
|
||||||
|
|
||||||
const req = requestWithPublicId('http://localhost:3000/f/missing-id', 'missing-id');
|
const req = requestWithPublicId('http://localhost:4000/f/missing-id', 'missing-id');
|
||||||
const res = await handleFileRedirect(req);
|
const res = await handleFileRedirect(req);
|
||||||
expect(res.status).toBe(404);
|
expect(res.status).toBe(404);
|
||||||
const body = await responseJson<ErrorBody>(res);
|
const body = await responseJson<ErrorBody>(res);
|
||||||
@@ -187,7 +187,7 @@ describe('File Route Handlers', () => {
|
|||||||
updatedAt: new Date('2026-05-18T00:00:00.000Z'),
|
updatedAt: new Date('2026-05-18T00:00:00.000Z'),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const req = requestWithPublicId('http://localhost:3000/f/test-id', 'test-id');
|
const req = requestWithPublicId('http://localhost:4000/f/test-id', 'test-id');
|
||||||
const res = await handleFileRedirect(req);
|
const res = await handleFileRedirect(req);
|
||||||
|
|
||||||
expect(res.status).toBe(302);
|
expect(res.status).toBe(302);
|
||||||
@@ -201,7 +201,7 @@ describe('File Route Handlers', () => {
|
|||||||
throw new Error('DB Connection Error');
|
throw new Error('DB Connection Error');
|
||||||
});
|
});
|
||||||
|
|
||||||
const req = requestWithPublicId('http://localhost:3000/f/test-id', 'test-id');
|
const req = requestWithPublicId('http://localhost:4000/f/test-id', 'test-id');
|
||||||
const res = await handleFileRedirect(req);
|
const res = await handleFileRedirect(req);
|
||||||
expect(res.status).toBe(500);
|
expect(res.status).toBe(500);
|
||||||
const body = await responseJson<ErrorBody>(res);
|
const body = await responseJson<ErrorBody>(res);
|
||||||
@@ -213,7 +213,7 @@ describe('File Route Handlers', () => {
|
|||||||
it('should return 404 if file is not found in database', async () => {
|
it('should return 404 if file is not found in database', async () => {
|
||||||
mockFindByPublicId.mockImplementationOnce(async () => null);
|
mockFindByPublicId.mockImplementationOnce(async () => null);
|
||||||
|
|
||||||
const req = requestWithPublicId('http://localhost:3000/file/missing-id/info', 'missing-id');
|
const req = requestWithPublicId('http://localhost:4000/file/missing-id/info', 'missing-id');
|
||||||
const res = await handleFileInfo(req);
|
const res = await handleFileInfo(req);
|
||||||
expect(res.status).toBe(404);
|
expect(res.status).toBe(404);
|
||||||
const body = await responseJson<ErrorBody>(res);
|
const body = await responseJson<ErrorBody>(res);
|
||||||
@@ -251,7 +251,7 @@ describe('File Route Handlers', () => {
|
|||||||
|
|
||||||
mockFindByPublicId.mockImplementationOnce(async () => dbFile);
|
mockFindByPublicId.mockImplementationOnce(async () => dbFile);
|
||||||
|
|
||||||
const req = requestWithPublicId('http://localhost:3000/file/test-id/info', 'test-id');
|
const req = requestWithPublicId('http://localhost:4000/file/test-id/info', 'test-id');
|
||||||
const res = await handleFileInfo(req);
|
const res = await handleFileInfo(req);
|
||||||
expect(res.status).toBe(200);
|
expect(res.status).toBe(200);
|
||||||
const body = await responseJson<FileInfoBody>(res);
|
const body = await responseJson<FileInfoBody>(res);
|
||||||
@@ -273,7 +273,7 @@ describe('File Route Handlers', () => {
|
|||||||
throw new Error('DB Connection Error');
|
throw new Error('DB Connection Error');
|
||||||
});
|
});
|
||||||
|
|
||||||
const req = requestWithPublicId('http://localhost:3000/file/test-id/info', 'test-id');
|
const req = requestWithPublicId('http://localhost:4000/file/test-id/info', 'test-id');
|
||||||
const res = await handleFileInfo(req);
|
const res = await handleFileInfo(req);
|
||||||
expect(res.status).toBe(500);
|
expect(res.status).toBe(500);
|
||||||
const body = await responseJson<ErrorBody>(res);
|
const body = await responseJson<ErrorBody>(res);
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@ describe('Health Route Handler', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return status 200 and ok when DB is healthy', async () => {
|
it('should return status 200 and ok when DB is healthy', async () => {
|
||||||
const req = new Request('http://localhost:3000/health');
|
const req = new Request('http://localhost:4000/health');
|
||||||
const res = await handleHealth(req);
|
const res = await handleHealth(req);
|
||||||
|
|
||||||
expect(res.status).toBe(200);
|
expect(res.status).toBe(200);
|
||||||
@@ -30,7 +30,7 @@ describe('Health Route Handler', () => {
|
|||||||
|
|
||||||
it('should return status 500 and error details when DB health check fails', async () => {
|
it('should return status 500 and error details when DB health check fails', async () => {
|
||||||
mockExecute.mockImplementationOnce(() => Promise.reject(new Error('DB Connection Failed')));
|
mockExecute.mockImplementationOnce(() => Promise.reject(new Error('DB Connection Failed')));
|
||||||
const req = new Request('http://localhost:3000/health');
|
const req = new Request('http://localhost:4000/health');
|
||||||
const res = await handleHealth(req);
|
const res = await handleHealth(req);
|
||||||
|
|
||||||
expect(res.status).toBe(500);
|
expect(res.status).toBe(500);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { afterAll, beforeAll, describe, expect, it, mock } from 'bun:test';
|
|||||||
process.env.NODE_ENV = 'test';
|
process.env.NODE_ENV = 'test';
|
||||||
process.env.BOT_TOKEN = '123456:ABC-DEF';
|
process.env.BOT_TOKEN = '123456:ABC-DEF';
|
||||||
process.env.STORAGE_CHANNEL_ID = '-1001234567890';
|
process.env.STORAGE_CHANNEL_ID = '-1001234567890';
|
||||||
process.env.BASE_URL = 'http://localhost:3000';
|
process.env.BASE_URL = 'http://localhost:4000';
|
||||||
process.env.DATABASE_URL = 'postgresql://localhost/test';
|
process.env.DATABASE_URL = 'postgresql://localhost/test';
|
||||||
process.env.PORT = '3000';
|
process.env.PORT = '3000';
|
||||||
process.env.S3_ACCESS_KEY = 'filedrop-admin';
|
process.env.S3_ACCESS_KEY = 'filedrop-admin';
|
||||||
@@ -90,7 +90,7 @@ describe('S3 bucket configuration compatibility', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns VersioningConfiguration for path-style GetBucketVersioning', async () => {
|
it('returns VersioningConfiguration for path-style GetBucketVersioning', async () => {
|
||||||
const res = await handleS3Request(new Request('http://localhost:3000/gitea?versioning'));
|
const res = await handleS3Request(new Request('http://localhost:4000/gitea?versioning'));
|
||||||
const body = await res.text();
|
const body = await res.text();
|
||||||
|
|
||||||
expect(res.status).toBe(200);
|
expect(res.status).toBe(200);
|
||||||
@@ -101,7 +101,7 @@ describe('S3 bucket configuration compatibility', () => {
|
|||||||
|
|
||||||
it('returns VersioningConfiguration for virtual-hosted GetBucketVersioning', async () => {
|
it('returns VersioningConfiguration for virtual-hosted GetBucketVersioning', async () => {
|
||||||
const res = await handleS3Request(
|
const res = await handleS3Request(
|
||||||
new Request('http://gitea.localhost:3000/?versioning'),
|
new Request('http://gitea.localhost:4000/?versioning'),
|
||||||
'gitea',
|
'gitea',
|
||||||
);
|
);
|
||||||
const body = await res.text();
|
const body = await res.text();
|
||||||
|
|||||||
+7
-7
@@ -117,7 +117,7 @@ describe('Upload Route Handler', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should reject unsupported content types with 400 status', async () => {
|
it('should reject unsupported content types with 400 status', async () => {
|
||||||
const req = new Request('http://localhost:3000/api/upload', {
|
const req = new Request('http://localhost:4000/api/upload', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'text/plain',
|
'content-type': 'text/plain',
|
||||||
@@ -132,7 +132,7 @@ describe('Upload Route Handler', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should process JSON upload (base64) successfully', async () => {
|
it('should process JSON upload (base64) successfully', async () => {
|
||||||
const req = new Request('http://localhost:3000/api/upload', {
|
const req = new Request('http://localhost:4000/api/upload', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
@@ -160,7 +160,7 @@ describe('Upload Route Handler', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should reject JSON upload without file key', async () => {
|
it('should reject JSON upload without file key', async () => {
|
||||||
const req = new Request('http://localhost:3000/api/upload', {
|
const req = new Request('http://localhost:4000/api/upload', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
@@ -181,7 +181,7 @@ describe('Upload Route Handler', () => {
|
|||||||
const fileBlob = new Blob([realPhotoBuffer], { type: 'image/png' });
|
const fileBlob = new Blob([realPhotoBuffer], { type: 'image/png' });
|
||||||
formData.append('file', fileBlob, 'test_multi.png');
|
formData.append('file', fileBlob, 'test_multi.png');
|
||||||
|
|
||||||
const req = new Request('http://localhost:3000/api/upload', {
|
const req = new Request('http://localhost:4000/api/upload', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
});
|
});
|
||||||
@@ -214,7 +214,7 @@ describe('Upload Route Handler', () => {
|
|||||||
const fileBlob = new Blob([Buffer.from('multipart hello')], { type: 'text/plain' });
|
const fileBlob = new Blob([Buffer.from('multipart hello')], { type: 'text/plain' });
|
||||||
formData.append('file', fileBlob, 'test_multi.txt');
|
formData.append('file', fileBlob, 'test_multi.txt');
|
||||||
|
|
||||||
const req = new Request('http://localhost:3000/api/upload', {
|
const req = new Request('http://localhost:4000/api/upload', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
});
|
});
|
||||||
@@ -252,7 +252,7 @@ describe('Upload Route Handler', () => {
|
|||||||
updatedAt: new Date('2026-05-18T00:00:00.000Z'),
|
updatedAt: new Date('2026-05-18T00:00:00.000Z'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const req = new Request('http://localhost:3000/api/upload', {
|
const req = new Request('http://localhost:4000/api/upload', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
@@ -281,7 +281,7 @@ describe('Upload Route Handler', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should reject oversized request by Content-Length header', async () => {
|
it('should reject oversized request by Content-Length header', async () => {
|
||||||
const req = new Request('http://localhost:3000/api/upload', {
|
const req = new Request('http://localhost:4000/api/upload', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ describe('Web API v1', () => {
|
|||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
process.env.BOT_TOKEN = '123456:ABC-DEF';
|
process.env.BOT_TOKEN = '123456:ABC-DEF';
|
||||||
process.env.STORAGE_CHANNEL_ID = '-1001234567890';
|
process.env.STORAGE_CHANNEL_ID = '-1001234567890';
|
||||||
process.env.BASE_URL = 'http://localhost:3000';
|
process.env.BASE_URL = 'http://localhost:4000';
|
||||||
process.env.DATABASE_URL = 'postgresql://localhost/test';
|
process.env.DATABASE_URL = 'postgresql://localhost/test';
|
||||||
const webApi = await import('../src/interfaces/http/controllers/web-api-controller');
|
const webApi = await import('../src/interfaces/http/controllers/web-api-controller');
|
||||||
handleWebApiV1 = webApi.handleWebApiV1;
|
handleWebApiV1 = webApi.handleWebApiV1;
|
||||||
@@ -74,7 +74,7 @@ describe('Web API v1', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should list buckets via GET /api/v1/buckets', async () => {
|
it('should list buckets via GET /api/v1/buckets', async () => {
|
||||||
const req = new Request('http://localhost:3000/api/v1/buckets');
|
const req = new Request('http://localhost:4000/api/v1/buckets');
|
||||||
const res = await handleWebApiV1(req);
|
const res = await handleWebApiV1(req);
|
||||||
expect(res.status).toBe(200);
|
expect(res.status).toBe(200);
|
||||||
const data = (await res.json()) as { buckets: { name: string }[] };
|
const data = (await res.json()) as { buckets: { name: string }[] };
|
||||||
@@ -84,7 +84,7 @@ describe('Web API v1', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return 404 for unknown API path', async () => {
|
it('should return 404 for unknown API path', async () => {
|
||||||
const req = new Request('http://localhost:3000/api/v1/unknown');
|
const req = new Request('http://localhost:4000/api/v1/unknown');
|
||||||
const res = await handleWebApiV1(req);
|
const res = await handleWebApiV1(req);
|
||||||
expect(res.status).toBe(404);
|
expect(res.status).toBe(404);
|
||||||
const data = (await res.json()) as { error: string };
|
const data = (await res.json()) as { error: string };
|
||||||
@@ -92,7 +92,7 @@ describe('Web API v1', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return 400 for invalid bucket name on create', async () => {
|
it('should return 400 for invalid bucket name on create', async () => {
|
||||||
const req = new Request('http://localhost:3000/api/v1/buckets', {
|
const req = new Request('http://localhost:4000/api/v1/buckets', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'content-type': 'application/json' },
|
headers: { 'content-type': 'application/json' },
|
||||||
body: JSON.stringify({ name: 'INVALID_NAME!' }),
|
body: JSON.stringify({ name: 'INVALID_NAME!' }),
|
||||||
@@ -117,7 +117,7 @@ describe('Web API v1', () => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const req = new Request('http://localhost:3000/api/v1/buckets/test-bucket/objects');
|
const req = new Request('http://localhost:4000/api/v1/buckets/test-bucket/objects');
|
||||||
const res = await handleWebApiV1(req);
|
const res = await handleWebApiV1(req);
|
||||||
|
|
||||||
expect(res.status).toBe(200);
|
expect(res.status).toBe(200);
|
||||||
|
|||||||
Reference in New Issue
Block a user