forked from JJUNGTABLE/Back
[👷] 설정 작업
This commit is contained in:
parent
826f11719a
commit
3d3f6f2779
45
apps/push.js
Normal file
45
apps/push.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { admin } from '../firebaseConfig.js';
|
||||
|
||||
export function HandlePush(req, res) {
|
||||
const { fcmToken, title, body, parameter, sound, badge } = req.body;
|
||||
|
||||
if (!fcmToken || !title || !body) {
|
||||
res.status(400).json({ error: 'fcmToken, title, body, and parameter are required' });
|
||||
return;
|
||||
}
|
||||
|
||||
const message = {
|
||||
token: fcmToken,
|
||||
notification: {
|
||||
title: title,
|
||||
body: body,
|
||||
},
|
||||
apns: {
|
||||
payload: {
|
||||
aps: {
|
||||
alert: {
|
||||
title: title,
|
||||
body: body,
|
||||
parameter: parameter,
|
||||
},
|
||||
sound: sound || 'default',
|
||||
badge: badge ? Number(badge) : 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// const jjApp = admin.app('jjungtable');
|
||||
|
||||
admin.app('jjungtable').messaging().send(message)
|
||||
.then((response) => {
|
||||
console.log('Successfully sent message:', response);
|
||||
res.status(200).json({ message: 'Successfully sent message' });
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error sending message:', error);
|
||||
res.status(500).json({ error: `Error sending message: ${error.message}` });
|
||||
});
|
||||
}
|
||||
|
16
db/database.js
Normal file
16
db/database.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
import mysql from 'mysql2/promise';
|
||||
|
||||
// 데이터베이스 연결 설정 함수
|
||||
export const createDatabaseConnection = (config) => {
|
||||
return mysql.createConnection({
|
||||
host: config.host,
|
||||
user: config.user,
|
||||
password: config.password,
|
||||
database: config.database,
|
||||
port: config.port,
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue
Block a user