Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: elifesciences/enhanced-preprints-server
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ce8842d482dffb40094b93f4a1ef418334a57cad
Choose a base ref
..
head repository: elifesciences/enhanced-preprints-server
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cc7354b04bce5f1cc1201956b3044a97038f2723
Choose a head ref
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG node_version=22.12-alpine3.20
ARG node_version=22.13-alpine3.20

FROM node:${node_version} as base

Binary file not shown.
Binary file not shown.
Binary file not shown.
44 changes: 44 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -38,6 +38,39 @@ services:
retries: 10
start_period: 2s

minio:
image: minio/minio:RELEASE.2023-01-02T09-40-09Z
ports:
- 9100:9000
- 9101:9001
volumes:
- minio_storage:/data
environment:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: miniotest
command: server --console-address ":9001" /data
healthcheck:
test: curl http://minio:9000/minio/health/live
interval: 5s
timeout: 5s
retries: 10
start_period: 2s

createbucket:
image: minio/mc:RELEASE.2022-12-24T15-21-38Z
depends_on:
minio:
condition: service_healthy
entrypoint: >
/bin/sh -c "
/usr/bin/mc config host add myminio http://minio:9000 minio miniotest;
/usr/bin/mc mb myminio/epp || true;
/usr/bin/mc mirror /automation-data myminio/epp/automation;
exit 0;
"
volumes:
- ./data/automation:/automation-data

# EPP API
api:
build:
@@ -52,11 +85,21 @@ services:
depends_on:
mongodb:
condition: service_healthy
minio:
condition: service_healthy
createbucket:
condition: service_completed_successfully
environment:
REPO_TYPE: MongoDB
REPO_CONNECTION: mongodb:27017
REPO_USERNAME: admin
REPO_PASSWORD: testtest

# EPP S3 bucket
S3_ENDPOINT: http://minio:9000
AWS_ACCESS_KEY_ID: minio
AWS_SECRET_ACCESS_KEY: miniotest
BUCKET_NAME: epp
ports:
- 3000:3000
volumes:
@@ -74,3 +117,4 @@ services:
- ./.docker/nginx.conf:/etc/nginx/conf.d/default.conf
volumes:
data: {}
minio_storage: {}
21 changes: 21 additions & 0 deletions integration-tests/api.test.ts
Original file line number Diff line number Diff line change
@@ -1012,6 +1012,27 @@ describe('server tests', () => {
});
});

describe('/api/files/:fileId(*)', () => {
it('returns 404 if file not known', async () => {
const app = createApp(articleStore);

await request(app)
.get('/api/files/unknown')
.expect(404, 'File not found');
});
});

describe('/api/files/ping', () => {
it('returns OK for svg file', async () => {
const app = createApp(articleStore);

await request(app)
.get('/api/files/ping')
.expect(200)
.expect('Content-Type', 'image/svg+xml; charset=utf-8');
});
});

describe('/api/citations/:publisherId/:articleId/bibtex', () => {
const bibtex = `
@article{Carberry_2008,
9 changes: 4 additions & 5 deletions scripts/use-cluster-db.sh
Original file line number Diff line number Diff line change
@@ -13,15 +13,14 @@ while [[ $# -gt 0 ]]; do
shift # past value
;;
-h|--help)
printf "This script will restore a mongodb data dump into a local mongodb docker container."
printf
printf "options:"
printf -e "${G}-i --input The input path for the database dump including the filename (default: ./versioned_articles.bson.gz)"
printf "This script will restore a mongodb data dump into a local mongodb docker container.\n\n"
printf "options:\n"
printf "${G}-i --input The input path for the database dump including the filename (default: ./versioned_articles.bson.gz)\n"
exit 0
;;

-*|--*)
printf -e "${R}Unknown option $1"
printf "${R}Unknown option $1"
exit 1
;;
esac
2 changes: 2 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import express from 'express';
import { ArticleRepository } from './model/model';
import { preprintsRoutes } from './routes/preprints-routes';
import { citationsRoutes } from './routes/citations-routes';
import { filesRoutes } from './routes/files-routes';

export const createApp = (repo: ArticleRepository) => {
const app = express();
@@ -23,6 +24,7 @@ export const createApp = (repo: ArticleRepository) => {

app.use(preprintsRoutes(repo));
app.use(citationsRoutes());
app.use(filesRoutes());

return app;
};
25 changes: 25 additions & 0 deletions src/routes/files-routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Response, Request, Router } from 'express';

export const filesRoutes = () => {
const router = Router();
router.get('/api/files/ping', async (req: Request, res: Response) => {
// Set the Content-Type header for SVG
res.setHeader('Content-Type', 'image/svg+xml');

// SVG content with the word "pong"
const svgContent = `
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
<text x="10" y="30" font-family="Arial" font-size="24" fill="black">pong</text>
</svg>
`;

// Send the SVG content
res.status(200).send(svgContent);
});

router.get('/api/files/:fileId(*)', async (req: Request, res: Response) => {
res.status(404).send('File not found');
});

return router;
};
Loading