ken_nogi/oldCode/LINEWORKS_Pleasanter/server.js
Kenichiro NOGI 06c28e8b5a oldCode: 旧LINEWORKS/Pleasanter連携コード一式を追加
express/LINEWORKS_Pleasanter/LINEWORKS_sendMessage、いずれも過去の
Express実装。Gitea移行に伴い保管。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-05 10:42:21 +09:00

46 lines
1.5 KiB
JavaScript

const express = require('express');
const cors = require('cors');
const https = require('https');
const fs = require('fs');
const API_KEY = 'pgqhLFWbDFu4Byz#4afNYX2F6Fa1&$KPjved$8%sUdTQV52caip#EpIKxYUkdd4S'; // 任意のAPIキーを設定
const app = express();
app.use(cors({
origin: [
'https://neo999.next-hd.net',
'https://nextoffice.next-hd.co.jp',
], // 許可するオリジン
optionsSuccessStatus: 200
}));
// APIエンドポイント
app.post('/server', (req, res) => {
let rawBody = '';
req.on('data', (chunk) => {
rawBody += chunk; // リクエストデータをそのまま取得
});
req.on('end', () => {
// APIキーの検証
const apiKey = req.headers['x-api-key'];
if (!apiKey || apiKey !== API_KEY) {
return res.status(401).json({ error: 'APIキーが不正です' });
}
console.log('Headers:', req.headers); // ヘッダーを出力
console.log('Raw Body:', rawBody); // パースせずにそのまま出力
res.json({ message: 'リクエストを受け付けました', rawBody });
});
});
// HTTPSサーバー起動
const PORT = 30399;
const sslOptions = {
cert: fs.readFileSync('/etc/letsencrypt/live/neo999.next-hd.net/fullchain.pem'),
key: fs.readFileSync('/etc/letsencrypt/live/neo999.next-hd.net/privkey.pem')
};
https.createServer(sslOptions, app).listen(PORT, () => {
console.log(`APIサーバー起動: https://neo999.next-hd.net:${PORT}/server`);
});