Skip to content

Commit

Permalink
refacto: fix metascraper for route handler
Browse files Browse the repository at this point in the history
  • Loading branch information
quentingrchr committed Oct 2, 2024
1 parent b854534 commit 82c5503
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 9 deletions.
10 changes: 10 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ const nextConfig = {
serverActions: true,
serverComponentsExternalPackages: ['mjml', 'mjml-react'],
},

webpack: (config, { isServer }) => {
// to use metascraper in route handlers https://github.com/uhop/node-re2/issues/63#issuecomment-1785743859
config.module.rules.push({
test: /\.node$/,
loader: 'node-loader',
});

return config;
},
reactStrictMode: false,
};

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"next-connect": "^1.0.0-next.3",
"next-contentlayer": "^0.3.2",
"next-superjson-plugin": "^0.5.8",
"node-loader": "^2.0.0",
"nodemailer": "^6.9.1",
"openai": "^4.10.0",
"plaiceholder": "^2.5.0",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import db from '@/lib/db';
import { saveBookmark } from '@/services/database/bookmark';
import { TBlock, extractLinksFromBlocks } from '@/utils/slack';
import axios from 'axios';

interface SlackPayload {
type: 'message_action';
Expand All @@ -14,7 +13,6 @@ interface SlackPayload {
};
}


export async function POST(request: Request) {
try {
const body = await request.json();
Expand All @@ -39,12 +37,17 @@ export async function POST(request: Request) {
)
);

// Send response to Slack
await axios.post(payload.response_url, {
text: `:pushpin: ${links.join(',')} has been added to your team feed *${
team.name
}*`,
response_type: 'ephemeral',
await fetch(payload.response_url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: `:pushpin: ${links.join(
','
)} has been added to your team feed *${team.name}*`,
response_type: 'ephemeral',
}),
});

return new Response(JSON.stringify({ bookmarks }), { status: 200 });
Expand Down
28 changes: 27 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3881,6 +3881,11 @@ big-integer@^1.6.16:
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686"
integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==

big.js@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==

bin-version-check@~5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/bin-version-check/-/bin-version-check-5.1.0.tgz#788e80e036a87313f8be7908bc20e5abe43f0837"
Expand Down Expand Up @@ -5316,6 +5321,11 @@ emoji-regex@^9.2.2:
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72"
integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==

emojis-list@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78"
integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==

encoding@0.1.13, encoding@^0.1.13:
version "0.1.13"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9"
Expand Down Expand Up @@ -7945,7 +7955,7 @@ json5@^1.0.2:
dependencies:
minimist "^1.2.0"

json5@^2.2.3:
json5@^2.1.2, json5@^2.2.3:
version "2.2.3"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
Expand Down Expand Up @@ -8101,6 +8111,15 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==

loader-utils@^2.0.0:
version "2.0.4"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c"
integrity sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==
dependencies:
big.js "^5.2.2"
emojis-list "^3.0.0"
json5 "^2.1.2"

localforage@^1.8.1:
version "1.10.0"
resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.10.0.tgz#5c465dc5f62b2807c3a84c0c6a1b1b3212781dd4"
Expand Down Expand Up @@ -9726,6 +9745,13 @@ node-int64@^0.4.0:
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==

node-loader@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/node-loader/-/node-loader-2.0.0.tgz#9109a6d828703fd3e0aa03c1baec12a798071562"
integrity sha512-I5VN34NO4/5UYJaUBtkrODPWxbobrE4hgDqPrjB25yPkonFhCmZ146vTH+Zg417E9Iwoh1l/MbRs1apc5J295Q==
dependencies:
loader-utils "^2.0.0"

node-releases@^2.0.13:
version "2.0.13"
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.13.tgz#d5ed1627c23e3461e819b02e57b75e4899b1c81d"
Expand Down

0 comments on commit 82c5503

Please sign in to comment.