This repository was archived by the owner on Jan 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathexpress.js
More file actions
39 lines (34 loc) · 1.5 KB
/
express.js
File metadata and controls
39 lines (34 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const lark = require("@larksuiteoapi/allcore");
const express = require('express');
const appSettings = lark.getInternalAppSettingsByEnv()
const conf = lark.newConfig(lark.Domain.FeiShu, appSettings, {
loggerLevel: lark.LoggerLevel.ERROR,
})
// set handler
lark.card.setHandler(conf, (ctx, card) => {
let conf = lark.core.getConfigByCtx(ctx);
console.log(conf);
console.log("----------------");
console.log(ctx.getHeader());
console.log(ctx.getRequestID());
console.log(card)
return "{\"config\":{\"wide_screen_mode\":true},\"i18n_elements\":{\"zh_cn\":[{\"tag\":\"div\",\"text\":{\"tag\":\"lark_md\",\"content\":\"[飞书](https://www.feishu.cn)整合即时沟通、日历、音视频会议、云文档、云盘、工作台等功能于一体,成就组织和个人,更高效、更愉悦。\"}}]}}";
})
const app = express();
app.use(express.json())
// Start the httpserver, "Developer Console" -> "Features" -> "Bot", setting Message Card Request URL: https://domain/webhook/card
app.post('/webhook/card', (req, res) => {
const request = new lark.core.Request()
Object.entries(req.headers).forEach(([k, v]) => {
request.headers[k] = v
})
request.body = req.body
lark.card.httpHandle(conf, request, undefined).then(response => {
console.log("=================\n", response.body);
res.status(response.statusCode).send(response.body)
})
});
// startup event http server, port: 8089
app.listen(8089, () => {
console.log(`listening at :8089`)
})