1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getOrderById } from "../database/queries.ts";
3import { processPayment, getPaymentMethods } from "../services/payment.ts";
4import { authMiddleware } from "../middleware/auth.ts";
7 getProductById,
8 clearCart
9} from "../database/queries.ts";
10import { authMiddleware } from "../middleware/auth.ts";
11import {
6 removeCartItem,
7 getProductById
8} from "../database/queries.ts";
9import { authMiddleware } from "../middleware/auth.ts";
10import {
5 getProductCategories,
6 getProductsByCategory
7} from "../database/queries.ts";
8import { ApiResponse, Product, ProductCategory } from "../../shared/types.ts";
9
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { createUser, getUserByEmail } from "../database/queries.ts";
3import { sign } from "https://esm.sh/jsonwebtoken@9.0.2";
4import { compare, hash } from "https://esm.sh/bcrypt@5.1.1";
1import { createPayment, updateOrderStatus } from "../database/queries.ts";
2import { OrderStatus, PaymentResponse } from "../../shared/types.ts";
3
24 const transactionId = `txn_${Date.now()}_${Math.floor(Math.random() * 1000000)}`;
25
26 // Record the payment in the database
27 await createPayment(
28 orderId,
52// Get available payment methods
53export function getPaymentMethods() {
54 // In a real application, this might come from a database or payment gateway API
55 return [
56 { id: "credit_card", name: "Credit Card" },
1import { Context, Next } from "https://esm.sh/hono@3.11.7";
2import { getUserById } from "../database/queries.ts";
3import { verify } from "https://esm.sh/jsonwebtoken@9.0.2";
4
19 const decoded = verify(token, jwtSecret) as { userId: number };
20
21 // Get the user from the database
22 const user = await getUserById(decoded.userId);
23
32
33- **Framework**: Hono (TypeScript)
34- **Database**: SQLite
35- **Authentication**: JWT
36- **Payment Processing**: Stripe API integration
40```
41โโโ backend/
42โ โโโ database/
43โ โ โโโ migrations.ts # Schema definitions
44โ โ โโโ queries.ts # DB query functions
2import { cors } from "https://esm.sh/hono@3.11.7/middleware";
3import { readFile, serveFile } from "https://esm.town/v/std/utils/index.ts";
4import { runMigrations } from "./database/migrations.ts";
5import {
6 createJobPosting,
9 createChatMessage,
10 getChatMessages
11} from "./database/queries.ts";
12import { parseProject } from "https://esm.town/v/std/utils/index.ts";
13
65}
66
67// Helper functions to map database rows to TypeScript types
68function mapJobRow(row: any): JobPosting {
69 return {