import express from "express" ; import { getLikesByTransactionId , createLikes } from "./database" ; import { ensureAuthenticated , validateMiddleware } from "./helpers" ; import { shortIdValidation } from "./validators" ; const router = express . Router ( ) ; router . get ( "/:transactionId" , ensureAuthenticated , validateMiddleware ( [ shortIdValidation ( "transactionId" ) ] ) , ( req , res ) => { const { transactionId } = req . params ; const likes = getLikesByTransactionId ( transactionId ) ; res . status ( 200 ) ; res . json ( { likes } ) ; } ) ; router . post ( "/:transactionId" , ensureAuthenticated , validateMiddleware ( [ shortIdValidation ( "transactionId" ) ] ) , ( req , res ) => { const { transactionId } = req . params ; createLikes ( req . user ?. id ! , transactionId ) ; res . sendStatus ( 200 ) ; } ) ; export default router ;