Add VSCode task for automatic build on project open and update dependencies

Remove .vscode from .gitignore to allow for project-specific settings. Introduce a VSCode task to run `npm run dev` automatically when the project is opened. Update environment configuration files and dependencies to enhance support for the Node adapter.

Fixes #13
This commit is contained in:
GitHub Copilot
2025-05-01 21:05:24 +00:00
parent 8058df41fd
commit b51fe35a16
23 changed files with 342 additions and 401 deletions

View File

@@ -10,9 +10,9 @@
* - Set up proper CORS configuration
*/
import type { APIRoute } from "astro";
import { transactions, accounts } from "../../../data/store";
import type { Transaction } from "../../../types";
import type { APIRoute } from 'astro';
import { transactions, accounts } from '../../../data/store';
import type { Transaction } from '../../../types';
/**
* TODO: API Improvements
@@ -27,7 +27,7 @@ import type { Transaction } from "../../../types";
export const POST: APIRoute = async ({ request }) => {
try {
const transaction = (await request.json()) as Omit<Transaction, "id">;
const transaction = (await request.json()) as Omit<Transaction, 'id'>;
// Validate required fields
if (
@@ -36,21 +36,18 @@ export const POST: APIRoute = async ({ request }) => {
!transaction.description ||
transaction.amount === undefined
) {
return new Response(
JSON.stringify({ error: "Missing required fields" }),
{
status: 400,
headers: { "Content-Type": "application/json" },
}
);
return new Response(JSON.stringify({ error: 'Missing required fields' }), {
status: 400,
headers: { 'Content-Type': 'application/json' },
});
}
// Validate account exists
const account = accounts.find((a) => a.id === transaction.accountId);
if (!account) {
return new Response(JSON.stringify({ error: "Account not found" }), {
return new Response(JSON.stringify({ error: 'Account not found' }), {
status: 404,
headers: { "Content-Type": "application/json" },
headers: { 'Content-Type': 'application/json' },
});
}
@@ -68,12 +65,12 @@ export const POST: APIRoute = async ({ request }) => {
return new Response(JSON.stringify(newTransaction), {
status: 201,
headers: { "Content-Type": "application/json" },
headers: { 'Content-Type': 'application/json' },
});
} catch (error) {
return new Response(JSON.stringify({ error: "Invalid request body" }), {
return new Response(JSON.stringify({ error: 'Invalid request body' }), {
status: 400,
headers: { "Content-Type": "application/json" },
headers: { 'Content-Type': 'application/json' },
});
}
};