Skip to content

Commit

Permalink
Release 1.7.8
Browse files Browse the repository at this point in the history
Release 1.7.8
  • Loading branch information
benoitdemaegdt authored Jan 11, 2020
2 parents 5fb16cb + d3dca60 commit 98a4d02
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 185 deletions.
415 changes: 247 additions & 168 deletions client/package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maxplorateur-client",
"version": "1.7.7",
"version": "1.7.8",
"private": true,
"scripts": {
"serve": "node_modules/.bin/vue-cli-service serve",
Expand All @@ -11,7 +11,7 @@
},
"dependencies": {
"axios": "^0.19.0",
"core-js": "^3.6.0",
"core-js": "^3.6.1",
"register-service-worker": "^1.6.2",
"vue": "^2.6.11",
"vue-router": "^3.1.3",
Expand All @@ -20,18 +20,18 @@
},
"devDependencies": {
"@mdi/font": "^4.7.95",
"@vue/cli-plugin-babel": "^4.1.1",
"@vue/cli-plugin-eslint": "^4.1.1",
"@vue/cli-plugin-pwa": "^4.1.1",
"@vue/cli-service": "^4.1.1",
"@vue/cli-plugin-babel": "^4.1.2",
"@vue/cli-plugin-eslint": "^4.1.2",
"@vue/cli-plugin-pwa": "^4.1.2",
"@vue/cli-service": "^4.1.2",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/test-utils": "^1.0.0-beta.30",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"eslint": "^6.8.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-vue": "^6.0.1",
"eslint-plugin-vue": "^6.1.1",
"jest": "^24.9.0",
"prettier": "^1.19.1",
"sass": "^1.24.0",
Expand Down
8 changes: 4 additions & 4 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maxplorateur-server",
"version": "1.7.7",
"version": "1.7.8",
"description": "find a tgvmax seat",
"scripts": {
"clean": "rm -fR ./node_modules ./.nyc_output ./coverage ./dist",
Expand Down Expand Up @@ -59,7 +59,7 @@
"@types/lodash": "^4.14.149",
"@types/mocha": "^5.2.7",
"@types/moment-timezone": "^0.5.12",
"@types/mongodb": "^3.3.13",
"@types/mongodb": "^3.3.14",
"@types/nock": "^11.1.0",
"@types/node": "^13.1.1",
"@types/node-cron": "^2.0.2",
Expand Down
6 changes: 6 additions & 0 deletions server/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ export class Config {
*/
public disableCronCheck: boolean;

/**
* disable trainline calls
*/
public disableTrainline: number;

constructor() {
/* tslint:disable */
this.baseSncfWebUrl = 'https://www.oui.sncf';
Expand All @@ -106,6 +111,7 @@ export class Config {
this.disableCronCheck = isNil(process.env.DISABLE_CRON_CHECK)
? config.get('disableCronCheck')
: process.env.DISABLE_CRON_CHECK === 'true';
this.disableTrainline = 2;
}

private getWhitelist = (): string => {
Expand Down
2 changes: 1 addition & 1 deletion server/src/core/CronChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CronChecks {
/**
* split load on trainline and sncf mobile APIs
*/
if (random(0, 1) === 0) {
if (random(0, 1) === Config.disableTrainline) {
console.log(`${moment(new Date()).tz('Europe/Paris').format('DD-MM-YYYY HH:mm:ss')} - processing travelAlert ${travelAlert._id} - trainline API`); // tslint:disable-line
const trainline: Trainline = new Trainline(
travelAlert.origin.trainlineId,
Expand Down
26 changes: 23 additions & 3 deletions server/src/core/SncfMobile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
import * as httpsProxyAgent from 'https-proxy-agent';
import { filter, isEmpty, isNil, map, random, uniq } from 'lodash';
import { filter, get, isEmpty, isNil, map, random, uniq } from 'lodash';
import * as moment from 'moment-timezone';
import Config from '../Config';
import { IAvailability, ISncfMobileTrain } from '../types';
Expand Down Expand Up @@ -79,7 +79,7 @@ export class SncfMobile {
try {
while (keepSearching) {
const config: AxiosRequestConfig = {
url: `${Config.baseSncfMobileUrl}/m680/vmd/maq/v3/proposals/train`,
url: `${Config.baseSncfMobileUrl}/m690/vmd/maq/v3/proposals/train`,
method: 'POST',
headers: {
Accept: 'application/json',
Expand Down Expand Up @@ -129,6 +129,23 @@ export class SncfMobile {
config.httpsAgent = new httpsProxyAgent(Config.proxyUrl);
}

/**
* interceptor for handling sncf 200 ok that should be 500 or 301
*/
Axios.interceptors.response.use(async(res: AxiosResponse) => {
const data: {exceptionType?: string} = res.data as {exceptionType?: string};
if (!isNil(data.exceptionType)) {
return Promise.reject({
response: {
status: 500,
statusText: data.exceptionType,
},
});
}

return res;
});

/**
* get data from oui.sncf
*/
Expand All @@ -150,7 +167,10 @@ export class SncfMobile {
fromTime = pageLastTripDeparture;
}
} catch (error) {
console.log(`SNCF API ERROR : ${error.response.status} ${error.response.statusText} | ${error.response.data.label}`); // tslint:disable-line
const status: number = get(error, 'response.status', ''); // tslint:disable-line
const statusText: string = get(error, 'response.statusText', ''); // tslint:disable-line
const label: string = get(error, 'response.data.label', ''); // tslint:disable-line
console.log(`SNCF API ERROR : ${status} ${statusText} ${label}`); // tslint:disable-line
}

/**
Expand Down

0 comments on commit 98a4d02

Please sign in to comment.