diff --git a/datasetxml2oai-pmh.xslt b/datasetxml2oai-pmh.xslt index 42f305d..8198118 100755 --- a/datasetxml2oai-pmh.xslt +++ b/datasetxml2oai-pmh.xslt @@ -144,7 +144,7 @@ - + diff --git a/notes.txt b/notes.txt index cede692..3f1d8cd 100644 --- a/notes.txt +++ b/notes.txt @@ -105,4 +105,11 @@ git config --global user.name git config --global user.email git remote add origin https://gitea.geologie.ac.at/geolba/tethys.api.git -git push -o repo.private=false --set-upstream origin master \ No newline at end of file +git push -o repo.private=false --set-upstream origin master + + + +npm install --save multer + +curl -X POST -d "verb=identify" -H "Content-Type: application/xml" http://localhost:3000/oai +curl -X POST -H "Content-Type: application/xml" -d '{"verb": "Identify"}' http://localhost:8080/oai \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index 33d5e84..672b371 100644 --- a/src/app.ts +++ b/src/app.ts @@ -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 { diff --git a/src/controllers/oai.controller.ts b/src/controllers/oai.controller.ts index 65d9e84..595ca61 100644 --- a/src/controllers/oai.controller.ts +++ b/src/controllers/oai.controller.ts @@ -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;