import * as path from 'path' ; import * as express from 'express' ; import checkPublicApiVersionHeaders from '../middlewares/checkPublicApiVersionHeaders' ; import constructJrd from '../middlewares/constructJrd' ; import errorHandler , { wrapAsync } from '../middlewares/errorHandler' ; import initializeMetrics from '../middlewares/initializeMetrics' ; import getPaymentInfo from '../middlewares/payIds' ; import sendSuccess from '../middlewares/sendSuccess' ; const publicApiRouter = express . Router ( ) ; /**
 * Routes for the PayID Public API.
 */ publicApiRouter . use ( ( _req , res , next ) => { res . header ( 'Access-Control-Allow-Origin' , '*' ) ; res . header ( 'Access-Control-Allow-Methods' , 'GET, OPTIONS' ) ; res . header ( 'Access-Control-Allow-Headers' , 'PayID-Version' ) ; res . header ( 'Access-Control-Expose-Headers' , 'PayID-Version, PayID-Server-Version' ) ; next ( ) ; } ) . get ( '/' , ( _req , res ) => { res . sendFile ( path . join ( __dirname , '../html/index.html' ) ) ; } ) . get ( '/favicon.ico' , ( _req , res ) => { res . sendFile ( path . join ( __dirname , '../html/favicon.ico' ) ) ; } ) . get ( '/status/health' , sendSuccess ) . get ( '/.well-known/webfinger' , constructJrd , sendSuccess ) . get ( '/*' , checkPublicApiVersionHeaders , initializeMetrics , wrapAsync ( getPaymentInfo ) , sendSuccess ) . use ( errorHandler ) ; export default publicApiRouter ;