import { FastifyInstance , FastifyRequest , FastifyReply } from 'fastify' ; import { ServerInstance } from '../types' ; import { createEdv , getEdvs , getEdv , createDocument , getDocument , updateDocument , createAuthorization , createRevocation , createChunk , getChunk , queryEdv , } from './operations' ; export default async ( server ) : Promise < void > => { server . post ( '/' , async ( request , reply ) => { const response = await createEdv ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; server . get ( '/' , async ( request , reply ) => { const response = await getEdvs ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; server . get ( '/:edvId' , async ( request , reply ) => { const response = await getEdv ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; server . post ( '/:edvId/query' , async ( request , reply ) => { const response = await queryEdv ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; server . post ( '/:edvId/documents' , async ( request , reply ) => { const response = await createDocument ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; server . get ( '/:edvId/documents' , async ( request , reply ) => { const response = await getDocument ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; server . get ( '/:edvId/documents/:docId' , async ( request , reply ) => { const response = await getDocument ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; server . post ( '/:edvId/documents/:docId' , async ( request , reply ) => { const response = await updateDocument ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; server . post ( '/:edvId/documents/:docId/chunks/:chunkIndex' , async ( request , reply ) => { const response = await createChunk ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; server . get ( '/:edvId/documents/:docId/chunks/:chunkIndex' , async ( request , reply ) => { const response = await getChunk ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; server . post ( '/:edvId/authorizations' , async ( request , reply ) => { const response = await createAuthorization ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; server . post ( '/:edvId/revocations' , async ( request , reply ) => { const response = await createRevocation ( { server : server as ServerInstance , method : request . method , path : request . url , params : request . params , query : request . query , headers : request . headers , body : request . body } ) ; return reply . status ( response . status ) . headers ( response . headers ) . send ( response . body ) ; } ) ; } ;