import { NextApiRequest , NextApiResponse } from 'next' ; import * as browserService from '../../../be-modules/browser' ; import { RCloneErrorRemark } from '../../../be-modules/rclone/error' ; export default async ( req , res ) => { const path = Buffer . from ( String ( req . query . path ) , 'base64' ) . toString ( 'utf-8' ) ; try { await browserService . cat ( path , res ) ; } catch ( e ) { if ( e . remark === RCloneErrorRemark . DirectoryNotFound ) { res . status ( 404 ) . json ( { statusCode : 404 , message : 'Directory not found' } ) ; } else { res . status ( 404 ) . json ( { statusCode : 404 , message : 'Directory not found' } ) ; } } if ( ! res . headersSent ) { res . status ( 404 ) . json ( { statusCode : 404 , message : 'Directory not found' } ) ; } } ;