Skip to content

Commit

Permalink
Merge branch 'master' into migrate-api-to-websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Mar 31, 2024
2 parents ab46b3c + 53c7d3e commit 642de33
Show file tree
Hide file tree
Showing 27 changed files with 467 additions and 332 deletions.
30 changes: 30 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/packages/api"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/packages/api-routes"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/packages/axios-helper"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/packages/prisma-clients"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/packages/types"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/apps/web"
schedule:
interval: "daily"
24 changes: 24 additions & 0 deletions .github/workflows/certificate-renewer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: certificate-renewer

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
renew-certificates:
runs-on: ubuntu-latest
environment: production
steps:
- name: Renew certificates
uses: appleboy/[email protected]
env:
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN_DM }}
with:
host: ${{ secrets.PRODUCTION_SSH_HOST }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
command_timeout: 2m
envs: DOCKER_REGISTRY_TOKEN_DM
script: |
cd workspace
docker compose run --rm certbot && docker compose up -d --force-recreate web_global
22 changes: 22 additions & 0 deletions .github/workflows/notification-sender.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: notification-sender

on:
workflow_dispatch:
jobs:
send-notifications:
runs-on: ubuntu-latest
environment: production
steps:
- name: Send emails
uses: appleboy/[email protected]
env:
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN_DM }}
with:
host: ${{ secrets.PRODUCTION_SSH_HOST }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
command_timeout: 2m
envs: DOCKER_REGISTRY_TOKEN_DM
script: |
cd workspace/DucksManager2
docker compose exec -w /app/packages api node ./api/scripts/send-notifications.js
22 changes: 22 additions & 0 deletions .github/workflows/pending-emails-sender.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: pending-emails-sender

on:
workflow_dispatch:
jobs:
send-emails:
runs-on: ubuntu-latest
environment: production
steps:
- name: Send emails
uses: appleboy/[email protected]
env:
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN_DM }}
with:
host: ${{ secrets.PRODUCTION_SSH_HOST }}
username: ${{ secrets.PRODUCTION_SSH_USER }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
command_timeout: 2m
envs: DOCKER_REGISTRY_TOKEN_DM
script: |
cd workspace/DucksManager2
docker compose exec -w /app/packages api node ./api/scripts/send-pending-emails.js
2 changes: 1 addition & 1 deletion apps/duck-estimator
Submodule duck-estimator updated 2 files
+3 −4 package.json
+177 −184 pnpm-lock.yaml
2 changes: 1 addition & 1 deletion apps/duckguessr
Submodule duckguessr updated 4 files
+8 −8 api/package.json
+215 −215 api/pnpm-lock.yaml
+17 −17 package.json
+4,953 −938 pnpm-lock.yaml
2 changes: 1 addition & 1 deletion apps/dumili
Submodule dumili updated 80 files
+2 −2 .env
+3 −2 .env.production
+23 −21 .eslintrc.js
+0 −1 .gitignore
+0 −1 .prettierignore
+1 −0 .prettierrc.js
+2 −0 Dockerfile
+1 −5 api/.env
+0 −25 api/.eslintrc.json
+0 −1 api/.prettierrc.json
+33 −173 api/index.ts
+6 −0 api/nodemon.json
+16 −27 api/package.json
+507 −1,413 api/pnpm-lock.yaml
+0 −64 api/prisma/migrations/20240218202452_/migration.sql
+0 −24 api/prisma/migrations/20240218205118_indexation_id_string/migration.sql
+0 −5 api/prisma/migrations/20240218205459_entry_to_indexation_fk/migration.sql
+0 −56 api/prisma/migrations/20240219210710_wip/migration.sql
+0 −3 api/prisma/migrations/migration_lock.toml
+0 −179 api/prisma/schema.prisma
+39 −0 api/routes/_auth.ts
+38 −0 api/routes/cloudinary/indexation/:indexation/ai/cover-search.ts
+48 −0 api/routes/cloudinary/indexation/:indexation/ai/kumiko.ts
+47 −0 api/routes/cloudinary/indexation/:indexation/ai/ocr/[...url].ts
+24 −0 api/routes/cloudinary/indexation/:indexation/index.ts
+18 −0 api/routes/cloudinary/indexation/index.ts
+4 −0 api/routes/me.ts
+0 −51 api/services/_auth.ts
+0 −12 api/services/index.ts
+0 −567 api/services/indexations/index.ts
+0 −35 api/services/indexations/kumiko.ts
+0 −23 api/services/indexations/ocr.ts
+0 −135 api/services/indexations/types.ts
+0 −5 api/services/types.ts
+8 −7 api/tsconfig.json
+0 −12 docker-compose-dev.yml
+4 −0 index.html
+32 −37 package.json
+1 −1 paddleocr/requirements.txt
+9 −4 paddleocr/server.py
+949 −1,482 pnpm-lock.yaml
+35 −33 src/App.vue
+23 −0 src/api.ts
+239 −188 src/components/Book.vue
+105 −96 src/components/Entry.vue
+5 −5 src/components/Gallery.vue
+2 −4 src/components/Issue.vue
+35 −28 src/components/IssueSelect.vue
+51 −31 src/components/IssueSuggestionList.vue
+31 −53 src/components/IssueSuggestionModal.vue
+4 −4 src/components/Story.vue
+30 −19 src/components/StorySearch.vue
+52 −39 src/components/StorySuggestionList.vue
+37 −47 src/components/SuggestionList.vue
+0 −253 src/components/TableOfContents.vue
+1 −1 src/components/TableTooltip.vue
+33 −46 src/components/TextEditor.vue
+42 −73 src/components/UploadWidget.vue
+120 −61 src/composables/useAi.ts
+0 −20 src/composables/useDumiliSocket.ts
+77 −21 src/composables/useHint.ts
+5 −10 src/main.ts
+65 −61 src/pages/index.vue
+73 −62 src/pages/indexation/[id].vue
+26 −0 src/stores/ai.ts
+383 −0 src/stores/coa.ts
+2 −0 src/stores/images.ts
+171 −82 src/stores/suggestions.ts
+3 −2 src/stores/tabs.ts
+0 −3 src/stores/ui.ts
+6 −0 src/stores/user.ts
+0 −21 src/style.scss
+2 −2 translations/messages.en.json
+6 −11 tsconfig.json
+1 −0 types/CloudinaryResourceContext.ts
+14 −0 types/CoverSearchResults.ts
+14 −0 types/KumikoResults.ts
+5 −0 types/OcrResults.ts
+0 −42 types/storyKinds.ts
+10 −17 vite.config.ts
1 change: 1 addition & 0 deletions apps/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ COPY --from=build /app/packages/api/dist/api ./packages/api
COPY packages/api/package.json ./packages/api
COPY packages/api/translations ./packages/api/translations
COPY packages/api/emails ./packages/api/emails
COPY packages/api/scripts ./packages/api/scripts

RUN --mount=type=cache,id=pnpm-store,target=/app/.pnpm-store \
pnpm i --production
Expand Down
13 changes: 9 additions & 4 deletions apps/web/src/components/LastPurchases.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ const hasPublicationNames = $computed(() => Object.keys(publicationNames)),
() =>
purchasesById.value &&
allIssues.value
?.reduce(
?.reduce<
{
purchase: { date: Date; description: string };
issues: IssueWithPublicationcode[];
}[]
>(
(acc, issue) => {
const existingPurchase =
issue.purchaseId && purchasesById.value![issue.purchaseId];
Expand All @@ -69,17 +74,17 @@ const hasPublicationNames = $computed(() => Object.keys(publicationNames)),
({ purchase: currentPurchase }) =>
currentPurchase.date === purchase.date,
);
if (purchaseIndex === -1) {
if (purchaseIndex === -1 && purchase.date) {
acc.push({
purchase: {
date: purchase.date as Date,
date: purchase.date,
description: purchase.description,
},
issues: [],
});
purchaseIndex = acc.length - 1;
}
acc[purchaseIndex].issues.push(issue);
acc[purchaseIndex]?.issues?.push(issue);
return acc;
},
[] as {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/MedalImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const props = defineProps<{
const {
contribution,
nextLevel = false,
nextLevel,
userLevelPoints,
small = false,
xSmall = false,
Expand All @@ -86,7 +86,7 @@ const { t } = useI18n();
const medalColors = ["bronze", "argent", "or"];
const level = computed(() =>
nextLevel && currentLevel.value !== null
nextLevel.value && currentLevel.value !== null
? currentLevel.value + 1
: currentLevel.value,
);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/PublicationSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const countryNamesForPublication = $computed(
);
const publicationNamesForCurrentCountry = $computed(() =>
publicationNamesFullCountries.value.includes(currentCountryCode || "")
? Object.keys(publicationNames)
? Object.keys(publicationNames.value)
.filter((publicationcode) =>
new RegExp(`^${currentCountryCode}/`).test(publicationcode),
)
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/pages/inducks/import.vue
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ const processRawData = async () => {
const REGEX_VALID_ROW = /^([^^]+\^[^^]+)\^/;
const issueCodes = rawData
.split("\n")
.filter((row) => !/^country/.test(row) && REGEX_VALID_ROW.test(row))
.map((row) => row.match(REGEX_VALID_ROW)![1].replace("^", "/"));
.filter((row: string) => !/^country/.test(row) && REGEX_VALID_ROW.test(row))
.map((row: string) => row.match(REGEX_VALID_ROW)![1].replace("^", "/"));
await fetchIssueCodesDetails(issueCodes);
if (!issueCodeDetails) {
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/pages/stats/conditions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
:conditions="conditionsWithoutMissing"
:number-per-condition="numberPerCondition"
/>
<ConditionsComponent
:conditions="conditionsWithoutMissing"
:number-per-condition="numberPerCondition"
/>
</template>

<script setup lang="ts">
Expand Down
1 change: 1 addition & 0 deletions packages/api/.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ INDUCKS_COVERS_ROOT="https://inducks.org/hr.php?normalsize=1&image=https://outdu

MYSQL_ROOT_PASSWORD=changeme

ASSETS_PICTURES_ROOT=http://localhost:8001/images/
ASSETS_MEDALS_PICTURES_ROOT=http://localhost:8001/images/medals/
PASTEC_HOSTS=pastec
PASTEC_PORT=4212
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
</p>
<% } %>
<br />
<b><%- __("Votre contribution vous a rapporté {{extraPhotographerPoints}} points \"Photographe\"", {extraPhotographerPoints})</b>, <%- __("bravo à vous et merci pour votre contribution : nous sommes heureux de vous compter parmi la communauté active de DucksManager !") %>
<b><%- __("Votre contribution vous a rapporté {{extraPhotographerPoints}} points \"Photographe\"", {extraPhotographerPoints}) %></b>, <%- __("bravo à vous et merci pour votre contribution : nous sommes heureux de vous compter parmi la communauté active de DucksManager !") %>

<%- include('../footer'); %>
15 changes: 5 additions & 10 deletions packages/api/emails/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const fr = Object.keys(en).reduce((acc, key) => ({ ...acc, [key]: key }), {});
export const i18n = new I18n({
locales: ["fr", "en-US"],

defaultLocale: "en-US",
defaultLocale: "fr",
staticCatalog: {
en: Object.entries(en).reduce(
"en-US": Object.entries(en).reduce(
(acc, [key, value]) => ({
...acc,
[key]: value,
Expand Down Expand Up @@ -71,18 +71,13 @@ export abstract class Email {
console.log(
`Sending email of type ${this.getTemplateDirName()} to ${options.to}`
);
try {
await Email.transporter.sendMail(options);
} catch (e) {
console.log(
`Can't send e-mail '${JSON.stringify(options)}': failed with ${e}`
);
}
await Email.transporter.sendMail(options);
}
} catch (e) {
console.log(
console.error(
`Can't send e-mail '${JSON.stringify(options)}': failed with ${e}`
);
return Promise.reject(e);
}
};

Expand Down
10 changes: 5 additions & 5 deletions packages/api/emails/footer.ejs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<br />
<br />
<%= __('A bientôt sur le site !') %><br />
<a href="https://ducksmanager.net"><img width="400" src="<%= process.env.VITE_IMAGES_ROOT %>logo_small.png" /></a>
<a href="<%= process.env.WEBSITE_ROOT %>"><img width="400" src="<%= process.env.ASSETS_PICTURES_ROOT %>logo_small.png" /></a>
<br />
<%= __('Retrouvez-nous sur les réseaux sociaux :') %><br />
<a href="https://www.facebook.com/DucksManager"><img src="<%= process.env.VITE_IMAGES_ROOT %>icons/facebook.png" /></a>&nbsp;
<a href="https://www.instagram.com/ducksmanager"><img src="<%= process.env.VITE_IMAGES_ROOT %>icons/instagram.png" /></a>&nbsp;
<a href="https://discord.gg/z959xaejJm"><img src="<%= process.env.VITE_IMAGES_ROOT %>icons/discord.png" /></a>&nbsp;
<a href="https://www.youtube.com/user/ducksmanager"><img src="<%= process.env.VITE_IMAGES_ROOT %>icons/youtube.png" /></a>
<a href="https://www.facebook.com/DucksManager"><img src="<%= process.env.ASSETS_PICTURES_ROOT %>icons/facebook.png" /></a>&nbsp;
<a href="https://www.instagram.com/ducksmanager"><img src="<%= process.env.ASSETS_PICTURES_ROOT %>icons/instagram.png" /></a>&nbsp;
<a href="https://discord.gg/z959xaejJm"><img src="<%= process.env.ASSETS_PICTURES_ROOT %>icons/discord.png" /></a>&nbsp;
<a href="https://www.youtube.com/user/ducksmanager"><img src="<%= process.env.ASSETS_PICTURES_ROOT %>icons/youtube.png" /></a>
30 changes: 14 additions & 16 deletions packages/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import events from "./services/events";
import feedback from "./services/feedback";
import globalStats from "./services/global-stats";
import login from "./services/login";
import notifications from "./services/notifications";
import presentationText from "./services/presentation-text";
import publicCollection from "./services/public-collection";
import stats from "./services/stats";
Expand All @@ -30,7 +29,7 @@ class ServerWithUser extends Server<
Record<string, never>,
Record<string, never>,
{ user?: SessionUser }
> { }
> {}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(BigInt.prototype as any).toJSON = function () {
Expand All @@ -47,45 +46,45 @@ Sentry.init({
});

const httpServer = createServer(async (req, res) => {
let data: { error: string } | object
let data: { error: string } | object;
switch (req.url) {
case '/status/db':
data = await getDbStatus()
case "/status/db":
data = await getDbStatus();
break;
case '/status/pastecsearch':
data = await getPastecSearchStatus()
case "/status/pastecsearch":
data = await getPastecSearchStatus();
break;
case '/status/pastec':
data = await getPastecStatus()
case "/status/pastec":
data = await getPastecStatus();
default:
res.writeHead(404);
res.end();
return
return;
}

res.writeHead("error" in data ? 500 : 200, { 'Content-Type': 'text/json' });
res.writeHead("error" in data ? 500 : 200, { "Content-Type": "text/json" });
res.write(JSON.stringify(data));
res.end();
});
const io = new ServerWithUser(httpServer, {
cors: {
origin: '*',
origin: "*",
},
});

instrument(io, {
auth: false
auth: false,
});

httpServer.listen(3000);
console.log('WebSocket open on port 3000')
console.log("WebSocket open on port 3000");

io.use(OptionalAuthMiddleware);
io.use((_socket, next) => {
next();

// app.all(
// /^\/(edgecreator\/(publish|edgesprites)|notifications)|(edges\/(published))|(\/demo\/reset)|(\/notification\/send)|(bookstores\/(approve|refuse))|(presentation-text\/(approve|refuse))/,
// /^\/(edgecreator\/(publish|edgesprites)|notifications)|(edges\/(published))|(\/demo\/reset)|(bookstores\/(approve|refuse))|(presentation-text\/(approve|refuse))/,
// [checkUserIsAdmin]
// );

Expand Down Expand Up @@ -115,7 +114,6 @@ events(io);
feedback(io);
globalStats(io);
login(io);
notifications(io);
presentationText(io);
publicCollection(io);
stats(io);
Loading

0 comments on commit 642de33

Please sign in to comment.