-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
11 changed files
with
233 additions
and
141 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 |
---|---|---|
@@ -1,10 +1,49 @@ | ||
import generator, { Entity, Response } from 'megalodon' | ||
import generator from 'megalodon' | ||
|
||
const BASE_URL: string = 'https://mastodon.social' | ||
const BASE_URL: string = process.env.MASTODON_URL! | ||
const ACCESS_TOKEN: string = process.env.MASTODON_ACCESS_TOKEN! | ||
console.log(BASE_URL) | ||
console.log('start') | ||
|
||
const client = generator('mastodon', BASE_URL) | ||
const client = generator('mastodon', BASE_URL, ACCESS_TOKEN) | ||
|
||
client.getInstance().then((res: Response<Entity.Instance>) => { | ||
console.log(res) | ||
const stream = client.localSocket() | ||
stream.on('connect', () => { | ||
console.log('connect') | ||
}) | ||
|
||
stream.on('pong', () => { | ||
console.log('pong') | ||
}) | ||
|
||
stream.on('update', (status: Entity.Status) => { | ||
console.log(status) | ||
}) | ||
|
||
stream.on('notification', (notification: Entity.Notification) => { | ||
console.log(notification) | ||
}) | ||
|
||
stream.on('delete', (id: number) => { | ||
console.log(id) | ||
}) | ||
|
||
stream.on('error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
|
||
stream.on('status_update', (status: Entity.Status) => { | ||
console.log('updated: ', status.url) | ||
}) | ||
|
||
stream.on('heartbeat', () => { | ||
console.log('thump.') | ||
}) | ||
|
||
stream.on('close', () => { | ||
console.log('close') | ||
}) | ||
|
||
stream.on('parser-error', (err: Error) => { | ||
console.error(err) | ||
}) |
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
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 |
---|---|---|
@@ -1,3 +1,11 @@ | ||
export const NO_REDIRECT = 'urn:ietf:wg:oauth:2.0:oob' | ||
export const DEFAULT_SCOPE = ['read', 'write', 'follow'] | ||
export const DEFAULT_UA = 'megalodon' | ||
|
||
export function isBrowser() { | ||
if (typeof window !== 'undefined') { | ||
return true | ||
} else { | ||
return false | ||
} | ||
} |
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
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.