Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
impr
Browse files Browse the repository at this point in the history
  • Loading branch information
norbornen committed Sep 8, 2019
1 parent 84b5931 commit e7d6eef
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 53 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"ts-node": "^8.3.0",
"tslint": "^5.19.0",
"typegoose": "^5.9.0",
"typescript": "^3.6.2",
"user-agents": "^1.0.372"
"typescript": "^3.6.2"
}
}
7 changes: 2 additions & 5 deletions src/tools/agent.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
import * as qs from 'qs';

// tslint:disable-next-line:no-var-requires
const UserAgentCtor = require('user-agents');
const UserAgent = new UserAgentCtor();
import { randomUserAgent } from './user_agent';

export function createHttpAgent(baseURL?: string, timeout?: number): AxiosInstance {
const config: AxiosRequestConfig = {
headers: {
'User-Agent': UserAgent.random().toString(),
'User-Agent': randomUserAgent(),
'Content-Type': 'application/json',
'Accept': 'application/json, text/plain, */*',
'Accept-Encoding': 'gzip, deflate, br'
Expand Down
15 changes: 7 additions & 8 deletions src/usecases/NotificationUsecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,20 @@ export class NotificationUsecase {
return provider.send(offer);
})
);
const has_fail = notificationResults.reduce((acc, x) => {
const hasFail = notificationResults.reduce((acc, x) => {
let ok = false;
if (x.isFulfilled) {
acc = acc.concat(x.value || false);
ok = x.value;
}
if (x.isRejected || !x.isFulfilled) {
if ('reason' in x && x.reason) {
console.error(x.reason);
}
acc.push(false);
if (x.isRejected && 'reason' in x && x.reason) {
console.error(x.reason);
}
acc.push(ok || false);
return acc;
}, [] as boolean[])
.some((x) => x === false);

if (!has_fail) {
if (!hasFail) {
offer.is_notifications_send = true;
await offer.save();
}
Expand Down
38 changes: 0 additions & 38 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,6 @@ diff@^4.0.1:
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.1.tgz#0c667cb467ebbb5cea7f14f135cc2dba7780a8ff"
integrity sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==

docopt@~0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/docopt/-/docopt-0.6.2.tgz#b28e9e2220da5ec49f7ea5bb24a47787405eeb11"
integrity sha1-so6eIiDaXsSffqW7JKR3h0Be6xE=

dot-json@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/dot-json/-/dot-json-1.1.0.tgz#36dc7d40c00afaef2823b715b94325ba39f1bd89"
integrity sha512-PiQZW9/C8xILPYK2bOye/cbPZrakNEkt28jFb8RlPCwsoMAHYYw9T8JoACxgttHL9Y2AmdqVvibbZJHtLgeqTQ==
dependencies:
docopt "~0.6.2"
underscore-keypath "~0.0.22"

ejs@^2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.7.1.tgz#5b5ab57f718b79d4aca9254457afecd36fa80228"
Expand Down Expand Up @@ -476,11 +463,6 @@ levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"

lodash.clonedeep@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=

lodash@^4.17.11, lodash@^4.17.5:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
Expand Down Expand Up @@ -995,31 +977,11 @@ typescript@^3.6.2:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.2.tgz#105b0f1934119dde543ac8eb71af3a91009efe54"
integrity sha512-lmQ4L+J6mnu3xweP8+rOrUwzmN+MRAj7TgtJtDaXE5PMyX2kCrklhg3rvOsOIfNeAWMQWO2F1GPc1kMD2vLAfw==

underscore-keypath@~0.0.22:
version "0.0.22"
resolved "https://registry.yarnpkg.com/underscore-keypath/-/underscore-keypath-0.0.22.tgz#48a528392bb6efc424be1caa56da4b5faccf264d"
integrity sha1-SKUoOSu278QkvhyqVtpLX6zPJk0=
dependencies:
underscore "*"

underscore@*:
version "1.9.1"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.1.tgz#06dce34a0e68a7babc29b365b8e74b8925203961"
integrity sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==

unpipe@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=

user-agents@^1.0.372:
version "1.0.372"
resolved "https://registry.yarnpkg.com/user-agents/-/user-agents-1.0.372.tgz#698610a963f67678ef8fb336108123bae7b7953e"
integrity sha512-nEekEZF+hqE4fLq9J0GctsnVXqks+MJrs0pOKiChnc+Jh0lzNO3VZ0hfPCaVZjR02cEanlTIFbAD03+DoLtHVA==
dependencies:
dot-json "^1.1.0"
lodash.clonedeep "^4.5.0"

util-deprecate@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
Expand Down

0 comments on commit e7d6eef

Please sign in to comment.