Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import config from '../../../config';
import helpers from '../helpers';
import models from '../../db/models';
import MovieDb from 'moviedb-promise';
import stringSimilarity from 'string-similarity';
const mdb = new MovieDb(config.server.movieApiKey);
const popularTv = async () => {
try {
const response = await mdb.miscPopularTvs();
return response;
} catch (error) {
helpers.handleError(error, 'popularTv');
}
};
const topRatedTv = async () => {
try {
const response = await mdb.miscTopRatedTvs();
return response;
} catch (error) {
helpers.handleError(error, 'miscTopRatedTvs');
import Promise from 'bluebird';
import plexApi from './plexApi';
import models from '../../db/models';
import config from '../../../config';
import MovieDb from 'moviedb-promise';
import logger from '../../../config/winston';
import { Op } from 'sequelize';
const mdb = new MovieDb(config.server.movieApiKey);
const updateOrCreate = async (model, where, newItem) => {
const item = await model.findOne({ where });
if (!item) {
const createItem = await model.create(newItem, {
returning: true,
plain: true,
raw: true,
});
return { createItem, created: true };
} else {
await model.update(
newItem,
{ where: where },
{ returning: true, plain: true, raw: true },
);