Migrating to workers, renaming service

This commit is contained in:
Jonathan Cremin 2017-10-23 17:58:23 +01:00
parent 850584ff36
commit a6cd5f4266
29 changed files with 5542 additions and 611 deletions

View file

@ -4,7 +4,7 @@ import services from '../lib/services';
import render from '../lib/render';
import models from '../models';
const debug = debuglog('match.audio:share');
const debug = debuglog('combinefm:share');
const recentQuery = {
include: [

View file

@ -1,14 +0,0 @@
import { parse } from 'url';
import request from 'superagent';
export default function* (next) {
const url = `http://${this.request.url.substr(8)}`;
const parsed = parse(url);
if (parsed.host.match(/mzstatic\.com/)) {
const proxyResponse = yield request.get(url);
this.set(proxyResponse.headers);
this.body = proxyResponse.body;
} else {
yield next;
}
}

View file

@ -1,9 +1,15 @@
import { parse } from 'url';
import kue from 'kue';
import lookup from '../lib/lookup';
import services from '../lib/services';
import { find, create, findMatchesAsync } from '../lib/share';
const queue = kue.createQueue({
redis: {
host: 'redis',
},
});
export default function* () {
const url = parse(this.request.body.url);
@ -18,7 +24,10 @@ export default function* () {
if (!share) {
share = yield create(music);
findMatchesAsync(share);
const job = queue.create('search', share).save((err) => {
if (!err) console.log(job.id);
});
}
share = share.toJSON();