Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-vans-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@embedly/platforms": minor
---

added reddit support (mostly working)
2 changes: 1 addition & 1 deletion apps/api/biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"root": false,
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["@embedly/config/biome"],
"extends": ["@embedly/config/biome.json"],
"files": {
"includes": ["./src/**"]
}
Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"dev": "wrangler dev --config wrangler.local.jsonc",
"lint": "biome ci ./src/*",
"build": "pkgroll && wrangler deploy --dry-run",
"build": "pkgroll --sourcemap=inline && tsc && wrangler deploy --dry-run",
"deploy": "wrangler deploy --minify",
"deploy:local": "wrangler deploy --config wrangler.local.jsonc --minify",
"cf-typegen": "wrangler types"
Expand Down
3 changes: 2 additions & 1 deletion apps/api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": "@embedly/config/typescript",
"extends": "@embedly/config/tsconfig.json",
"exclude": ["node_modules"],
"include": ["src"],
"compilerOptions": {
"types": ["./worker-configuration.d.ts", "@types/node"],
"outDir": "./dist"
}
}
2 changes: 1 addition & 1 deletion apps/bot/biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"root": false,
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["@embedly/config/biome"]
"extends": ["@embedly/config/biome.json"]
}
2 changes: 1 addition & 1 deletion apps/bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"dev": "tsx watch --env-file=.env src/main.ts",
"lint": "biome ci ./src/*",
"build": "pkgroll"
"build": "pkgroll --sourcemap=inline && tsc"
},
"devDependencies": {
"@biomejs/biome": "2.3.10",
Expand Down
5 changes: 4 additions & 1 deletion apps/bot/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "@embedly/config/typescript",
"extends": "@embedly/config/tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
},
"exclude": ["node_modules"],
"include": ["src"]
}
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["@embedly/config/biome"],
"extends": ["@embedly/config/biome.json"],
"root": true
}
2 changes: 1 addition & 1 deletion packages/builder/biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"root": false,
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["@embedly/config/biome"]
"extends": ["@embedly/config/biome.json"]
}
2 changes: 1 addition & 1 deletion packages/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"scripts": {
"lint": "biome ci ./src/*",
"build": "pkgroll"
"build": "pkgroll --sourcemap=inline && tsc && tsc"
},
"devDependencies": {
"@biomejs/biome": "2.3.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/builder/src/Embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class Embed implements EmbedData {

if (description) {
section.addTextDisplayComponents((builder) =>
builder.setContent(escapeMarkdown(description))
builder.setContent(description)
);
}

Expand Down
5 changes: 3 additions & 2 deletions packages/builder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "@embedly/config/typescript",
"extends": "@embedly/config/tsconfig.json",
"compilerOptions": {
"lib": ["WebWorker", "ESNext"]
"lib": ["WebWorker", "ESNext"],
"outDir": "./dist"
},
"exclude": ["node_modules"],
"include": ["src"]
Expand Down
4 changes: 2 additions & 2 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"type": "module",
"exports": {
"./typescript": "./tsconfig.json",
"./biome": "./biome.json"
"./tsconfig.json": "./tsconfig.json",
"./biome.json": "./biome.json"
},
"devDependencies": {
"@biomejs/biome": "2.3.10"
Expand Down
4 changes: 3 additions & 1 deletion packages/config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"alwaysStrict": true,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"importHelpers": false,
"lib": ["esnext"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"newLine": "lf",
"noEmit": true,
"noEmitHelpers": false,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
Expand All @@ -21,6 +21,8 @@
"pretty": true,
"removeComments": false,
"resolveJsonModule": true,
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "ESNext",
Expand Down
2 changes: 1 addition & 1 deletion packages/logging/biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"root": false,
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["@embedly/config/biome"]
"extends": ["@embedly/config/biome.json"]
}
2 changes: 1 addition & 1 deletion packages/logging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"scripts": {
"lint": "biome ci ./src/*",
"build": "pkgroll"
"build": "pkgroll --sourcemap=inline && tsc"
},
"devDependencies": {
"@biomejs/biome": "2.3.10",
Expand Down
5 changes: 3 additions & 2 deletions packages/logging/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "@embedly/config/typescript",
"extends": "@embedly/config/tsconfig.json",
"compilerOptions": {
"lib": ["WebWorker", "ESNext"]
"lib": ["WebWorker", "ESNext"],
"outDir": "./dist"
},
"exclude": ["node_modules"],
"include": ["src"]
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"root": false,
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["@embedly/config/biome"]
"extends": ["@embedly/config/biome.json"]
}
2 changes: 1 addition & 1 deletion packages/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"scripts": {
"lint": "biome ci ./src/*",
"build": "pkgroll"
"build": "pkgroll --sourcemap=inline && tsc"
},
"devDependencies": {
"@biomejs/biome": "2.3.10",
Expand Down
4 changes: 4 additions & 0 deletions packages/parser/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CBC_REGEX,
GENERIC_LINK_REGEX,
IG_REGEX,
REDDIT_REGEX,
THREADS_REGEX,
TIKTOK_REGEX_MAIN,
TWITTER_REGEX
Expand Down Expand Up @@ -37,5 +38,8 @@ export function getPlatformFromURL(
if (THREADS_REGEX.test(url)) {
return { type: EmbedlyPlatformType.Threads };
}
if (REDDIT_REGEX.test(url)) {
return { type: EmbedlyPlatformType.Reddit };
}
return null;
}
2 changes: 2 additions & 0 deletions packages/parser/src/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ export const TIKTOK_REGEX =
export const THREADS_REGEX =
/threads\.com\/@.*\/post\/(?<thread_shortcode>[A-Za-z0-9-_]+)/;
export const CBC_REGEX = /cbc.ca\/.*(?<cbc_id>\d\.\d+)/;
export const REDDIT_REGEX =
/https?:\/\/(?:www\.|old\.|m\.)?reddit\.com\/r\/(?<subreddit>\w+)\/comments\/(?<post_id>[a-z0-9]+)/;
5 changes: 3 additions & 2 deletions packages/parser/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "@embedly/config/typescript",
"extends": "@embedly/config/tsconfig.json",
"compilerOptions": {
"lib": ["WebWorker", "ESNext"]
"lib": ["WebWorker", "ESNext"],
"outDir": "./dist"
},
"exclude": ["node_modules"],
"include": ["src"]
Expand Down
2 changes: 1 addition & 1 deletion packages/platforms/biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"root": false,
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["@embedly/config/biome"],
"extends": ["@embedly/config/biome.json"],
"linter": {
"rules": {
"complexity": {
Expand Down
2 changes: 1 addition & 1 deletion packages/platforms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"scripts": {
"lint": "biome ci ./src/*",
"build": "pkgroll"
"build": "pkgroll --sourcemap=inline && tsc"
},
"devDependencies": {
"@biomejs/biome": "2.3.10",
Expand Down
4 changes: 4 additions & 0 deletions packages/platforms/src/Instagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export class Instagram extends EmbedlyPlatform {
"X-FB-LSD": "AVqbxe3J_YA",
"X-ASBD-ID": "129477",
"Sec-Fetch-Site": "same-origin"
},
cf: {
cacheTtl: 60 * 60 * 24,
cacheEverything: true
}
});
if (!resp.ok) {
Expand Down
4 changes: 3 additions & 1 deletion packages/platforms/src/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export abstract class EmbedlyPlatform {
});
}
abstract fetchPost<T>(post_id: string, env?: any): Promise<T>;
abstract transformRawData(raw_data: any): BaseEmbedData;
abstract transformRawData(
raw_data: any
): Promise<BaseEmbedData> | BaseEmbedData;
abstract createEmbed<T>(post_data: T): Promise<Embed> | Embed;
}
Loading