diff --git a/oada/Dockerfile b/oada/Dockerfile index 38c396f6..9fac1ce9 100644 --- a/oada/Dockerfile +++ b/oada/Dockerfile @@ -122,5 +122,6 @@ USER root COPY --from=dev /oada/ /oada/ + # Default to a production target FROM production \ No newline at end of file diff --git a/oada/libs/lib-arangodb/src/libs/putBodies.ts b/oada/libs/lib-arangodb/src/libs/putBodies.ts index 650c18d9..057e2265 100644 --- a/oada/libs/lib-arangodb/src/libs/putBodies.ts +++ b/oada/libs/lib-arangodb/src/libs/putBodies.ts @@ -18,7 +18,7 @@ import { config } from '../config.js'; import { db as database } from '../db.js'; -const collection = database.collection( +const collection = database.collection<{body: unknown}>( config.get('arangodb.collections.putBodies.name'), ); @@ -26,15 +26,23 @@ const collection = database.collection( * Give string of JSON rather than object */ export async function savePutBody(body: string): Promise<{ _id: string }> { - // The _id comes back in the response to save - return collection.save({body}); + // HACK: send body without parsing it + const cursor = await database.query({ + query: ` + INSERT ${body} + INTO ${collection.name} + RETURN NEW._id + `, + bindVars: {}, + }); + return { _id: (await cursor.next())! }; } export async function getPutBody(id: string): Promise { - const { body } = (await collection.document(id)) as { body: unknown }; + const { body } = await collection.document(id); return body; } export async function removePutBody(id: string): Promise { await collection.remove(id); -} +} \ No newline at end of file diff --git a/oada/services/http-handler/src/resources.ts b/oada/services/http-handler/src/resources.ts index a9fb6503..97aa1430 100644 --- a/oada/services/http-handler/src/resources.ts +++ b/oada/services/http-handler/src/resources.ts @@ -550,7 +550,7 @@ const plugin: FastifyPluginAsync = async (fastify, options) => { const { _id: bodyid } = await putBodies.savePutBody( request.body as string, ); - request.log.trace({ oadaGraph: request.oadaGraph }, 'PUT body saved'); + request.log.debug({ oadaGraph: request.oadaGraph, bodyid }, 'PUT body saved'); request.log.trace('Resource exists: %s', request.resourceExists); const ignoreLinks = @@ -740,4 +740,4 @@ const plugin: FastifyPluginAsync = async (fastify, options) => { }); }; -export default plugin; +export default plugin; \ No newline at end of file