Skip to content

Commit

Permalink
Merge branch 'infra/refactor' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
moroine committed Oct 3, 2023
2 parents e52a617 + 0c405bb commit dd973fe
Show file tree
Hide file tree
Showing 32 changed files with 79 additions and 208 deletions.
2 changes: 1 addition & 1 deletion .bin/scripts/release-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ fi
readonly next_version="${1}"
readonly mode=${2:-$defaultMode}

"$ROOT_DIR/.bin/scripts/build-images.sh" $next_version $mode next
"$ROOT_DIR/.bin/scripts/build-images.sh" $next_version $mode production recette
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
name: Deploy ${{ needs.release.outputs.VERSION }} on recette
uses: "./.github/workflows/_deploy.yml"
with:
environment: next
environment: recette
app_version: ${{ needs.release.outputs.VERSION }}
secrets:
DEPLOY_SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# yarn lint-staged
yarn lint-staged
./.husky/preventSensibleFilesCommit.sh
yarn node-talisman --githook pre-commit
2 changes: 1 addition & 1 deletion .infra/ansible/tasks/files_copy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
dest: "/opt/app/docker-compose.recette.yml"
with_fileglob:
- "{{inventory_dir}}/docker-compose.recette.yml"
when: env_type == 'recette' or env_type == 'next'
when: env_type == 'recette'

- name: creation du fichier docker compose preview system
ansible.builtin.template:
Expand Down
23 changes: 4 additions & 19 deletions .infra/env.ini
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
[all:vars]
app_version=1.88.5-beta.12
app_version=latest

[production]
217.182.170.149
149.202.54.205
[production:vars]
dns_name=labonnealternance.apprentissage.beta.gouv.fr
dns_name=labonnealternance-develop.apprentissage.beta.gouv.fr
host_name=lba-production
env_type=production

[recette]
146.59.199.41
51.75.246.6
[recette:vars]
dns_name=labonnealternance-recette.apprentissage.beta.gouv.fr
host_name=lba-recette
env_type=recette

[develop]
149.202.54.205
[develop:vars]
dns_name=labonnealternance-develop.apprentissage.beta.gouv.fr
host_name=lba-develop
env_type=develop


[next]
51.75.246.6
[next:vars]
dns_name=labonnealternance-next.apprentissage.beta.gouv.fr
host_name=lba-next
env_type=next

