fix errors for discogs and use env settings in mcrates compose
This commit is contained in:
1 parent
2ffb5f9bc3
commit
ac0a31511d
4 files changed
+17
-9
No files matched your search
+3
-3
@@ -42,7 +42,6 @@ export default function createDiscogs(log: Log, pg: Pg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onError(error) {
|
function onError(error) {
|
||||||
console.error(error);
|
|
||||||
if (error.response.status === 429) {
|
if (error.response.status === 429) {
|
||||||
return [new Error('rate limited, try again in 1 minute'), null];
|
return [new Error('rate limited, try again in 1 minute'), null];
|
||||||
}
|
}
|
||||||
@@ -54,7 +53,6 @@ export default function createDiscogs(log: Log, pg: Pg) {
|
|||||||
|
|
||||||
async function wantListSync(username: string, user: User): Promise<Want[]> {
|
async function wantListSync(username: string, user: User): Promise<Want[]> {
|
||||||
const [err, res] = await api.get(`${apiBase}/users/${username}/wants`);
|
const [err, res] = await api.get(`${apiBase}/users/${username}/wants`);
|
||||||
log.warn(err, res);
|
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
const { wants, pagination } = res;
|
const { wants, pagination } = res;
|
||||||
|
|
||||||
@@ -75,7 +73,8 @@ export default function createDiscogs(log: Log, pg: Pg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function release(id: DiscogsRelease): Promise<any> {
|
async function release(id: DiscogsRelease): Promise<any> {
|
||||||
const [error, data] = await api.get(`${apiBase}/releases/${id}`);
|
const [err, data] = await api.get(`${apiBase}/releases/${id}`);
|
||||||
|
if (err) throw err;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +120,7 @@ export default function createDiscogs(log: Log, pg: Pg) {
|
|||||||
|
|
||||||
log.debug('fetching listing', id);
|
log.debug('fetching listing', id);
|
||||||
const [err, discogsListing] = await api.get(`${apiBase}/marketplace/listings/${id}`);
|
const [err, discogsListing] = await api.get(`${apiBase}/marketplace/listings/${id}`);
|
||||||
|
if (err) throw err;
|
||||||
log.debug(discogsListing);
|
log.debug(discogsListing);
|
||||||
return pg.listingUpsert(discogsListing, want);
|
return pg.listingUpsert(discogsListing, want);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -27,7 +27,8 @@ export default function createEvents(log: Log, pg: Pg, discogs, offers) {
|
|||||||
log.error('event error', e);
|
log.error('event error', e);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function populateListings(want: Want) {
|
const MAX_ATTEMPTS = 2;
|
||||||
|
async function populateListings(want: Want, attempts = 0) {
|
||||||
try {
|
try {
|
||||||
const listings = await discogs.listings(want);
|
const listings = await discogs.listings(want);
|
||||||
await pg.wantSynced(want);
|
await pg.wantSynced(want);
|
||||||
@@ -36,7 +37,10 @@ export default function createEvents(log: Log, pg: Pg, discogs, offers) {
|
|||||||
if (e.message.includes('rate limited')) {
|
if (e.message.includes('rate limited')) {
|
||||||
log.warn('rate limited, trying again in 60s');
|
log.warn('rate limited, trying again in 60s');
|
||||||
await setTimeout(60 * 1000);
|
await setTimeout(60 * 1000);
|
||||||
return populateListings(want);
|
if (attempts > MAX_ATTEMPTS) {
|
||||||
|
log.error(wantDetails(want), 'failed to populate listings')
|
||||||
|
}
|
||||||
|
return populateListings(want, attempts++);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ body {
|
|||||||
.info {
|
.info {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"words swirl"
|
"words swirl"
|
||||||
"words contact";
|
"words contact";
|
||||||
@@ -65,10 +67,12 @@ body {
|
|||||||
.contact {
|
.contact {
|
||||||
grid-area: contact;
|
grid-area: contact;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.words {
|
.words {
|
||||||
grid-area: words;
|
grid-area: words;
|
||||||
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.swirl {
|
.swirl {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ services:
|
|||||||
pg:
|
pg:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: 'mcrates'
|
POSTGRES_USER: '${POSTGRES_USER}'
|
||||||
POSTGRES_DB: 'mcrates'
|
POSTGRES_DB: '${POSTGRES_DB}'
|
||||||
POSTGRES_PASSWORD: 'digdeep'
|
POSTGRES_PASSWORD: '${POSTGRES_PASSWORD}'
|
||||||
|
|
||||||
# allow prisma client to push changes from outside docker etc
|
# allow prisma client to push changes from outside docker etc
|
||||||
# ufw blocks this from being publicly accessible
|
# ufw blocks this from being publicly accessible
|
||||||
@@ -20,7 +20,7 @@ services:
|
|||||||
working_dir: /opt/mcrates/api
|
working_dir: /opt/mcrates/api
|
||||||
entrypoint: npm start
|
entrypoint: npm start
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: 'postgresql://mcrates:digdeep@pg:5432/mcrates?schema=public'
|
DATABASE_URL: 'postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@pg:5432/${POSTGRES_DB}?schema=public'
|
||||||
volumes:
|
volumes:
|
||||||
- "./api:/opt/mcrates/api"
|
- "./api:/opt/mcrates/api"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user