Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// this is split out so that the auth controller can follow featured podcasts at user creation
import Follow from '../models/follow';
import config from '../config';
import stream from 'getstream';
const client = stream.connect(config.stream.apiKey, config.stream.apiSecret);
const followPodcast = (userID, podcastID) => {
// couple things:
// find follow relationship already in DB - if it exists, return it, don't send a 409
// if not, create a new one, and:
// timeline follows podcast
// user_episode follows podcast
let obj = {
podcast: podcastID,
user: userID,
};
return Follow.findOne(obj).then(existingFollow => {
if (existingFollow) {
// serialize podcast and user ids
existingFollow.podcast = existingFollow.podcast._id;
existingFollow.user = existingFollow.user._id;
import '../loadenv';
import '../utils/db';
import program from 'commander';
import logger from '../utils/logger';
import Follow from '../models/follow';
import { FollowSchema } from '../models/follow';
import asyncTasks from '../asyncTasks';
import stream from 'getstream';
import config from '../config';
const streamClient = stream.connect(config.stream.apiKey, config.stream.apiSecret);
program.parse(process.argv);
async function main() {
logger.info(`time to resync those follows, \\0/`);
let followCount = await Follow.count({});
let chunkSize = 500;
for (let i = 0, j = followCount; i < j; i += chunkSize) {
let follows = await Follow.find({})
.skip(i)
.limit(chunkSize)
.lean();
logger.info(`found ${follows.length} follows`);
let feedRelations = [];
import stream from 'getstream';
import Share from '../models/share';
import config from '../config';
import logger from '../utils/logger';
const client = stream.connect(
config.stream.apiKey,
config.stream.apiSecret,
);
exports.list = (req, res) => {
const page = parseInt(req.query.page, 10) || 0;
const perPage = parseInt(req.query.per_page, 10) || 10;
Share.find({ flags: { $lte: 5 } })
.skip(perPage * page)
.limit(perPage)
.then(shares => {
res.json(shares);
})
.catch(err => {
logger.error(err);
export function getStreamClient() {
let client = stream.connect(
process.env.API_KEY,
process.env.API_SECRET,
process.env.APP_ID,
)
return client
}
constructor(props: StreamAppProps) {
super(props);
const client: StreamClient = stream.connect(
this.props.apiKey,
this.props.token,
this.props.appId,
this.props.options || {},
);
let analyticsClient;
if (this.props.analyticsToken) {
analyticsClient = new StreamAnalytics({
apiKey: this.props.apiKey,
token: this.props.analyticsToken,
});
analyticsClient.setUser(client.userId);
}
this.state = {
client,
import 'source-map-support/register'
import { getUserId } from '../../infrastructure/authentication/getUserId'
import stream from 'getstream'
import md5 from 'md5'
import { userApi } from '../../infrastructure/databases/users/userApi'
import {
makeErrorResponse,
makeSuccessResponse
} from '../../infrastructure/http/makeResponse'
const getStreamClient = stream.connect(
process.env.GETSTREAM_KEY,
process.env.GETSTREAM_SECRET,
process.env.GETSTREAM_APPID
)
let userIdUsernameCache = {}
async function getUsername(userId) {
if (!userId) {
return ''
} else if (userIdUsernameCache[userId]) {
return userIdUsernameCache[userId]
} else {
userIdUsernameCache = await userApi.listAllUsers()
return userIdUsernameCache[userId]
}
export function getStreamClient() {
if (streamClient === null) {
streamClient = stream.connect(config.stream.apiKey, config.stream.apiSecret);
}
return streamClient;
}
constructor(props: StreamAppProps) {
super(props);
let client: StreamClient = stream.connect(
this.props.apiKey,
this.props.token,
this.props.appId,
this.props.options || {},
);
let analyticsClient;
if (this.props.analyticsToken) {
analyticsClient = new StreamAnalytics({
apiKey: this.props.apiKey,
token: this.props.analyticsToken,
});
analyticsClient.setUser(client.userId);
}
this.state = {
export function getStreamClient() {
let client = stream.connect(
SETTINGS.stream.key,
SETTINGS.stream.secret,
SETTINGS.stream.app_id,
)
return client
}