8 CreateProductPayload, // Added import
9} from "../../shared/types.ts"
10import * as db from "../database/queries.ts"
11import {aiServiceInstance} from "./aiService.ts"
12import {logUserAction} from "./userService.ts"
36 await blob.set(blobId, ia)
37
38 // Create a preliminary bill record in the database
39 const scanDate = new Date().toISOString()
40 const partialBill = await db.createSupplierBill(blobId, scanDate, userId)
5 CreateCategoryPayload,
6} from "../../shared/types.ts";
7import * as db from "../database/queries.ts";
8import { logUserAction } from "./userService.ts"; // For logging actions
9
14import {aiServiceInstance} from "./services/aiService.ts" // Added for direct AI calls
15
16import {runMigrations} from "./database/migrations.ts"
17import {
18 CreateUserPayload,
76 if (!migrationsRun) {
77 try {
78 console.log("Running database migrations...")
79 await runMigrations()
80 migrationsRun = true
81 console.log("Database migrations completed.")
82 } catch (e) {
83 console.error("Migration failed:", e)
84 // Optionally, you could prevent the app from starting or return an error response
85 return c.json({error: "Database migration failed", message: e.message}, 500)
86 }
87 }
132 `)
133
134 console.log("Database migrations completed.")
135}
136
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 getChatMessages,
9 getJobPostingById,
10 addJobPosting
11} from "./database/queries.ts";
12import { ApiResponse, ChatMessage, JobPosting } from "../shared/types.ts";
13
88 }
89
90 // Add the message to the database
91 const newMessage = await addChatMessage(username, message);
92
188 }
189
190 // Add the job posting to the database
191 const newJob = await addJobPosting(
192 title,
6import { chatRouter } from "./routes/chat.ts";
7import { staticRouter } from "./routes/static.ts";
8import { runMigrations } from "./database/migrations.ts";
9import { updateUserOnlineStatus, removeOfflineUsers } from "./database/queries.ts";
10
11// Initialize the app
27}));
28
29// Run database migrations
30app.use("*", async (c, next) => {
31 try {
34 } catch (error) {
35 console.error("Migration error:", error);
36 return c.text("Database initialization error", 500);
37 }
38});
10 markMessagesAsRead,
11 getUnreadMessageCounts
12} from "../database/queries.ts";
13import { ApiResponse, ChatRoom, ChatRoomMessage, Message, User } from "../../shared/types.ts";
14
9 deleteComment,
10 toggleLike
11} from "../database/queries.ts";
12import { ApiResponse, Post, Comment } from "../../shared/types.ts";
13
6 getUserLikedPosts,
7 getOnlineUsers
8} from "../database/queries.ts";
9import { ApiResponse, User, Post } from "../../shared/types.ts";
10
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { jwt } from "https://esm.sh/hono@3.11.7/middleware/jwt";
3import { createUser, getUserByEmail, verifyUser } from "../database/queries.ts";
4import { SignupRequest, LoginRequest, ApiResponse, AuthResponse } from "../../shared/types.ts";
5