diff --git a/package.json b/package.json index 5562344..b781e1b 100755 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "dev": "next dev", "lint": "next lint", "start": "next start", - "go": "next build && next start" + "go": "git pull docker master && next build && next start" }, "dependencies": { "@t3-oss/env-nextjs": "^0.10.1", diff --git a/src/app/api/updatePushToken/route.ts b/src/app/api/updatePushToken/route.ts index 7cdcf31..76f171f 100644 --- a/src/app/api/updatePushToken/route.ts +++ b/src/app/api/updatePushToken/route.ts @@ -10,18 +10,20 @@ type Data = { export const POST = async (request: Request) => { try { const { apiKey, userId, pushToken } = await request.json() as Data; + console.log('Received request:', { apiKey, userId, pushToken }); - // Validate API key (optional, but since you do it, let's continue) if (apiKey !== process.env.API_KEY) { + console.log('Invalid API Key'); return NextResponse.json({ message: "Invalid API Key" }, { status: 401 }); } - // Update push token in the database + console.log('Updating push token for user:', userId); await updateUserPushToken(parseInt(userId), pushToken); + console.log('Push token updated successfully'); return NextResponse.json({ message: "Push token updated successfully" }); } catch (error) { - console.error(error); + console.error('Error in updatePushToken:', error); return NextResponse.json({ message: "Error updating push token" }, { status: 500 }); } }; diff --git a/src/server/db/schema.ts b/src/server/db/schema.ts index 853a4d1..a262dcd 100755 --- a/src/server/db/schema.ts +++ b/src/server/db/schema.ts @@ -14,7 +14,7 @@ export const users = createTable( id: serial("id").primaryKey(), name: varchar("name", { length: 256 }), message: varchar("message", { length: 256 }), - pushToken: varchar("push_token", { length: 256 }), + pushToken: varchar("pushToken", { length: 256 }), createdAt: timestamp("created_at", { withTimezone: true }) .default(sql`CURRENT_TIMESTAMP`) .notNull(),