Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { Client } = require('tdl')
const Future = require('fluture')
const client = new Client({
apiId: 2222, // Your api_id
apiHash: 'YOUR_API_HASH'
})
const searchChat = username =>
client.invokeFuture({ _: 'searchPublicChat', username })
.map(chat => `Chat: ${chat.title}, id: ${chat.id}`)
.mapRej(err => `Error: ${err.message}`)
const login = Future.encaseP(client.login)
Future
.tryP(client.connect)
.chain(() => login(() => ({
phoneNumber: 'YOUR_PHONE_NUMBER'
})))
.chain(() => searchChat('username'))
.fork(console.error, console.log)
const insert = (values: Payload) => {
const query = generatePgInsert({ payload: values, table: tableName })
return (
Future.tryP(() => client.query(query.text, query.values))
.map(debug ? R.tap(console.log) : R.identity)
// @ts-ignore
.map(value => new entityMapperClass(value.rows[0]))
)
}
const find = (payload: Payload) => {
const clause = getWhereClauseFromObject({ payload })
return (
Future.tryP(() =>
client.query(`select * from ${tableName} ${clause.length !== 0 ? `where ${clause}` : ''}`),
)
.map(value => value.rows)
// @ts-ignore
.map(R.map(data => new entityMapperClass(data)))
)
}
const requestRaw = (query: string): FutureInstance => {
// @ts-ignore
return Future.tryP(() => client.query(query)).pipe(mapResults)
}
function fetchSlides() {
const url = 'http://beta.json-generator.com/api/json/get/VJihcRLIQ'
return tryP(async function() {
const res = await fetch(url)
return res.json()
})
}