feat: basic api
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import express, { Express, Request, Response } from "express";
|
||||
import cors from "cors";
|
||||
import * as dotenv from "dotenv";
|
||||
import transactionsRouter from './routes/transactions';
|
||||
|
||||
|
||||
dotenv.config();
|
||||
@@ -13,6 +14,8 @@ app.get("/api/health", (req: Request, res: Response) => {
|
||||
res.json({ status: "OK" });
|
||||
});
|
||||
|
||||
app.use('/api/transactions', transactionsRouter);
|
||||
|
||||
const PORT: number = parseInt(process.env.PORT as string) || 3000;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server running on port ${PORT}`);
|
||||
|
||||
17
server/src/routes/transactions.ts
Normal file
17
server/src/routes/transactions.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import express from 'express';
|
||||
import { Transaction } from "@shared/interfaces/transaction"
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// Mock data
|
||||
const mockTransactions: Transaction[] = [
|
||||
{ id: '1', partner: 'Alice Smith', amount: 50.00, date: new Date('2026-03-01'), type: 'Received' },
|
||||
{ id: '2', partner: 'Bob Johnson', amount: -25.50, date: new Date('2026-02-28'), type: 'Sent' },
|
||||
];
|
||||
|
||||
// GET /api/transactions
|
||||
router.get('/', (req, res) => {
|
||||
res.json(mockTransactions);
|
||||
});
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user