- 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

@ -144,7 +144,7 @@
</sampleIdentifier> </sampleIdentifier>
</oai-identifier> </oai-identifier>
</description> </description>
<description> <!-- <description>
<eprints xmlns="http://www.openarchives.org/OAI/1.1/eprints" xsi:schemaLocation="http://www.openarchives.org/OAI/1.1/eprints http://www.openarchives.org/OAI/1.1/eprints.xsd"> <eprints xmlns="http://www.openarchives.org/OAI/1.1/eprints" xsi:schemaLocation="http://www.openarchives.org/OAI/1.1/eprints http://www.openarchives.org/OAI/1.1/eprints.xsd">
<content> <content>
<text> <text>
@ -166,7 +166,7 @@
See https://gitea.geologie.ac.at/geolba/tethys/ for more information. See https://gitea.geologie.ac.at/geolba/tethys/ for more information.
</comment> </comment>
</eprints> </eprints>
</description> </description> -->
</Identify> </Identify>
</xsl:template> </xsl:template>

View File

@ -106,3 +106,10 @@ git config --global user.email
git remote add origin https://gitea.geologie.ac.at/geolba/tethys.api.git git remote add origin https://gitea.geologie.ac.at/geolba/tethys.api.git
git push -o repo.private=false --set-upstream origin master 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

View File

@ -41,10 +41,13 @@ export class App extends Server {
}); });
// this.app.use(bodyParser.json()); // this.app.use(bodyParser.json());
// this.app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/json
this.app.use(bodyParser.json({ limit: "100mb" })); this.app.use(bodyParser.json({ limit: "100mb" }));
// for parsing application/xwww-
this.app.use(bodyParser.urlencoded({ limit: "50mb", extended: true })); 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 { 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]")); (earliestDateFromDb = dayjs(firstPublishedDataset.server_date_published).format("YYYY-MM-DDTHH:mm:ss[Z]"));
this.xsltParameter["earliestDatestamp"] = earliestDateFromDb; 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 { try {
await this.handleRequest(oaiRequest, request); await this.handleRequest(oaiRequest, request);
} catch (error) { } catch (error) {
@ -506,7 +515,7 @@ export class OaiController {
OaiErrorCodes.BADARGUMENT, OaiErrorCodes.BADARGUMENT,
); );
} }
fromDate = dayjs.tz(from, "Europe/Vienna") fromDate = dayjs.tz(from, "Europe/Vienna");
fromDate.hour() == 0 && (fromDate = fromDate.startOf("day")); fromDate.hour() == 0 && (fromDate = fromDate.startOf("day"));
const now = dayjs(); const now = dayjs();