Skip to content

Commit

Permalink
fix: Validation base on file size to avoid website error
Browse files Browse the repository at this point in the history
  • Loading branch information
LucsT committed Apr 22, 2024
1 parent fe78da3 commit 96aeeac
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const {
const requestJSON = requestFactory({
cheerio: false,
json: true,
debug: true,
debug: false,
jar: true,
headers: {
'Accept-Language': 'fr' // Mandatory to have pdf in French
Expand Down Expand Up @@ -56,10 +56,20 @@ async function start(fields) {
contentType: 'application/pdf',
fileIdAttributes: ['vendorRef'],
identifiers: [VENDOR],
validateFile: true
validateFile,
retry: 2
})
}

function validateFile(doc) {
const size = doc.size
if (size < 900) {
log('warn', 'BAD_FILE_SIZE')
return false
}
return true
}

async function authenticate(username, password, offerClientKey) {
// Requesting a Oauth token for GrandLyon offer
const clientTokenReq = await requestJSON({
Expand Down

0 comments on commit 96aeeac

Please sign in to comment.