Compare commits

20 Commits

Author SHA1 Message Date
cedric 1d7c39973c deploy: add workflow for check PR
Déploiement API BETA / build (push) Successful in 2m10s
Déploiement API BETA / deploy (push) Successful in 44s
Vérification PR / deploy-beta (pull_request) Successful in 45s
Vérification PR / build (pull_request) Successful in 2m6s
2026-05-16 11:29:44 +04:00
cedric 4fc9df88f4 deploy: prevent no app running in pm2
Déploiement API BETA / build (push) Successful in 2m6s
Déploiement API BETA / deploy (push) Successful in 44s
2026-05-16 11:17:30 +04:00
cedric 1b15741643 deploy: create prod workflow
Déploiement API BETA / build (push) Successful in 2m8s
Déploiement API BETA / deploy (push) Successful in 46s
2026-05-16 10:48:16 +04:00
cedric 4f512a555a deploy: fix branch
Déploiement API BETA / build (push) Successful in 2m14s
Déploiement API BETA / deploy (push) Successful in 48s
2026-05-16 10:12:11 +04:00
cedric 7950eb4fae deploy: add yarn
Déploiement API BETA / build (push) Successful in 2m14s
Déploiement API BETA / deploy (push) Failing after 8s
2026-05-16 10:03:50 +04:00
cedric d7575a28bd deploy: create workflow
Déploiement API BETA / build (push) Failing after 18s
Déploiement API BETA / deploy (push) Has been skipped
2026-05-16 10:02:26 +04:00
cedric 39aa3a31eb replace oki.re by pwaol.nu 2026-05-12 16:43:23 +04:00
cedric 883480c012 build: upgrade to v5.44.0 2026-04-29 17:55:39 +04:00
Cédric Famibelle-Pronzola fe44c32eb0 Merge pull request 'Correction des effets de bords liés à la migration vers la v5' (#3) from upgrade-fix into master
Reviewed-on: https://codeberg.org/OKI/api.oki.re/pulls/3
2026-04-28 11:32:04 +02:00
cedric 3ab054bee3 remove logs 2026-04-28 12:36:51 +04:00
cedric f781d52d1f fix: adapt parole beforeCreate method 2026-04-28 12:31:19 +04:00
cedric be4c7ed421 fix: change DeepL API calls config 2026-04-28 12:30:46 +04:00
cedric 7a168f54ff fix: use documentId 2026-04-28 12:30:29 +04:00
cedric 7df8ec1df2 config: change middleware file 2026-04-28 12:25:09 +04:00
cedric b219ca277d build: upgrade to v5.43.0 2026-04-28 12:24:51 +04:00
Cédric Famibelle-Pronzola 9a6ce8166a Merge pull request 'Upgrade vers la v5.42.1 de Strapi' (#2) from v5-upgrade into master
Reviewed-on: https://codeberg.org/OKI/api.oki.re/pulls/2
2026-04-22 05:31:17 +02:00
cedric b532981404 Changes from codemod 2026-04-21 21:35:59 +04:00
cedric e7bc8790b1 Fix stats request 2026-04-21 19:46:58 +04:00
cedric b71f1535bb build: upgrade to Strapi v5.42.1 2026-04-21 18:58:19 +04:00
cedric e32c08ac74 build: remove cache plugins 2026-04-17 10:34:24 +04:00
17 changed files with 5702 additions and 4741 deletions
+50
View File
@@ -0,0 +1,50 @@
name: Vérification PR
run-name: Vérification PR de ${{ gitea.actor }}
on:
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Activer Corepack (yarn)
run: corepack enable
- name: Installer les dépendances
run: yarn install --frozen-lockfile
- name: Build Strapi
run: yarn build
deploy-beta:
needs: build
runs-on: ubuntu-latest
steps:
- name: Pré-déployer sur BETA pour test
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
cd ${{ secrets.DEPLOY_PATH }}
git fetch origin
git checkout ${{ gitea.head.ref }}
git pull --ff-only origin ${{ gitea.head.ref }}
corepack enable
yarn install --frozen-lockfile
NODE_ENV=production yarn build
pm2 describe api-beta-pawol > /dev/null 2>&1 \
&& pm2 restart api-beta-pawol \
|| pm2 start yarn --name api-beta-pawol -- start
+48
View File
@@ -0,0 +1,48 @@
name: Déploiement API BETA
run-name: ${{ gitea.actor }} déploie API BETA
on:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Activer Corepack (yarn)
run: corepack enable
- name: Installer les dépendances
run: yarn install --frozen-lockfile
- name: Build Strapi
run: yarn build
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Déployer sur le serveur
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
cd ${{ secrets.DEPLOY_PATH }}
git pull --ff-only origin dev
corepack enable
yarn install --frozen-lockfile
NODE_ENV=production yarn build
pm2 describe api-beta-pawol > /dev/null 2>&1 \
&& pm2 restart api-beta-pawol \
|| pm2 start yarn --name api-beta-pawol -- start
+48
View File
@@ -0,0 +1,48 @@
name: Déploiement API PROD
run-name: ${{ gitea.actor }} déploie API PROD
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Activer Corepack (yarn)
run: corepack enable
- name: Installer les dépendances
run: yarn install --frozen-lockfile
- name: Build Strapi
run: yarn build
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Déployer sur le serveur
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
cd ${{ secrets.PROD_DEPLOY_PATH }}
git pull --ff-only origin master
corepack enable
yarn install --frozen-lockfile
NODE_ENV=production yarn build
pm2 describe api-pawol > /dev/null 2>&1 \
&& pm2 restart api-pawol \
|| pm2 start yarn --name api-pawol -- start
-4
View File
@@ -2,9 +2,7 @@
* This file was automatically generated by Strapi.
* Any modifications made will be discarded.
*/
import i18N from "@strapi/plugin-i18n/strapi-admin";
import usersPermissions from "@strapi/plugin-users-permissions/strapi-admin";
import restCache from "strapi-plugin-rest-cache/strapi-admin";
import { renderAdmin } from "@strapi/strapi/admin";
import customisations from "../../src/admin/app.js";
@@ -13,8 +11,6 @@ renderAdmin(document.getElementById("strapi"), {
customisations,
plugins: {
i18n: i18N,
"users-permissions": usersPermissions,
"rest-cache": restCache,
},
});
+2 -1
View File
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<!--
This file was automatically generated by Strapi.
@@ -58,5 +58,6 @@ Any modifications made will be discarded.
</div>
</div></noscript
>
<script type="module" src="/.strapi/client/app.js"></script>
</body>
</html>
+6 -9
View File
@@ -1,5 +1,5 @@
{
"name": "api.oki.re",
"name": "api.pawol.nu",
"description": "API de l'application web est conçue pour faciliter la transcription et la traduction automatiques de contenus musicaux.",
"private": false,
"version": "0.1.0",
@@ -11,7 +11,7 @@
},
"repository": {
"type": "git",
"url": "git+https://codeberg.org/OKI/api.oki.re.git"
"url": "git+https://codeberg.org/OKI/api.pawol.nu.git"
},
"scripts": {
"dev": "strapi develop",
@@ -21,19 +21,16 @@
},
"devDependencies": {},
"dependencies": {
"@strapi/plugin-i18n": "4.26.1",
"@strapi/plugin-users-permissions": "4.26.1",
"@strapi/plugin-users-permissions": "5.44.0",
"@strapi/provider-email-nodemailer": "^4.26.1",
"@strapi/strapi": "4.26.1",
"@strapi/strapi": "5.44.0",
"better-sqlite3": "^12.9.0",
"diff": "^5.1.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "^5.2.0",
"react-router-dom": "^6.0.0",
"slugify": "^1.6.5",
"strapi-plugin-rest-cache": "^4.2.4",
"strapi-provider-rest-cache-memory": "^4.2.4",
"styled-components": "^5.2.1",
"styled-components": "^6.0.0",
"yup": "^1.7.1"
},
"strapi": {
@@ -1,10 +1,5 @@
'use strict';
/**
* Read the documentation (https://strapi.io/documentation/v3.x/concepts/models.html#lifecycle-hooks)
* to customize this model
*/
const { ApplicationError } = require("@strapi/utils").errors
const slugify = require('slugify')
+4 -2
View File
@@ -26,7 +26,9 @@ module.exports = createCoreController('api::artiste.artiste', ({strapi}) => ({
}
}
const user = await strapi.entityService.findOne('plugin::users-permissions.user', body.data.user.id)
const user = await strapi.documents('plugin::users-permissions.user').findOne({
documentId: body.data.user.documentId
})
if (!user) {
throw new NotFoundError('Utilisateur introuvable.')
@@ -43,7 +45,7 @@ module.exports = createCoreController('api::artiste.artiste', ({strapi}) => ({
if (artiste) {
return artiste
} else {
const newArtiste = await strapi.entityService.create('api::artiste.artiste', {
const newArtiste = await strapi.documents('api::artiste.artiste').create({
data: {
...data
}
@@ -21,7 +21,9 @@ module.exports = createCoreController('api::commentaire.commentaire', ({strapi})
throw new UnauthorizedError(ctx, err, 'Opération non autorisée')
}
}
const user = await strapi.entityService.findOne('plugin::users-permissions.user', body.data.user.id)
const user = await strapi.documents('plugin::users-permissions.user').findOne({
documentId: data.user.documentId
})
if (!user) {
throw new NotFoundError('Utilisateur introuvable.')
@@ -33,7 +35,8 @@ module.exports = createCoreController('api::commentaire.commentaire', ({strapi})
data.user = user.id
const parole = await strapi.entityService.findOne('api::parole.parole', data.parole, {
const parole = await strapi.documents('api::parole.parole').findOne({
documentId: user.documentId,
fields: ['id']
})
@@ -41,13 +44,15 @@ module.exports = createCoreController('api::commentaire.commentaire', ({strapi})
throw new NotFoundError('Texte introuvable.')
}
const newCommentaire = await strapi.entityService.create('api::commentaire.commentaire', {
const newCommentaire = await strapi.documents('api::commentaire.commentaire').create({
data: {
...data
}
})
await strapi.entityService.update('api::parole.parole', parole.id, {
await strapi.documents('api::parole.parole').update({
documentId: user.documentId,
data: {
commentaires: [newCommentaire.id]
}
@@ -31,7 +31,7 @@ const isSlugExists = async existingSlug => {
}
const jwennAwtisEpiId = async artistesIds => {
if (artistesIds.length === 0) {
if (!artistesIds || artistesIds.length === 0) {
throw new ApplicationError('Champ obligatoire. Veuillez choisir au moins un artiste.');
}
@@ -53,8 +53,8 @@ const jwennUserEpiId = async userId => {
}
const user = await strapi.db.query('plugin::users-permissions.user').findOne({
where: {id: userId}
})
where: {user: userId}
})
if (!user) {
throw new ApplicationError('Utilisateur introuvable.')
@@ -116,43 +116,36 @@ const jwennSuperAdminEpiId = async userAdminId => {
module.exports = {
beforeCreate: async event => {
let {data} = event.params
delete data.createdBy
delete data.updatedBy
strapi.service('api::parole.parole').validateParoles(data.titre, data.transcription)
const userAdmin = await jwennUserAdminEpiId(data?.createdBy)
if (userAdmin) {
data.userAdmin = userAdmin
}
let artistesIds = []
if (data?.artistes?.connect) {
for (const artiste of data.artistes.connect) {
artistesIds.push(artiste.id)
if (data?.artistes?.connect?.length) {
artistesIds = data.artistes.connect.map(a => a.id)
if (data.titre && !data.forceSlug) {
const artiste = await jwennAwtisEpiId(artistesIds)
data.slug = getSlug(artiste, data.titre)
}
} else {
artistesIds = data.artistes
}
if (data.titre && !data.forceSlug) {
const artiste = await jwennAwtisEpiId(artistesIds)
data.slug = getSlug(artiste, data.titre)
}
const getSlugExistance = await isSlugExists(data.slug)
const getSlugExistance = await isSlugExists(data.slug)
if (getSlugExistance) {
throw new ApplicationError('Un morceau du même artiste existe déjà.')
if (getSlugExistance) {
throw new ApplicationError('Un morceau du même artiste existe déjà.')
}
}
},
beforeUpdate: async event => {
const {state} = event
let {data} = event.params
const {where} = event.params
const {id} = where
const {documentId} = data
const previousParoles = await strapi.db.query('api::parole.parole').findOne({
where: {id},
where: {documentId},
populate: {difference: true, artistes: true}
})
@@ -162,25 +155,26 @@ module.exports = {
state.diff = difference
}
if(!data.publishedAt && data.titre && data.transcription) {
if(!data.publishedAt && data.titre && data.transcription) {
strapi.service('api::parole.parole').validateParoles(data.titre, data.transcription)
if (data.titre && !data.forceSlug) {
let artistes
if (data.artistes.connect.length === 0) {
artistes = previousParoles.artistes.map(a => a.alias).join('-')
} else {
artistes = await jwennAwtisEpiId(data.artistes.connect)
let artistesIds = []
artistesIds = data.artistes.connect.map(a => a.id)
artistes = await jwennAwtisEpiId(artistesIds)
}
data.slug = getSlug(artistes, data.titre)
}
}
}
if (data.publishedAt != null) {
const {id} = where
const previousData = await strapi.db.query('api::parole.parole').findOne({
where: {id},
populate: {userAdmin: true, user: true}
where: {documentId}
})
const previousPublishedAt = previousData.publishedAt
@@ -192,7 +186,7 @@ module.exports = {
strapi.plugins['email'].services.email.send({
from: process.env.SMTP_FROM,
to: previousData.user.email,
subject: `Publication de "${previousData.titre}" sur oki.re`,
subject: `Publication de "${previousData.titre}" sur pawol.nu`,
text: `Le titre que vous avez soumis, "${previousData.titre}" a été publié sur le site.
Vous pouvez le trouver à l'adresse ${process.env.WEBSITE_URL}/paroles/${previousData.slug}
Merci pour votre contribution ❤️`,
@@ -205,7 +199,7 @@ module.exports = {
strapi.plugins['email'].services.email.send({
from: process.env.SMTP_FROM,
to: previousData.userAdmin.email,
subject: `Publication de "${previousData.titre}" sur oki.re`,
subject: `Publication de "${previousData.titre}" sur pawol.nu`,
text: `Le titre que vous avez soumis, "${previousData.titre}" a été publié sur le site.
Vous pouvez le trouver à l'adresse ${process.env.WEBSITE_URL}/paroles/${previousData.slug}.
Merci pour votre contribution ❤️`,
@@ -239,7 +233,7 @@ module.exports = {
}
},
afterUpdate: async event => {
const {result, state} = event
const {result, state} = event
if (state.diff) {
await strapi.entityService.update('api::parole.parole', result.id, {
+18 -9
View File
@@ -3,18 +3,21 @@
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::parole.parole', ({strapi}) => ({
async findOne(ctx) {
const {id} = ctx.params
const parole = await strapi.entityService.findOne('api::parole.parole', id, {
async findOne(documentId) {
const parole = await strapi.documents('api::parole.parole').findOne({
documentId,
populate: ['artistes']
})
return parole
},
async update(ctx) {
const {body} = ctx.request
const {data} = body
const updatedParole = await strapi.entityService.update('api::parole.parole', data.id, {
const updatedParole = await strapi.documents('api::parole.parole').update({
documentId: data.documentId,
data: {
...data
}
@@ -41,7 +44,9 @@ module.exports = createCoreController('api::parole.parole', ({strapi}) => ({
}
}
const user = await strapi.entityService.findOne('plugin::users-permissions.user', body.data.user.id)
const user = await strapi.documents('plugin::users-permissions.user').findOne({
documentId: body.data.user.documentId
})
if (!user) {
ctx.notFound('Utilisateur introuvable.')
@@ -51,13 +56,15 @@ module.exports = createCoreController('api::parole.parole', ({strapi}) => ({
ctx.badRequest('Informations non valides.')
}
const artiste = await strapi.entityService.findOne('api::artiste.artiste', data.artistes[0])
const artiste = await strapi.documents('api::artiste.artiste').findOne({
documentId: data.artistes[0].documentId
})
if (!artiste) {
ctx.notFound('Artiste introuvable.')
}
const currentUserParole = await strapi.entityService.findMany('api::parole.parole', {
const currentUserParole = await strapi.documents('api::parole.parole').findMany({
fields: ['id'],
filters: {
user: {
@@ -77,7 +84,7 @@ module.exports = createCoreController('api::parole.parole', ({strapi}) => ({
data.traductions = translated
}
const newParole = await strapi.entityService.create('api::parole.parole', {
const newParole = await strapi.documents('api::parole.parole').create({
data: {
...data
}
@@ -86,7 +93,9 @@ module.exports = createCoreController('api::parole.parole', ({strapi}) => ({
const parolesIds = currentUserParole.map(({id}) => id)
parolesIds.push(newParole.id)
await strapi.entityService.update('plugin::users-permissions.user', user.id, {
await strapi.documents('plugin::users-permissions.user').update({
documentId: user.documentId,
data: {
paroles: parolesIds
}
+8 -3
View File
@@ -21,15 +21,20 @@ class Translator {
target_lang: target,
text
}
const result = await axios.post(this.urlRequest, qs.stringify(data), {
const result = await axios.post(this.urlRequest, {
text: Array.isArray(text) ? text : [text],
source_lang: origin,
target_lang: target,
}, {
headers: {
'content-type': 'application/x-www-form-urlencoded'
Authorization: `DeepL-Auth-Key ${this.deeplKey}`,
'Content-Type': 'application/json'
}
})
return result.data
} catch (error) {
console.log('error', error)
console.error('DeepL error:', error?.response?.data || error);
}
}
}
+6 -7
View File
@@ -2,13 +2,12 @@
module.exports = {
async count(ctx, next) {
const countArtiste = await strapi.entityService.count('api::artiste.artiste')
const countParole = await strapi.entityService.count('api::parole.parole', {
filters: {
publishedAt: {
$notNull: true,
}
}
const countArtiste = await strapi.documents('api::artiste.artiste').count({
publicationState: 'live'
})
const countParole = await strapi.documents('api::parole.parole').count({
publicationState: 'live'
})
return {countArtiste, countParole}
+24 -28
View File
@@ -1,6 +1,6 @@
import type { Attribute, Schema } from '@strapi/strapi';
import type { Schema, Struct } from '@strapi/strapi';
export interface DifferenceParolesDiff extends Schema.Component {
export interface DifferenceParolesDiff extends Struct.ComponentSchema {
collectionName: 'components_diff_paroles_diffs';
info: {
description: '';
@@ -8,28 +8,24 @@ export interface DifferenceParolesDiff extends Schema.Component {
icon: 'american-sign-language-interpreting';
};
attributes: {
admin_user: Attribute.Relation<
'difference.paroles-diff',
'oneToOne',
'admin::user'
>;
date: Attribute.DateTime;
jsonDiff: Attribute.JSON;
paroles: Attribute.RichText;
sources: Attribute.Enumeration<
admin_user: Schema.Attribute.Relation<'oneToOne', 'admin::user'>;
date: Schema.Attribute.DateTime;
jsonDiff: Schema.Attribute.JSON;
paroles: Schema.Attribute.RichText;
sources: Schema.Attribute.Enumeration<
[
'transcription',
'francais',
'anglais',
'espagnol',
'allemand',
'italien'
'italien',
]
>;
};
}
export interface StoreAlbum extends Schema.Component {
export interface StoreAlbum extends Struct.ComponentSchema {
collectionName: 'components_store_albums';
info: {
description: '';
@@ -37,7 +33,7 @@ export interface StoreAlbum extends Schema.Component {
icon: 'music';
};
attributes: {
plateforme: Attribute.Enumeration<
plateforme: Schema.Attribute.Enumeration<
[
'Tidal',
'Spotify',
@@ -46,14 +42,14 @@ export interface StoreAlbum extends Schema.Component {
'Youtubemusic',
'Applemusic',
'Amazon',
'Soundcloud'
'Soundcloud',
]
>;
url: Attribute.String;
url: Schema.Attribute.String;
};
}
export interface TradTraductions extends Schema.Component {
export interface TradTraductions extends Struct.ComponentSchema {
collectionName: 'components_trad_traductions';
info: {
description: '';
@@ -61,15 +57,15 @@ export interface TradTraductions extends Schema.Component {
icon: 'spell-check';
};
attributes: {
allemand: Attribute.RichText;
anglais: Attribute.RichText;
espagnol: Attribute.RichText;
francais: Attribute.RichText;
italien: Attribute.RichText;
allemand: Schema.Attribute.RichText;
anglais: Schema.Attribute.RichText;
espagnol: Schema.Attribute.RichText;
francais: Schema.Attribute.RichText;
italien: Schema.Attribute.RichText;
};
}
export interface UrlLiens extends Schema.Component {
export interface UrlLiens extends Struct.ComponentSchema {
collectionName: 'components_url_liens';
info: {
description: '';
@@ -77,16 +73,16 @@ export interface UrlLiens extends Schema.Component {
icon: 'hand-pointer';
};
attributes: {
plateforme: Attribute.Enumeration<
plateforme: Schema.Attribute.Enumeration<
['Youtube', 'Gad\u00E9', 'Dailymotion', 'Vimeo', 'File', 'Lbry', 'Rumble']
>;
url: Attribute.String;
url: Schema.Attribute.String;
};
}
declare module '@strapi/types' {
export module Shared {
export interface Components {
declare module '@strapi/strapi' {
export module Public {
export interface ComponentSchemas {
'difference.paroles-diff': DifferenceParolesDiff;
'store.album': StoreAlbum;
'trad.traductions': TradTraductions;
+634 -520
View File
File diff suppressed because it is too large Load Diff
+4816 -4114
View File
File diff suppressed because it is too large Load Diff