From 94e50f3c782dd9cd5b6cf912fa4774e9b18d0b9b Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sat, 23 Sep 2023 21:54:42 +0900 Subject: [PATCH] Get status id from readline in examples --- example/typescript/src/firefish/get_note.ts | 27 +++++++++++++++++++ example/typescript/src/firefish/note.ts | 11 -------- .../src/firefish/{toot.ts => post_note.ts} | 0 example/typescript/src/mastodon/get_status.ts | 21 +++++++++++++++ example/typescript/src/mastodon/status.ts | 16 ----------- example/typescript/src/pleroma/get_status.ts | 22 +++++++++++++++ 6 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 example/typescript/src/firefish/get_note.ts delete mode 100644 example/typescript/src/firefish/note.ts rename example/typescript/src/firefish/{toot.ts => post_note.ts} (100%) create mode 100644 example/typescript/src/mastodon/get_status.ts delete mode 100644 example/typescript/src/mastodon/status.ts create mode 100644 example/typescript/src/pleroma/get_status.ts diff --git a/example/typescript/src/firefish/get_note.ts b/example/typescript/src/firefish/get_note.ts new file mode 100644 index 000000000..98b74648d --- /dev/null +++ b/example/typescript/src/firefish/get_note.ts @@ -0,0 +1,27 @@ +import * as readline from 'readline' +import generator, { MegalodonInterface } from 'megalodon' + +const rl: readline.ReadLine = readline.createInterface({ + input: process.stdin, + output: process.stdout +}) + +const BASE_URL: string = process.env.FIREFISH_URL! +const access_token: string = process.env.FIREFISH_ACCESS_TOKEN! + +new Promise((resolve, reject) => { + rl.question('NoteID: ', id => { + const client: MegalodonInterface = generator('firefish', BASE_URL, access_token) + + client + .getStatus(id) + .then(res => { + console.log(res.data) + resolve(res) + }) + .catch(err => { + console.error(err) + reject(err) + }) + }) +}) diff --git a/example/typescript/src/firefish/note.ts b/example/typescript/src/firefish/note.ts deleted file mode 100644 index 3b5a4d067..000000000 --- a/example/typescript/src/firefish/note.ts +++ /dev/null @@ -1,11 +0,0 @@ -import generator, { MegalodonInterface } from 'megalodon' - -const BASE_URL: string = process.env.FIREFISH_URL! -const access_token: string = process.env.FIREFISH_ACCESS_TOKEN! - -const client: MegalodonInterface = generator('firefish', BASE_URL, access_token) - -client - .getStatus('9jwo0f2unacowj1e') - .then(res => console.log(res.data)) - .catch(err => console.error(err)) diff --git a/example/typescript/src/firefish/toot.ts b/example/typescript/src/firefish/post_note.ts similarity index 100% rename from example/typescript/src/firefish/toot.ts rename to example/typescript/src/firefish/post_note.ts diff --git a/example/typescript/src/mastodon/get_status.ts b/example/typescript/src/mastodon/get_status.ts new file mode 100644 index 000000000..c5a96591b --- /dev/null +++ b/example/typescript/src/mastodon/get_status.ts @@ -0,0 +1,21 @@ +import * as readline from 'readline' +import generator from 'megalodon' + +const rl: readline.ReadLine = readline.createInterface({ + input: process.stdin, + output: process.stdout +}) + +const BASE_URL: string = process.env.MASTODON_URL! +const access_token: string = process.env.MASTODON_ACCESS_TOKEN! + +new Promise(resolve => { + rl.question('StatusID: ', id => { + const client = generator('mastodon', BASE_URL, access_token) + client.getStatus(id).then(res => { + console.log(res.data) + rl.close() + resolve(res) + }) + }) +}) diff --git a/example/typescript/src/mastodon/status.ts b/example/typescript/src/mastodon/status.ts deleted file mode 100644 index ba5a964a6..000000000 --- a/example/typescript/src/mastodon/status.ts +++ /dev/null @@ -1,16 +0,0 @@ -import generator from 'megalodon' - -declare var process: { - env: { - MASTODON_ACCESS_TOKEN: string - } -} - -const BASE_URL: string = 'https://fedibird.com' - -const access_token: string = process.env.MASTODON_ACCESS_TOKEN - -const client = generator('mastodon', BASE_URL, access_token) -client.getStatus('104120282397597514').then(res => { - console.log(res.data) -}) diff --git a/example/typescript/src/pleroma/get_status.ts b/example/typescript/src/pleroma/get_status.ts new file mode 100644 index 000000000..368f003a5 --- /dev/null +++ b/example/typescript/src/pleroma/get_status.ts @@ -0,0 +1,22 @@ +import * as readline from 'readline' +import generator from 'megalodon' + +const rl: readline.ReadLine = readline.createInterface({ + input: process.stdin, + output: process.stdout +}) + +const BASE_URL: string = process.env.PLEROMA_URL! + +const access_token: string = process.env.PLEROMA_ACCESS_TOKEN! + +new Promise(resolve => { + rl.question('StatusID: ', id => { + const client = generator('pleroma', BASE_URL, access_token) + client.getStatus(id).then(res => { + console.log(res.data) + rl.close() + resolve(res) + }) + }) +})