Skip to content

Commit

Permalink
add breadcrumbs to document resp
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieVangeysel committed Dec 4, 2024
1 parent e978f73 commit 4da7de2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 8 additions & 2 deletions src/controllers/document.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4da7de2

Please sign in to comment.