Trying to fix push notifs
This commit is contained in:
parent
03fc9c9c1e
commit
dcc57a43bb
@ -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",
|
||||
|
@ -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 });
|
||||
}
|
||||
};
|
||||
|
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user