[preview]
;
[preview:vars]
Expand Down
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fileignoreconfig:
- filename: .infra/.env_server
checksum: 618e1aad8e37a060c78ddca285899ae61cd2a6c584895a3c4dfd54f392ed6112
- filename: .infra/env.ini
checksum: 24332dcab809201ac286e4225a1d861307c291dc4a5e2308b996da2d3547a41c
checksum: 46009eb5ccdcc992bfcc93feb40bb6e5dbaad5b57bec5a47ed4122a7ebbd243f
- filename: .infra/files/configs/mongodb/seed.gpg
checksum: 7141d3836a9746d58ca3331b6ce2911a3b260131d47af6e402d39962c411eac8
- filename: .infra/vault/vault.yml
Expand Down
5 changes: 1 addition & 4 deletions docker-bake.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"recette": {
"targets": ["server", "ui-recette"]
},
"next": {
"targets": ["server", "ui-next"]
},
"preview": {
"targets": ["server", "ui-preview"]
},
Expand Down Expand Up @@ -46,7 +43,7 @@
"ui": {
"inherits": ["common"],
"matrix": {
"ENV": ["production", "recette", "preview", "local", "next"]
"ENV": ["production", "recette", "preview", "local"]
},
"name": "ui-${ENV}",
"args": {
Expand Down
2 changes: 1 addition & 1 deletion server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config = {
appName: "lba",
version: env.get("PUBLIC_VERSION").required().asString(),
port: env.get("LBA_SERVER_PORT").required().asPortNumber(),
env: env.get("LBA_ENV").required().asEnum(["local", "recette", "production", "preview", "next"]),
env: env.get("LBA_ENV").required().asEnum(["local", "recette", "production", "preview"]),
publicUrl: env.get("LBA_PUBLIC_URL").required().asString(),
outputDir: env.get("LBA_OUTPUT_DIR").required().asString(),
formationsEndPoint: "/api/v1/entity/formations",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import config from "../../../config"
import * as eligibleTrainingsForAppointmentService from "../../../services/eligibleTrainingsForAppointment.service"
import { Server } from "../../server"

import { contextCreateSchema } from "./validators"

export default (server: Server) => {
server.post(
"/appointment-request/context/create",
Expand All @@ -19,9 +17,6 @@ export default (server: Server) => {
// TODO: AttachValidation Error ?
},
async (req, res) => {
// TODO: remove this validate ?
await contextCreateSchema.validateAsync(req.body, { abortEarly: false })

const { referrer } = req.body

const referrerObj = getReferrerByKeyName(referrer)
Expand Down
79 changes: 0 additions & 79 deletions server/src/http/controllers/appointments/validators.ts

This file was deleted.

2 changes: 1 addition & 1 deletion server/src/http/routes/admin/etablissement.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default (server: Server) => {
throw Boom.notFound()
}

const result = await Etablissement.findByIdAndUpdate(params.id, body)
const result = await Etablissement.findByIdAndUpdate(params.id, body).lean()

if (!result) {
throw Boom.notFound()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default (server: Server) => {
newCfa = await setUserHasToBeManuallyValidated(newCfa._id)
await notifyToSlack({
subject: "RECRUTEUR",
message: `Nouvel OF en attente de validation - ${newCfa.email} - https://referentiel.apprentissage.beta.gouv.fr/organismes/${newCfa.establishment_siret}`,
message: `Nouvel OF en attente de validation - https://referentiel.apprentissage.beta.gouv.fr/organismes/${newCfa.establishment_siret}`,
})
return res.status(200).send({ user: newCfa })
}
Expand Down
16 changes: 8 additions & 8 deletions server/src/services/etablissement.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,60 +125,60 @@ export const findById = async (id): Promise<IEtablissement> => {
* @param {Object} conditions
* @returns {Promise<Etablissement[]>}
*/
export const find = async (conditions): Promise<IEtablissement[]> => Etablissement.find(conditions)
export const find = async (conditions): Promise<IEtablissement[]> => Etablissement.find(conditions).lean()

/**
* @description Returns one item.
* @param {Object} conditions
* @returns {Promise<Etablissement>}
*/
export const findOne = async (conditions): Promise<IEtablissement | null> => Etablissement.findOne(conditions)
export const findOne = async (conditions): Promise<IEtablissement | null> => Etablissement.findOne(conditions).lean()

/**
* @description Updates an etablissement from its conditions.
* @param {Object} conditions
* @param {Object} values
* @returns {Promise<Etablissement>}
*/
export const findOneAndUpdate = async (conditions, values): Promise<IEtablissement | null> => Etablissement.findOneAndUpdate(conditions, values, { new: true })
export const findOneAndUpdate = async (conditions, values): Promise<IEtablissement | null> => Etablissement.findOneAndUpdate(conditions, values, { new: true }).lean()

/**
* @description Upserts.
* @param {Object} conditions
* @param {Object} values
* @returns {Promise<Etablissement>}
*/
export const updateMany = async (conditions, values): Promise<any> => Etablissement.updateMany(conditions, values, { new: true, upsert: true })
export const updateMany = async (conditions, values): Promise<any> => Etablissement.updateMany(conditions, values, { new: true, upsert: true }).lean()

/**
* @description Update one.
* @param {Object} conditions
* @param {Object} values
* @returns {Promise<Etablissement>}
*/
export const updateOne = async (conditions, values): Promise<any> => Etablissement.updateOne(conditions, values, { new: true, upsert: true })
export const updateOne = async (conditions, values): Promise<any> => Etablissement.updateOne(conditions, values, { new: true, upsert: true }).lean()

/**
* @description Updates an etablissement from its id.
* @param {ObjectId} id
* @param {Object} values
* @returns {Promise<Etablissement>}
*/
export const findByIdAndUpdate = async (id, values): Promise<IEtablissement | null> => Etablissement.findByIdAndUpdate({ _id: id }, values, { new: true })
export const findByIdAndUpdate = async (id, values): Promise<IEtablissement | null> => Etablissement.findByIdAndUpdate({ _id: id }, values, { new: true }).lean()

/**
* @description Deletes an etablissement from its id.
* @param {ObjectId} id
* @returns {Promise<void>}
*/
export const findByIdAndDelete = async (id): Promise<IEtablissement | null> => Etablissement.findByIdAndDelete(id)
export const findByIdAndDelete = async (id): Promise<IEtablissement | null> => Etablissement.findByIdAndDelete(id).lean()

/**
* @description Get etablissement from a given query
* @param {Object} query
* @returns {Promise<void>}
*/
export const getEtablissement = async (query: FilterQuery<IUserRecruteur>): Promise<IUserRecruteur | null> => UserRecruteur.findOne(query)
export const getEtablissement = async (query: FilterQuery<IUserRecruteur>): Promise<IUserRecruteur | null> => UserRecruteur.findOne(query).lean()

/**
* @description Get opco details from CFADOCK API for a given SIRET
Expand Down
2 changes: 1 addition & 1 deletion server/src/services/userRecruteur.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const getUsers = async (query: FilterQuery<IUserRecruteur>, options, { pa
* @param {Filter<IUserRecruteur>} query
* @returns {Promise<IUserRecruteur>}
*/
export const getUser = async (query: FilterQuery<IUserRecruteur>): Promise<IUserRecruteur | null> => UserRecruteur.findOne(query)
export const getUser = async (query: FilterQuery<IUserRecruteur>): Promise<IUserRecruteur | null> => UserRecruteur.findOne(query).lean()

/**
* @description create user
Expand Down
2 changes: 1 addition & 1 deletion server/static/templates/mail-bienvenue.mjml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Félicitations, votre compte La bonne alternance est désormais créé pour votre centre de formation :<br /><br />
<% } %>
<%= data.establishment_raison_sociale %><br /><br />
Vous pouvez désormais accéder à votre espace pour publier
Vous pouvez désormais accéder à votre espace afin de publier
<% if(!data.is_delegated){ %>
vos offres
<% } %>
Expand Down
6 changes: 3 additions & 3 deletions server/static/templates/mail-candidature.mjml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@
<% } else { %>
<mj-text font-size="16px" line-height="28px" padding-bottom="15px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a class="link-black" href="<%= data.unsubscribeUrl %>">
🚫 Ne plus recevoir de candidature spontanée de La bonne alternance</a>
🚫 Déréférencer mon établissement</a>
</mj-text>
<mj-text font-size="16px" line-height="28px" padding-bottom="15px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a class="link-black" href="mailto:labonnealternance@apprentissage.beta.gouv.fr?subject=MAJ%20informations%20entreprise%20-%20Candidature%20spontanée">
📝 Modifier ou supprimer les données de mon établissement</a>
📝 Modifier les données de mon établissement</a>
</mj-text>
<mj-text font-size="16px" line-height="28px" padding-bottom="15px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a class="link-black" href="<%= data.lbaRecruiterUrl %>">
Expand Down Expand Up @@ -207,7 +207,7 @@
Par ailleurs, nous ne faisons aucune utilisation commerciale de vos données.
Conformément à l’article L.34-5 du code des postes et communications électroniques, vous bénéficiez d’un droit d’opposition
que vous pouvez utiliser à tout moment via l’adresse
<a class="link-black" href="mailto:[email protected]?subject=Droit%20opposition%20entreprise%20-%20Candidature%20spontanée">
<a class="link-black" href="mailto:[email protected]?subject=Droit%20opposition%20entreprise%20-%20Candidature%20spontanée&body=Bonjour,%0A%0APouvez-vous%20proc%C3%A9der%20au%20d%C3%A9r%C3%A9f%C3%A9rencement%20de%20mon%20entreprise%20du%20service%20gouvernemental%20La%20bonne%20alternance%20%3F%0A%0AEn%20effet,%20mon%20entreprise%20%28merci%20de%20pr%C3%A9ciser%20la%20raison%20de%20votre%20demande%29%0A-%20A%20d%C3%A9j%C3%A0%20recrut%C3%A9%20tous%20ses%20alternants%20pour%20l'ann%C3%A9e%20en%20cours%0A-%20Re%C3%A7oit%20des%20candidatures%20qui%20ne%20correspondent%20pas%20%C3%A0%20notre%20besoin%0A-%20Utilise%20d'autres%20canaux%20pour%20ses%20recrutements%0A-%20Ne%20recrute%20pas%20en%20alternance%0A-%20Autre">
labonnealternance@apprentissage.beta.gouv.fr</a>.
</mj-text>
<mj-text font-size="12px" line-height="20px" font-weight="400" color="#242424">
Expand Down
7 changes: 4 additions & 3 deletions shared/models/appointments.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Jsonify } from "type-fest"

import { z } from "../helpers/zodWithOpenApi"

import { zObjectId } from "./common"
Expand All @@ -7,9 +8,9 @@ export const ZMailing = z
.object({
campaign: z.string(),
message_id: z.string(),
status: z.string(),
webhook_status_at: z.date(),
email_sent_at: z.date(),
status: z.string().nullish(),
webhook_status_at: z.date().nullish(),
email_sent_at: z.date().nullish(),
})
.strict()
.openapi("Mailing")
Expand Down
1 change: 1 addition & 0 deletions shared/models/elligibleTraining.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Jsonify } from "type-fest"

import { z } from "../helpers/zodWithOpenApi"

import { ZAppointment } from "./appointments.model"
Expand Down
Loading

0 comments on commit dd973fe

Please sign in to comment.