19 lines
752 B
JavaScript
19 lines
752 B
JavaScript
const { sendLineworksMessage } = require('./lineworksCore');
|
|
const API_KEY = 'pgqhLFWbDFu4Byz#4afNYX2F6Fa1&$KPjved$8%sUdTQV52caip#EpIKxYUkdd4S';
|
|
|
|
exports.lwSendMessageHandler = async (req, res) => {
|
|
const apiKey = req.headers['x-api-key'];
|
|
if (!apiKey || apiKey !== API_KEY) {
|
|
return res.status(401).json({ error: 'APIキーが不正です' });
|
|
}
|
|
const { botId, userId, messageText } = req.body;
|
|
if (!botId || !userId || !messageText) {
|
|
return res.status(400).json({ error: 'botId, userId, messageTextは必須です' });
|
|
}
|
|
try {
|
|
await sendLineworksMessage(botId, userId, messageText);
|
|
res.json({ result: 'ok' });
|
|
} catch (e) {
|
|
res.status(500).json({ error: e.message });
|
|
}
|
|
}; |