diff --git a/README.md b/README.md index 5ab1e69..06379fc 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,6 @@ This api contains all controllers for the management interface available on http - /search - GET / #execute search query - /upload - - + - POST / #upload content to PCM - /users - GET / #retrieve list of users known in DB \ No newline at end of file diff --git a/src/controllers/document.controller.ts b/src/controllers/document.controller.ts index 7f89b6a..82e4685 100644 --- a/src/controllers/document.controller.ts +++ b/src/controllers/document.controller.ts @@ -6,6 +6,7 @@ import Document, { IDocument } from "../repositories/document.repository" import * as helper from '../helper' import Directory from "../repositories/directory.repository" import sql from 'mssql' +import Browse from '../repositories/browse.repository' declare module 'fastify' { export interface FastifyInstance { @@ -45,6 +46,7 @@ export default async function (fastify: FastifyInstance) { try { const pool = await fastify.getSqlPool() const repo = new Document(request.log, pool) + const browse_repo = new Browse(request.log, pool) const mode = request.query.mode ?? 'full' const result: any = (mode === 'preview') ? await repo.getPreview(request.params.id, request.jwt.sub) : await repo.get(request.params.id, request.jwt.sub) if (result.error) return reply.error(result.error) @@ -87,8 +89,12 @@ export default async function (fastify: FastifyInstance) { result.result.hasLargeImage = helper.fileDate(result.result.guid, 'image_large') } } - - return reply.success({ document: result.result }, 200, performance.now() - start) + const breadcrumbs = await browse_repo.getBreadcrumbs(result.result.directoryId, request.jwt.sub) + + return reply.success({ + document: result.result, + breadcrumbs: breadcrumbs.breadcrumbs + }, 200, performance.now() - start) } return reply.error('Session has expired!', 401, performance.now() - start)