-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
649 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { LemmyHttp, Login, GetCaptcha} from "lemmy-js-client" | ||
|
||
export async function POST(req: Request) { | ||
try { | ||
const body = await req.json(); | ||
|
||
const auth = body.auth, instance = body.instance ? `https://${body.instance}` : "https://lemmy.world"; | ||
console.log(body.instance, instance); | ||
const client = new LemmyHttp(instance); | ||
|
||
const response = await client.getCaptcha(); | ||
return new Response(JSON.stringify({ response }), { status: 200, headers: { 'Content-Type': 'application/json' } }) | ||
|
||
} catch (e: any) { | ||
console.error(e); | ||
return new Response(JSON.stringify({ error: e }), { status: 500, headers: { 'Content-Type': 'application/json' } }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { LemmyHttp, Login} from "lemmy-js-client" | ||
|
||
export async function POST(req: Request) { | ||
try { | ||
const body = await req.json(); | ||
|
||
const username = body.username, password = body.password, email = body.email, show_nsfw = body.show_nsfw, instance = body.instance ? `https://${body.instance}` : "https://lemmy.world", | ||
captcha_uuid = body.captcha_uuid, captcha_answer = body.captcha_answer, honeypot = body.honeypot, answer = body.answer; | ||
|
||
const client = new LemmyHttp(instance); | ||
|
||
console.log(username, password, email, show_nsfw, instance); | ||
|
||
const register = await client.register({ username, password, password_verify: password, email, show_nsfw: show_nsfw, captcha_uuid, captcha_answer, honeypot, answer }); | ||
|
||
return new Response(JSON.stringify({ register }), { status: 200, headers: { 'Content-Type': 'application/json' } }) | ||
|
||
} catch (e: any) { | ||
console.error(e); | ||
return new Response(JSON.stringify({ error: e }), { status: 500, headers: { 'Content-Type': 'application/json' } }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { parse } from "papaparse"; | ||
|
||
export async function GET(req: Request) { | ||
try { | ||
const url_to_csv = "https://raw.githubusercontent.com/maltfield/awesome-lemmy-instances/main/awesome-lemmy-instances.csv"; | ||
|
||
const data = parse(await (await fetch(url_to_csv)).text(), { header: true }).data; | ||
|
||
|
||
return new Response(JSON.stringify(data), { status: 200, headers: { 'Content-Type': 'application/json' } }) | ||
|
||
} catch (e: any) { | ||
console.error(e); | ||
return new Response(JSON.stringify({ error: e }), { status: 500, headers: { 'Content-Type': 'application/json' } }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { LemmyHttp, PostId, CommentId } from "lemmy-js-client" | ||
|
||
export async function GET(req: Request) { | ||
try { | ||
|
||
// get params from Resuest | ||
let params = new URL(req.url).searchParams; | ||
let auth = params.get("auth") || ""; | ||
let instance = params.get("instance") || undefined; | ||
|
||
let client: LemmyHttp = new LemmyHttp((instance && instance !== "undefined") ? `https://${instance}` : "https://lemmy.world"); | ||
|
||
let instances = await client.getFederatedInstances({ | ||
auth: auth as unknown as string, | ||
}); | ||
|
||
return new Response(JSON.stringify(instances), { status: 200, headers: { 'Content-Type': 'application/json' } }) | ||
|
||
} catch (e: any) { | ||
console.error(e); | ||
return new Response(JSON.stringify({ error: e }), { status: 500, headers: { 'Content-Type': 'application/json' } }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.