Skip to content

Commit

Permalink
Merge branch 'main' into feat-lbac-1688-securisation-lien-mail-candidat
Browse files Browse the repository at this point in the history
  • Loading branch information
kevbarns authored Dec 14, 2023
2 parents 1481317 + 5922ba2 commit eaaf433
Show file tree
Hide file tree
Showing 30 changed files with 430 additions and 1,079 deletions.
4 changes: 2 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ fileignoreconfig:
checksum: 8cdd1da6c1155f26b417a27e26311d4f00b7d8bd6c21f1f86c1c7cb3f0599e6a
- filename: server/.env.test
checksum: 2534c2dae48c1464b97489263621dcd516a676b28fdbb34e98267a10e00fd839
- filename: server/src/security/accessTokenService.ts
checksum: f05cafd17797362fc9bfb53062af2095ead2cbe2fa967fad23bd61b756052004
- filename: server/src/common/model/schema/_shared/mongoose-paginate.ts
checksum: b6762a7cb5df9bbee1f0ce893827f0991ad01514f7122a848b3b5d49b620f238
- filename: server/src/config.ts
Expand All @@ -41,8 +43,6 @@ fileignoreconfig:
checksum: d716e214d828109181a138f0ae253d5489a3c544b2625917b458d1e07886c408
- filename: server/src/jobs/lba_recruteur/formulaire/misc/removeVersionKeyFromRecruiters.ts
checksum: 3cd111d8c109cfec357bae48af70d0cf5644d02cd2c4b9afc5b8aa07bccbd535
- filename: server/src/security/accessTokenService.ts
checksum: f05cafd17797362fc9bfb53062af2095ead2cbe2fa967fad23bd61b756052004
- filename: server/src/services/application.service.ts
checksum: 935cd8f213565ba7bcc2925fca149aaa6cbe9bb5e393a13ab3525dff6ad17234
- filename: server/tests/integration/http/formationV1.test.ts
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@types/nodemailer-html-to-text": "^3.1.1",
"aws-sdk": "^2.1466.0",
"axios": "^1.5.1",
"axios-cache-interceptor": "^0.10.7",
"axios-cache-interceptor": "^1.3.2",
"basic-ftp": "^5.0.3",
"boom": "^7.3.0",
"bunyan": "^1.8.15",
Expand Down
6 changes: 6 additions & 0 deletions server/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,12 @@ program
.option("-q, --queued", "Run job asynchronously", false)
.action(createJobAction("user-recruters:data-validation:fix"))

program
.command("fix-data-validation-user-recruteurs-cfa")
.description("Répare les data des userrecruteurs CFA")
.option("-q, --queued", "Run job asynchronously", false)
.action(createJobAction("user-recruters-cfa:data-validation:fix"))

program
.command("anonymize-user-recruteurs")
.description("Anonymize les userrecruteurs qui ne se sont pas connectés depuis plus de 2 ans")
Expand Down
13 changes: 7 additions & 6 deletions server/src/common/apis/client.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// import http from "http"
// import https from "https"

import axios, { AxiosRequestConfig } from "axios"
import { setupCache } from "axios-cache-interceptor"
import { buildMemoryStorage, setupCache } from "axios-cache-interceptor"

const CLEANUP_INTERVAL = 1000 * 60 * 10 // 10 minutes
const MAX_ENTRIES = 200
const CLONE_DATA = false

const getApiClient = (options: AxiosRequestConfig, { cache }: { cache: boolean } = { cache: true }) => {
const axiosInstance = axios.create({
timeout: 5000,
// httpAgent: new http.Agent({ keepAlive: true }),
// httpsAgent: new https.Agent({ keepAlive: true }),
...options,
})

return cache
? setupCache(axiosInstance, {
storage: buildMemoryStorage(CLONE_DATA, CLEANUP_INTERVAL, MAX_ENTRIES),
ttl: 1000 * 60 * 10, // 10 Minutes
})
: axiosInstance
Expand Down
77 changes: 0 additions & 77 deletions server/src/common/model/schema/_shared/shared.types.ts

This file was deleted.

32 changes: 0 additions & 32 deletions server/src/common/utils/fileUtils.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,16 @@
import path from "path"

import csvToJson from "convert-csv-to-json"
import { Options as CsvParseOptions, parse } from "csv-parse"
import { isEmpty, pickBy } from "lodash-es"
import XLSX from "xlsx"

import config from "../../config"
import __dirname from "../dirname"

import { FTPClient } from "./ftpUtils"

export const readJsonFromCsvFile = (localPath) => {
return csvToJson.getJsonFromCsv(localPath)
}

export const readXLSXFile = (localPath) => {
const workbook = XLSX.readFile(localPath, { codepage: 65001 })
return { sheet_name_list: workbook.SheetNames, workbook }
}

export const createXLSXFile = (data, localPath) => {
const workbook = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(workbook, XLSX.utils.json_to_sheet(data), "data")

// @ts-expect-error writeFileAsync Cb function is not properly typed
XLSX.writeFileAsync(path.join(localPath), workbook, (e) => {
if (e) {
console.log(e)
throw new Error("La génération du fichier excel à échoué : ", e)
}
})
}

export const convertIntoBuffer = (workbook) => {
return XLSX.write(workbook, { type: "buffer", bookType: "xlsx" })
}

export const removeLine = (data, regex) => {
return data
.split("\n")
.filter((val) => !regex.test(val))
.join("\n")
}

export const prepareMessageForMail = (data) => {
const result = data ? data.replace(/(<([^>]+)>)/gi, "") : data
return result ? result.replace(/\r\n|\r|\n/gi, "<br />") : result
Expand Down
4 changes: 2 additions & 2 deletions server/src/http/middlewares/authMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import {
import { IRouteSchema, SecurityScheme, WithSecurityScheme } from "shared/routes/common.routes"

import { authenticationMiddleware } from "@/security/authenticationService"
import { authorizationnMiddleware } from "@/security/authorisationService"
import { authorizationMiddleware } from "@/security/authorisationService"

const symbol = Symbol("authStrategy")

export function auth<S extends IRouteSchema & WithSecurityScheme>(schema: S) {
const authMiddleware = async (req: FastifyRequest) => {
await authenticationMiddleware(schema, req)
await authorizationnMiddleware(schema, req)
await authorizationMiddleware(schema, req)
}

authMiddleware[symbol] = schema.securityScheme
Expand Down
151 changes: 0 additions & 151 deletions server/src/jobs/campaign/generateCsvForCampaign.ts

This file was deleted.

Loading

0 comments on commit eaaf433

Please sign in to comment.