- npm updates

- uncomment eprints description inside datasetxml2oai-pmh.xslt
- test with multer for uploading files  multipart/form-data
- allow post and get methods dor oai.controller.ts
This commit is contained in:
Arno Kaimbacher 2022-11-29 09:07:48 +01:00
parent 05e9273823
commit 6944deac83
4 changed files with 29 additions and 10 deletions

View file

@ -40,11 +40,14 @@ export class App extends Server {
next();
});
// this.app.use(bodyParser.json());
// this.app.use(bodyParser.urlencoded({ extended: true }));
// this.app.use(bodyParser.json());
// for parsing application/json
this.app.use(bodyParser.json({ limit: "100mb" }));
// for parsing application/xwww-
this.app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
this.app.use(bodyParser.json({ type: "application/vnd.api+json" }));
// this.app.use(forms.array());
// for parsing multipart/form-data = uploads
// this.app.use(upload.array());
}
private boostrap(): void {

View file

@ -88,7 +88,16 @@ export class OaiController {
(earliestDateFromDb = dayjs(firstPublishedDataset.server_date_published).format("YYYY-MM-DDTHH:mm:ss[Z]"));
this.xsltParameter["earliestDatestamp"] = earliestDateFromDb;
const oaiRequest: OaiParameter = request.query;
let oaiRequest: OaiParameter = {};
if (request.method == "POST") {
oaiRequest = request.body;
} else if (request.method == "GET") {
oaiRequest = request.query;
} else {
this.xsltParameter["oai_error_code"] = "unknown";
this.xsltParameter["oai_error_message"] = "An internal error occured.";
}
// const oaiRequest: OaiParameter = request.body;
try {
await this.handleRequest(oaiRequest, request);
} catch (error) {
@ -450,7 +459,7 @@ export class OaiController {
};
includeArray.push(icncludeFilter);
}
}
}
// const timeZone = "Europe/Vienna"; // Canonical time zone name
// &from=2020-09-03&until2020-09-03
@ -506,7 +515,7 @@ export class OaiController {
OaiErrorCodes.BADARGUMENT,
);
}
fromDate = dayjs.tz(from, "Europe/Vienna")
fromDate = dayjs.tz(from, "Europe/Vienna");
fromDate.hour() == 0 && (fromDate = fromDate.startOf("day"));
const now = dayjs();
@ -534,7 +543,7 @@ export class OaiController {
OaiErrorCodes.BADARGUMENT,
);
}
untilDate = dayjs.tz(until, "Europe/Vienna");
untilDate = dayjs.tz(until, "Europe/Vienna");
untilDate.hour() == 0 && (untilDate = untilDate.endOf("day"));
const firstPublishedDataset: Dataset = (await Dataset.earliestPublicationDate()) as Dataset;