Remove javascript example
This commit is contained in:
parent
f92d837c7d
commit
5ff324bead
|
@ -10,5 +10,4 @@ script:
|
|||
- yarn run build
|
||||
- yarn run test
|
||||
- cd example/browser && yarn install && yarn build
|
||||
- cd ../../example/javascript && yarn install && yarn build
|
||||
- cd ../../example/typescript && yarn install && yarn build
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"presets": [
|
||||
"@babel/preset-env"
|
||||
]
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
import readline from 'readline'
|
||||
import { Mastodon } from 'megalodon'
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
})
|
||||
|
||||
const SCOPES = ['read', 'write', 'follow']
|
||||
const BASE_URL = 'https://mastodon.social'
|
||||
|
||||
let clientId
|
||||
let clientSecret
|
||||
|
||||
const client = new Mastodon(BASE_URL)
|
||||
|
||||
client
|
||||
.registerApp('Test App', {
|
||||
scopes: SCOPES
|
||||
})
|
||||
.then(appData => {
|
||||
clientId = appData.clientId
|
||||
clientSecret = appData.clientSecret
|
||||
console.log('\nclient_id:')
|
||||
console.log(clientId)
|
||||
console.log('\nclient_secret:')
|
||||
console.log(clientSecret)
|
||||
console.log('\nAuthorization URL is generated.')
|
||||
console.log(appData.url)
|
||||
console.log()
|
||||
return new Promise(resolve => {
|
||||
rl.question('Enter the authorization code from website: ', code => {
|
||||
resolve(code)
|
||||
rl.close()
|
||||
})
|
||||
})
|
||||
})
|
||||
.then(code => Mastodon.fetchAccessToken(clientId, clientSecret, code, BASE_URL))
|
||||
.then(tokenData => {
|
||||
console.log('\naccess_token:')
|
||||
console.log(tokenData.accessToken)
|
||||
console.log('\nrefresh_token:')
|
||||
console.log(tokenData.refreshToken)
|
||||
console.log()
|
||||
})
|
||||
.catch(err => console.error(err))
|
|
@ -1,12 +0,0 @@
|
|||
import { Mastodon } from 'megalodon'
|
||||
|
||||
const BASE_URL = 'https://mastodon.social'
|
||||
|
||||
const access_token = process.env.MASTODON_ACCESS_TOKEN
|
||||
|
||||
const client = new Mastodon(BASE_URL, access_token)
|
||||
|
||||
client.getFavourites().then(res => {
|
||||
console.log(res.headers)
|
||||
console.log(res.data)
|
||||
})
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"name": "example",
|
||||
"author": "h3poteto",
|
||||
"scripts": {
|
||||
"build": "babel -d ./dist . -s --ignore 'node_modules/**/*.js' --ignore 'dist/*'"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/cli": "^7.8.4",
|
||||
"@babel/core": "^7.8.4",
|
||||
"@babel/preset-env": "^7.8.4",
|
||||
"megalodon": "file:../../"
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
// Please use this function after authorization.js
|
||||
// Now mastodon and pleroma don't have refersh token method.
|
||||
// So this example is failed.
|
||||
import { Mastodon } from 'megalodon'
|
||||
|
||||
const BASE_URL = 'https://pleroma.io'
|
||||
|
||||
const clientId = ''
|
||||
const clientSecret = ''
|
||||
const refreshToken = ''
|
||||
|
||||
const client = new Mastodon(BASE_URL)
|
||||
|
||||
client
|
||||
.refreshToken(clientId, clientSecret, refreshToken)
|
||||
.then(tokenData => {
|
||||
console.log('\naccess_token:')
|
||||
console.log(tokenData.accessToken)
|
||||
console.log('\nrefresh_token:')
|
||||
console.log(tokenData.refreshToken)
|
||||
console.log()
|
||||
})
|
||||
.catch(err => console.error(err))
|
|
@ -1,40 +0,0 @@
|
|||
import { Mastodon } from 'megalodon'
|
||||
|
||||
const BASE_URL = 'https://mastodon.social'
|
||||
|
||||
const access_token = process.env.MASTODON_ACCESS_TOKEN
|
||||
|
||||
const client = new Mastodon(BASE_URL, access_token)
|
||||
|
||||
const stream = client.publicStream()
|
||||
stream.on('connect', _ => {
|
||||
console.log('connect')
|
||||
})
|
||||
|
||||
stream.on('not-event-stream', mes => {
|
||||
console.log(mes)
|
||||
})
|
||||
|
||||
stream.on('update', status => {
|
||||
console.log(status)
|
||||
})
|
||||
|
||||
stream.on('notification', notification => {
|
||||
console.log(notification)
|
||||
})
|
||||
|
||||
stream.on('delete', id => {
|
||||
console.log(`delete: ${id}`)
|
||||
})
|
||||
|
||||
stream.on('error', err => {
|
||||
console.error(err)
|
||||
})
|
||||
|
||||
stream.on('heartbeat', msg => {
|
||||
console.log('thump.')
|
||||
})
|
||||
|
||||
stream.on('connection-limit-exceeded', err => {
|
||||
console.error(err)
|
||||
})
|
|
@ -1,9 +0,0 @@
|
|||
import { Mastodon } from 'megalodon'
|
||||
|
||||
const BASE_URL = 'https://mastodon.social'
|
||||
|
||||
const access_token = process.env.MASTODON_ACCESS_TOKEN
|
||||
|
||||
const client = new Mastodon(BASE_URL, access_token)
|
||||
|
||||
client.getHomeTimeline().then(res => console.log(res.data))
|
|
@ -1,27 +0,0 @@
|
|||
import readline from 'readline'
|
||||
import { Mastodon } from 'megalodon'
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
})
|
||||
|
||||
const BASE_URL = 'https://mastodon.social'
|
||||
|
||||
const access_token = process.env.MASTODON_ACCESS_TOKEN
|
||||
|
||||
const client = new Mastodon(BASE_URL, access_token)
|
||||
new Promise(resolve => {
|
||||
rl.question('Toot: ', status => {
|
||||
client
|
||||
.postStatus(status)
|
||||
.then(res => {
|
||||
console.log(res)
|
||||
rl.close()
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
rl.close()
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,40 +0,0 @@
|
|||
import { Mastodon } from 'megalodon'
|
||||
|
||||
const BASE_URL = 'wss://pleroma.io'
|
||||
|
||||
const access_token = process.env.PLEROMA_ACCESS_TOKEN
|
||||
|
||||
const client = new Mastodon(BASE_URL, access_token)
|
||||
|
||||
const stream = client.userSocket()
|
||||
stream.on('connect', event => {
|
||||
console.log('connect')
|
||||
})
|
||||
|
||||
stream.on('update', status => {
|
||||
console.log(status)
|
||||
})
|
||||
|
||||
stream.on('notification', notification => {
|
||||
console.log(notification)
|
||||
})
|
||||
|
||||
stream.on('delete', id => {
|
||||
console.log(`delete: ${id}`)
|
||||
})
|
||||
|
||||
stream.on('error', err => {
|
||||
console.error(err)
|
||||
})
|
||||
|
||||
stream.on('heartbeat', msg => {
|
||||
console.log('thump.')
|
||||
})
|
||||
|
||||
stream.on('close', () => {
|
||||
console.log('close')
|
||||
})
|
||||
|
||||
stream.on('parser-error', err => {
|
||||
console.error(err)
|
||||
})
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue