From d6792409491eb9f9daa2ae481e637947dcca16b4 Mon Sep 17 00:00:00 2001 From: Ludovic Mermod Date: Tue, 8 Aug 2023 16:40:44 +0200 Subject: [PATCH 1/4] build: add nextjs app to devcontainer (#38) --- .devcontainer/docker-compose.yaml | 17 +++++++++++++++ app/.devcontainer/Dockerfile | 12 +++++++++++ app/.devcontainer/devcontainer.json | 33 +++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 app/.devcontainer/Dockerfile create mode 100644 app/.devcontainer/devcontainer.json diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml index a1df02c..01666d6 100644 --- a/.devcontainer/docker-compose.yaml +++ b/.devcontainer/docker-compose.yaml @@ -43,6 +43,23 @@ services: volumes: - "strapi-data:/var/lib/postgresql/data" + app: + # Build the app service from its folder + build: + # Build context, relative to the current file + context: ../app/.devcontainer + # Path to Dockerfile, relative to context + dockerfile: Dockerfile + args: + VARIANT: ${VARIANT:-18-bullseye} + environment: + NODE_ENV: development + volumes: + # Bind-mount the app project folder into the container + - type: bind + source: ../app + target: /app + volumes: # Persist strapi database strapi-data: diff --git a/app/.devcontainer/Dockerfile b/app/.devcontainer/Dockerfile new file mode 100644 index 0000000..e989ef6 --- /dev/null +++ b/app/.devcontainer/Dockerfile @@ -0,0 +1,12 @@ +# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster +ARG VARIANT=18-bullseye +FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT} + +# the root folder will be mounted at /app in the container +WORKDIR /app + +# use "node" user with UID/GID 1000 (avoid permission issues with root) +USER node + +# install dependencies and run in watch mode +CMD npm install && npm run dev \ No newline at end of file diff --git a/app/.devcontainer/devcontainer.json b/app/.devcontainer/devcontainer.json new file mode 100644 index 0000000..db6f69e --- /dev/null +++ b/app/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +// strapi service devcontainer +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/typescript-node +{ + "name": "clic-website-devcontainer/app", + // Use docker-compose stack, relative to current file + "dockerComposeFile": "../../.devcontainer/docker-compose.yaml", + // Connect VSCode to following service defined in dockerComposeFile + "service": "app", + // Working directory inside devcontainer, where project is located + "workspaceFolder": "/app", + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + // todo highlighter + "wayou.vscode-todo-highlight", + // linter + "dbaeumer.vscode-eslint", + // formatter + "esbenp.prettier-vscode" + ] + } + }, + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "node" + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", +} From 356866ac8e277a19734d4e0bcd312a8c0182d222 Mon Sep 17 00:00:00 2001 From: Robb-Fr Date: Wed, 9 Aug 2023 12:27:58 +0000 Subject: [PATCH 2/4] feat: add strapi content type structure for CLIC models (#26) Co-authored-by: Ludovic Mermod --- .../content-types/association/schema.json | 126 ++++++++++++++++++ .../association/controllers/association.ts | 7 + .../src/api/association/routes/association.ts | 7 + .../api/association/services/association.ts | 7 + .../content-types/commission/schema.json | 72 ++++++++++ .../api/commission/controllers/commission.ts | 7 + .../src/api/commission/routes/commission.ts | 7 + .../src/api/commission/services/commission.ts | 7 + .../api/event/content-types/event/schema.json | 103 ++++++++++++++ strapi/src/api/event/controllers/event.ts | 7 + strapi/src/api/event/routes/event.ts | 7 + strapi/src/api/event/services/event.ts | 7 + .../member/content-types/member/schema.json | 52 ++++++++ strapi/src/api/member/controllers/member.ts | 7 + strapi/src/api/member/routes/member.ts | 7 + strapi/src/api/member/services/member.ts | 7 + .../api/news/content-types/news/schema.json | 90 +++++++++++++ strapi/src/api/news/controllers/news.ts | 7 + strapi/src/api/news/routes/news.ts | 7 + strapi/src/api/news/services/news.ts | 7 + .../partner/content-types/partner/schema.json | 57 ++++++++ strapi/src/api/partner/controllers/partner.ts | 7 + strapi/src/api/partner/routes/partner.ts | 7 + strapi/src/api/partner/services/partner.ts | 7 + .../api/pole/content-types/pole/schema.json | 57 ++++++++ strapi/src/api/pole/controllers/pole.ts | 7 + strapi/src/api/pole/routes/pole.ts | 7 + strapi/src/api/pole/services/pole.ts | 7 + .../content-types/social-link/schema.json | 42 ++++++ .../social-link/controllers/social-link.ts | 7 + .../src/api/social-link/routes/social-link.ts | 7 + .../api/social-link/services/social-link.ts | 7 + 32 files changed, 767 insertions(+) create mode 100644 strapi/src/api/association/content-types/association/schema.json create mode 100644 strapi/src/api/association/controllers/association.ts create mode 100644 strapi/src/api/association/routes/association.ts create mode 100644 strapi/src/api/association/services/association.ts create mode 100644 strapi/src/api/commission/content-types/commission/schema.json create mode 100644 strapi/src/api/commission/controllers/commission.ts create mode 100644 strapi/src/api/commission/routes/commission.ts create mode 100644 strapi/src/api/commission/services/commission.ts create mode 100644 strapi/src/api/event/content-types/event/schema.json create mode 100644 strapi/src/api/event/controllers/event.ts create mode 100644 strapi/src/api/event/routes/event.ts create mode 100644 strapi/src/api/event/services/event.ts create mode 100644 strapi/src/api/member/content-types/member/schema.json create mode 100644 strapi/src/api/member/controllers/member.ts create mode 100644 strapi/src/api/member/routes/member.ts create mode 100644 strapi/src/api/member/services/member.ts create mode 100644 strapi/src/api/news/content-types/news/schema.json create mode 100644 strapi/src/api/news/controllers/news.ts create mode 100644 strapi/src/api/news/routes/news.ts create mode 100644 strapi/src/api/news/services/news.ts create mode 100644 strapi/src/api/partner/content-types/partner/schema.json create mode 100644 strapi/src/api/partner/controllers/partner.ts create mode 100644 strapi/src/api/partner/routes/partner.ts create mode 100644 strapi/src/api/partner/services/partner.ts create mode 100644 strapi/src/api/pole/content-types/pole/schema.json create mode 100644 strapi/src/api/pole/controllers/pole.ts create mode 100644 strapi/src/api/pole/routes/pole.ts create mode 100644 strapi/src/api/pole/services/pole.ts create mode 100644 strapi/src/api/social-link/content-types/social-link/schema.json create mode 100644 strapi/src/api/social-link/controllers/social-link.ts create mode 100644 strapi/src/api/social-link/routes/social-link.ts create mode 100644 strapi/src/api/social-link/services/social-link.ts diff --git a/strapi/src/api/association/content-types/association/schema.json b/strapi/src/api/association/content-types/association/schema.json new file mode 100644 index 0000000..cf551e2 --- /dev/null +++ b/strapi/src/api/association/content-types/association/schema.json @@ -0,0 +1,126 @@ +{ + "kind": "singleType", + "collectionName": "associations", + "info": { + "singularName": "association", + "pluralName": "associations", + "displayName": "Association", + "description": "" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "attributes": { + "association_name": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "string", + "required": true, + "default": "CLIC", + "unique": true + }, + "about": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "richtext", + "required": false + }, + "logo": { + "type": "media", + "multiple": false, + "required": true, + "allowedTypes": [ + "images" + ], + "pluginOptions": { + "i18n": { + "localized": true + } + } + }, + "gallery": { + "type": "media", + "multiple": true, + "required": false, + "allowedTypes": [ + "images", + "videos" + ], + "pluginOptions": { + "i18n": { + "localized": true + } + } + }, + "official_documents": { + "type": "media", + "multiple": true, + "required": false, + "allowedTypes": [ + "files" + ], + "pluginOptions": { + "i18n": { + "localized": true + } + } + }, + "social_links": { + "type": "relation", + "relation": "oneToMany", + "target": "api::social-link.social-link" + }, + "members": { + "type": "relation", + "relation": "oneToMany", + "target": "api::member.member" + }, + "partners": { + "type": "relation", + "relation": "oneToMany", + "target": "api::partner.partner" + }, + "address": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "string", + "required": true, + "unique": true, + "default": "CLIC, INN 132, Station 14, EPFL, CH-1015 Lausanne" + }, + "email": { + "pluginOptions": { + "i18n": { + "localized": false + } + }, + "type": "email", + "default": "clic@epfl.ch", + "unique": false + }, + "phone": { + "pluginOptions": { + "i18n": { + "localized": false + } + }, + "type": "string", + "default": "+41 21 693 81 28", + "unique": false + } + } +} diff --git a/strapi/src/api/association/controllers/association.ts b/strapi/src/api/association/controllers/association.ts new file mode 100644 index 0000000..9228f14 --- /dev/null +++ b/strapi/src/api/association/controllers/association.ts @@ -0,0 +1,7 @@ +/** + * association controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::association.association'); diff --git a/strapi/src/api/association/routes/association.ts b/strapi/src/api/association/routes/association.ts new file mode 100644 index 0000000..3b76b04 --- /dev/null +++ b/strapi/src/api/association/routes/association.ts @@ -0,0 +1,7 @@ +/** + * association router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::association.association'); diff --git a/strapi/src/api/association/services/association.ts b/strapi/src/api/association/services/association.ts new file mode 100644 index 0000000..e665438 --- /dev/null +++ b/strapi/src/api/association/services/association.ts @@ -0,0 +1,7 @@ +/** + * association service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::association.association'); diff --git a/strapi/src/api/commission/content-types/commission/schema.json b/strapi/src/api/commission/content-types/commission/schema.json new file mode 100644 index 0000000..9d9c8d6 --- /dev/null +++ b/strapi/src/api/commission/content-types/commission/schema.json @@ -0,0 +1,72 @@ +{ + "kind": "collectionType", + "collectionName": "commissions", + "info": { + "singularName": "commission", + "pluralName": "commissions", + "displayName": "Commission", + "description": "" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "attributes": { + "commission_name": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "string", + "required": true, + "unique": true + }, + "news": { + "type": "relation", + "relation": "manyToMany", + "target": "api::news.news", + "mappedBy": "commissions" + }, + "description": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "richtext", + "required": true + }, + "small_description": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "text", + "required": true + }, + "members": { + "type": "relation", + "relation": "manyToMany", + "target": "api::member.member", + "mappedBy": "commissions" + }, + "social_links": { + "type": "relation", + "relation": "oneToMany", + "target": "api::social-link.social-link", + "mappedBy": "commission" + }, + "partners": { + "type": "relation", + "relation": "manyToMany", + "target": "api::partner.partner", + "inversedBy": "commissions" + } + } +} diff --git a/strapi/src/api/commission/controllers/commission.ts b/strapi/src/api/commission/controllers/commission.ts new file mode 100644 index 0000000..5373de1 --- /dev/null +++ b/strapi/src/api/commission/controllers/commission.ts @@ -0,0 +1,7 @@ +/** + * commission controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::commission.commission'); diff --git a/strapi/src/api/commission/routes/commission.ts b/strapi/src/api/commission/routes/commission.ts new file mode 100644 index 0000000..6f9cc8c --- /dev/null +++ b/strapi/src/api/commission/routes/commission.ts @@ -0,0 +1,7 @@ +/** + * commission router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::commission.commission'); diff --git a/strapi/src/api/commission/services/commission.ts b/strapi/src/api/commission/services/commission.ts new file mode 100644 index 0000000..cbc4497 --- /dev/null +++ b/strapi/src/api/commission/services/commission.ts @@ -0,0 +1,7 @@ +/** + * commission service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::commission.commission'); diff --git a/strapi/src/api/event/content-types/event/schema.json b/strapi/src/api/event/content-types/event/schema.json new file mode 100644 index 0000000..a4577c7 --- /dev/null +++ b/strapi/src/api/event/content-types/event/schema.json @@ -0,0 +1,103 @@ +{ + "kind": "collectionType", + "collectionName": "events", + "info": { + "singularName": "event", + "pluralName": "events", + "displayName": "Event", + "description": "" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "attributes": { + "event_date": { + "pluginOptions": { + "i18n": { + "localized": false + } + }, + "type": "datetime", + "required": true + }, + "event_description": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "richtext", + "default": "insert the event description here", + "required": true + }, + "canceled": { + "pluginOptions": { + "i18n": { + "localized": false + } + }, + "type": "boolean", + "default": false, + "required": true + }, + "media": { + "type": "media", + "multiple": true, + "required": false, + "allowedTypes": [ + "images", + "videos", + "audios" + ], + "pluginOptions": { + "i18n": { + "localized": false + } + } + }, + "link": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "string" + }, + "news": { + "type": "relation", + "relation": "oneToMany", + "target": "api::news.news", + "mappedBy": "event" + }, + "event_name": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "string", + "required": true, + "unique": true + }, + "small_description": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "text", + "required": true + }, + "partners": { + "type": "relation", + "relation": "manyToMany", + "target": "api::partner.partner", + "inversedBy": "events" + } + } +} diff --git a/strapi/src/api/event/controllers/event.ts b/strapi/src/api/event/controllers/event.ts new file mode 100644 index 0000000..9725955 --- /dev/null +++ b/strapi/src/api/event/controllers/event.ts @@ -0,0 +1,7 @@ +/** + * event controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::event.event'); diff --git a/strapi/src/api/event/routes/event.ts b/strapi/src/api/event/routes/event.ts new file mode 100644 index 0000000..bea7eaa --- /dev/null +++ b/strapi/src/api/event/routes/event.ts @@ -0,0 +1,7 @@ +/** + * event router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::event.event'); diff --git a/strapi/src/api/event/services/event.ts b/strapi/src/api/event/services/event.ts new file mode 100644 index 0000000..8fe1b33 --- /dev/null +++ b/strapi/src/api/event/services/event.ts @@ -0,0 +1,7 @@ +/** + * event service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::event.event'); diff --git a/strapi/src/api/member/content-types/member/schema.json b/strapi/src/api/member/content-types/member/schema.json new file mode 100644 index 0000000..79fe691 --- /dev/null +++ b/strapi/src/api/member/content-types/member/schema.json @@ -0,0 +1,52 @@ +{ + "kind": "collectionType", + "collectionName": "members", + "info": { + "singularName": "member", + "pluralName": "members", + "displayName": "Member", + "description": "" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "link": { + "type": "string", + "required": true + }, + "role": { + "type": "string", + "required": true + }, + "picture": { + "type": "media", + "multiple": false, + "required": false, + "allowedTypes": [ + "images" + ] + }, + "name": { + "type": "string", + "required": true + }, + "affiliation": { + "type": "string", + "required": true + }, + "poles": { + "type": "relation", + "relation": "manyToMany", + "target": "api::pole.pole", + "inversedBy": "members" + }, + "commissions": { + "type": "relation", + "relation": "manyToMany", + "target": "api::commission.commission", + "inversedBy": "members" + } + } +} diff --git a/strapi/src/api/member/controllers/member.ts b/strapi/src/api/member/controllers/member.ts new file mode 100644 index 0000000..204bc1b --- /dev/null +++ b/strapi/src/api/member/controllers/member.ts @@ -0,0 +1,7 @@ +/** + * member controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::member.member'); diff --git a/strapi/src/api/member/routes/member.ts b/strapi/src/api/member/routes/member.ts new file mode 100644 index 0000000..e914063 --- /dev/null +++ b/strapi/src/api/member/routes/member.ts @@ -0,0 +1,7 @@ +/** + * member router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::member.member'); diff --git a/strapi/src/api/member/services/member.ts b/strapi/src/api/member/services/member.ts new file mode 100644 index 0000000..0c024c1 --- /dev/null +++ b/strapi/src/api/member/services/member.ts @@ -0,0 +1,7 @@ +/** + * member service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::member.member'); diff --git a/strapi/src/api/news/content-types/news/schema.json b/strapi/src/api/news/content-types/news/schema.json new file mode 100644 index 0000000..a15772a --- /dev/null +++ b/strapi/src/api/news/content-types/news/schema.json @@ -0,0 +1,90 @@ +{ + "kind": "collectionType", + "collectionName": "newss", + "info": { + "singularName": "news", + "pluralName": "newss", + "displayName": "News", + "description": "" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "attributes": { + "content": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "richtext", + "default": "insert the news content here", + "required": true + }, + "publication": { + "pluginOptions": { + "i18n": { + "localized": false + } + }, + "type": "date", + "required": true + }, + "picture": { + "type": "media", + "multiple": false, + "required": true, + "allowedTypes": [ + "images" + ], + "pluginOptions": { + "i18n": { + "localized": true + } + } + }, + "event": { + "type": "relation", + "relation": "manyToOne", + "target": "api::event.event", + "inversedBy": "news" + }, + "news_title": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "string", + "required": true + }, + "commissions": { + "type": "relation", + "relation": "manyToMany", + "target": "api::commission.commission", + "inversedBy": "news" + }, + "link": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "string" + }, + "small_description": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "text", + "required": true + } + } +} diff --git a/strapi/src/api/news/controllers/news.ts b/strapi/src/api/news/controllers/news.ts new file mode 100644 index 0000000..c71543d --- /dev/null +++ b/strapi/src/api/news/controllers/news.ts @@ -0,0 +1,7 @@ +/** + * news controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::news.news'); diff --git a/strapi/src/api/news/routes/news.ts b/strapi/src/api/news/routes/news.ts new file mode 100644 index 0000000..222c69b --- /dev/null +++ b/strapi/src/api/news/routes/news.ts @@ -0,0 +1,7 @@ +/** + * news router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::news.news'); diff --git a/strapi/src/api/news/services/news.ts b/strapi/src/api/news/services/news.ts new file mode 100644 index 0000000..8a376ba --- /dev/null +++ b/strapi/src/api/news/services/news.ts @@ -0,0 +1,7 @@ +/** + * news service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::news.news'); diff --git a/strapi/src/api/partner/content-types/partner/schema.json b/strapi/src/api/partner/content-types/partner/schema.json new file mode 100644 index 0000000..87804c6 --- /dev/null +++ b/strapi/src/api/partner/content-types/partner/schema.json @@ -0,0 +1,57 @@ +{ + "kind": "collectionType", + "collectionName": "partners", + "info": { + "singularName": "partner", + "pluralName": "partners", + "displayName": "Partner" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "partner_name": { + "type": "string", + "required": true, + "unique": true + }, + "partner_logo": { + "allowedTypes": [ + "images" + ], + "type": "media", + "multiple": false, + "required": true + }, + "partner_link": { + "type": "string", + "required": true, + "unique": true + }, + "partner_rank": { + "type": "integer", + "default": 1, + "required": true + }, + "partnership_end": { + "type": "date", + "required": false + }, + "partnership_start": { + "type": "date" + }, + "commissions": { + "type": "relation", + "relation": "manyToMany", + "target": "api::commission.commission", + "inversedBy": "partners" + }, + "events": { + "type": "relation", + "relation": "manyToMany", + "target": "api::event.event", + "inversedBy": "partners" + } + } +} diff --git a/strapi/src/api/partner/controllers/partner.ts b/strapi/src/api/partner/controllers/partner.ts new file mode 100644 index 0000000..bdfb779 --- /dev/null +++ b/strapi/src/api/partner/controllers/partner.ts @@ -0,0 +1,7 @@ +/** + * partner controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::partner.partner'); diff --git a/strapi/src/api/partner/routes/partner.ts b/strapi/src/api/partner/routes/partner.ts new file mode 100644 index 0000000..5f566f8 --- /dev/null +++ b/strapi/src/api/partner/routes/partner.ts @@ -0,0 +1,7 @@ +/** + * partner router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::partner.partner'); diff --git a/strapi/src/api/partner/services/partner.ts b/strapi/src/api/partner/services/partner.ts new file mode 100644 index 0000000..8e731ca --- /dev/null +++ b/strapi/src/api/partner/services/partner.ts @@ -0,0 +1,7 @@ +/** + * partner service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::partner.partner'); diff --git a/strapi/src/api/pole/content-types/pole/schema.json b/strapi/src/api/pole/content-types/pole/schema.json new file mode 100644 index 0000000..587567a --- /dev/null +++ b/strapi/src/api/pole/content-types/pole/schema.json @@ -0,0 +1,57 @@ +{ + "kind": "collectionType", + "collectionName": "poles", + "info": { + "singularName": "pole", + "pluralName": "poles", + "displayName": "Pole" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "attributes": { + "pole_name": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "string", + "required": true, + "unique": true + }, + "pole_description": { + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "type": "richtext", + "required": true + }, + "pole_logo": { + "allowedTypes": [ + "images" + ], + "type": "media", + "multiple": false, + "pluginOptions": { + "i18n": { + "localized": true + } + }, + "required": false + }, + "members": { + "type": "relation", + "relation": "manyToMany", + "target": "api::member.member", + "mappedBy": "poles" + } + } +} diff --git a/strapi/src/api/pole/controllers/pole.ts b/strapi/src/api/pole/controllers/pole.ts new file mode 100644 index 0000000..64616aa --- /dev/null +++ b/strapi/src/api/pole/controllers/pole.ts @@ -0,0 +1,7 @@ +/** + * pole controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::pole.pole'); diff --git a/strapi/src/api/pole/routes/pole.ts b/strapi/src/api/pole/routes/pole.ts new file mode 100644 index 0000000..d8a4cbc --- /dev/null +++ b/strapi/src/api/pole/routes/pole.ts @@ -0,0 +1,7 @@ +/** + * pole router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::pole.pole'); diff --git a/strapi/src/api/pole/services/pole.ts b/strapi/src/api/pole/services/pole.ts new file mode 100644 index 0000000..37fba4e --- /dev/null +++ b/strapi/src/api/pole/services/pole.ts @@ -0,0 +1,7 @@ +/** + * pole service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::pole.pole'); diff --git a/strapi/src/api/social-link/content-types/social-link/schema.json b/strapi/src/api/social-link/content-types/social-link/schema.json new file mode 100644 index 0000000..b5f7b21 --- /dev/null +++ b/strapi/src/api/social-link/content-types/social-link/schema.json @@ -0,0 +1,42 @@ +{ + "kind": "collectionType", + "collectionName": "social_links", + "info": { + "singularName": "social-link", + "pluralName": "social-links", + "displayName": "Social Link" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "target_name": { + "type": "string", + "required": true, + "unique": false + }, + "target_url": { + "type": "string", + "unique": true, + "required": true + }, + "enabled": { + "type": "boolean", + "default": true + }, + "icon": { + "allowedTypes": [ + "images" + ], + "type": "media", + "multiple": false + }, + "commission": { + "type": "relation", + "relation": "manyToOne", + "target": "api::commission.commission", + "inversedBy": "social_links" + } + } +} diff --git a/strapi/src/api/social-link/controllers/social-link.ts b/strapi/src/api/social-link/controllers/social-link.ts new file mode 100644 index 0000000..098b97e --- /dev/null +++ b/strapi/src/api/social-link/controllers/social-link.ts @@ -0,0 +1,7 @@ +/** + * social-link controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::social-link.social-link'); diff --git a/strapi/src/api/social-link/routes/social-link.ts b/strapi/src/api/social-link/routes/social-link.ts new file mode 100644 index 0000000..360ea4a --- /dev/null +++ b/strapi/src/api/social-link/routes/social-link.ts @@ -0,0 +1,7 @@ +/** + * social-link router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::social-link.social-link'); diff --git a/strapi/src/api/social-link/services/social-link.ts b/strapi/src/api/social-link/services/social-link.ts new file mode 100644 index 0000000..1a27f2b --- /dev/null +++ b/strapi/src/api/social-link/services/social-link.ts @@ -0,0 +1,7 @@ +/** + * social-link service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::social-link.social-link'); From 687d1536268c62421d6ad64d2aa49d57a399e502 Mon Sep 17 00:00:00 2001 From: Ludovic Mermod Date: Wed, 9 Aug 2023 16:16:08 +0200 Subject: [PATCH 3/4] chore: integrate development docker stack with vscode (#22) Co-authored-by: Alexandre Chau --- .devcontainer/docker-compose.yaml | 2 ++ .vscode/settings.json | 44 +++++++++++++++++++++++++- .vscode/tasks.json | 34 ++++++++++++++++++++ strapi/.devcontainer/devcontainer.json | 33 ------------------- 4 files changed, 79 insertions(+), 34 deletions(-) create mode 100644 .vscode/tasks.json delete mode 100644 strapi/.devcontainer/devcontainer.json diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml index 01666d6..036e3de 100644 --- a/.devcontainer/docker-compose.yaml +++ b/.devcontainer/docker-compose.yaml @@ -7,6 +7,7 @@ services: # Custom strapi service strapi: # Build the strapi service from its folder + container_name: clic-strapi build: # Build context, relative to the current file context: ../strapi/.devcontainer @@ -35,6 +36,7 @@ services: # Database service for strapi strapi-postgres: + container_name: clic-postgres image: postgres environment: POSTGRES_DB: strapi_data diff --git a/.vscode/settings.json b/.vscode/settings.json index 7ec871b..927266d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,5 +16,47 @@ "color": "white", "backgroundColor": "orange" }, - "todohighlight.keywordsPattern": "(todo|TODO|fixme|FIXME)(:?)" + "todohighlight.keywordsPattern": "(todo|TODO|fixme|FIXME)(:?)", + "terminal.integrated.profiles.linux": { + "strapi": { + "path": "docker", + "args": ["exec", "-it", "clic-strapi", "/bin/bash"], + "overrideName": true + }, + "postgres": { + "path": "docker", + "args": ["exec", "-it", "clic-postgres", "/bin/bash"], + "overrideName": true + } + }, + "terminal.integrated.profiles.windows": { + "strapi": { + "path": "docker", + "args": ["exec", "-it", "clic-strapi", "/bin/bash"], + "overrideName": true + }, + "postgres": { + "path": "docker", + "args": ["exec", "-it", "clic-postgres", "/bin/bash"], + "overrideName": true + } + }, + "terminal.integrated.profiles.osx": { + "strapi": { + "path": "docker", + "args": ["exec", "-it", "clic-strapi", "/bin/bash"], + "overrideName": true + }, + "postgres": { + "path": "docker", + "args": ["exec", "-it", "clic-postgres", "/bin/bash"], + "overrideName": true + } + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } } diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..045b291 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,34 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Start dev container", + "type": "shell", + "command": "docker compose --file .devcontainer/docker-compose.yaml up", + "windows": { + "command": "docker compose --file .devcontainer\\docker-compose.yaml up" + }, + "group": "none", + "presentation": { + "reveal": "always", + "panel": "new" + }, + "runOptions": { + "runOn": "folderOpen" + } + }, + { + "label": "Stop dev container", + "type": "shell", + "command": "docker compose --file .devcontainer/docker-compose.yaml down", + "windows": { + "command": "docker compose --file .devcontainer\\docker-compose.yaml down" + }, + "group": "none", + "presentation": { + "reveal": "always", + "panel": "new" + } + } + ] +} diff --git a/strapi/.devcontainer/devcontainer.json b/strapi/.devcontainer/devcontainer.json deleted file mode 100644 index 67be020..0000000 --- a/strapi/.devcontainer/devcontainer.json +++ /dev/null @@ -1,33 +0,0 @@ -// strapi service devcontainer -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/typescript-node -{ - "name": "clic-website-devcontainer/strapi", - // Use docker-compose stack, relative to current file - "dockerComposeFile": "../../.devcontainer/docker-compose.yaml", - // Connect VSCode to following service defined in dockerComposeFile - "service": "strapi", - // Working directory inside devcontainer, where project is located - "workspaceFolder": "/app", - // Configure tool-specific properties. - "customizations": { - // Configure properties specific to VS Code. - "vscode": { - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - // todo highlighter - "wayou.vscode-todo-highlight", - // linter - "dbaeumer.vscode-eslint", - // formatter - "esbenp.prettier-vscode" - ] - } - }, - // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "node" - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "yarn install", -} From 6db75ca9e6dea8e489dbaebef790885bb9f9148a Mon Sep 17 00:00:00 2001 From: Ludovic Mermod Date: Thu, 10 Aug 2023 14:14:06 +0200 Subject: [PATCH 4/4] chore: add development reverse proxy (#39) Co-authored-by: Alexandre Chau --- .devcontainer/docker-compose.yaml | 10 +++++++--- app/package-lock.json | 19 ++++++++++--------- caddy/Caddyfile.dev | 11 +++++++++++ strapi/.env.example | 1 + strapi/config/middlewares.ts | 1 + strapi/config/server.ts | 1 + strapi/src/middlewares/admin-redirect.ts | 15 +++++++++++++++ 7 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 caddy/Caddyfile.dev create mode 100644 strapi/src/middlewares/admin-redirect.ts diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml index 036e3de..eb4ef9e 100644 --- a/.devcontainer/docker-compose.yaml +++ b/.devcontainer/docker-compose.yaml @@ -28,9 +28,6 @@ services: - type: bind source: ../strapi target: /app - ports: - # Expose strapi to port 8001 - - "8001:8001" depends_on: - strapi-postgres @@ -62,6 +59,13 @@ services: source: ../app target: /app + caddy: + image: caddy + volumes: + - "../caddy/Caddyfile.dev:/etc/caddy/Caddyfile" + ports: + - "80:80" + volumes: # Persist strapi database strapi-data: diff --git a/app/package-lock.json b/app/package-lock.json index 46b0e2c..5969dd0 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -19,9 +19,9 @@ "typescript": "5.0.4" }, "devDependencies": { - "autoprefixer": "^10.4.14", - "postcss": "^8.4.23", - "tailwindcss": "^3.3.2" + "autoprefixer": "10.4.14", + "postcss": "8.4.23", + "tailwindcss": "3.3.2" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -3223,9 +3223,9 @@ } }, "node_modules/postcss": { - "version": "8.4.27", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.27.tgz", - "integrity": "sha512-gY/ACJtJPSmUFPDCHtX78+01fHa64FaU4zaaWfuh1MhGJISufJAH4cun6k/8fwsHYeK4UQmENQK+tRLCFJE8JQ==", + "version": "8.4.23", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.23.tgz", + "integrity": "sha512-bQ3qMcpF6A/YjR55xtoTr0jGOlnPOKAIMdOWiv0EIT6HVPEaJiJB4NLljSbiHoC2RX7DN5Uvjtpbg1NPdwv1oA==", "dev": true, "funding": [ { @@ -3957,9 +3957,9 @@ } }, "node_modules/tailwindcss": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.3.tgz", - "integrity": "sha512-A0KgSkef7eE4Mf+nKJ83i75TMyq8HqY3qmFIJSWy8bNt0v1lG7jUcpGpoTFxAwYcWOphcTBLPPJg+bDfhDf52w==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.2.tgz", + "integrity": "sha512-9jPkMiIBXvPc2KywkraqsUfbfj+dHDb+JPWtSJa9MLFdrPyazI7q6WX2sUrm7R9eVR7qqv3Pas7EvQFzxKnI6w==", "dev": true, "dependencies": { "@alloc/quick-lru": "^5.2.0", @@ -3982,6 +3982,7 @@ "postcss-load-config": "^4.0.1", "postcss-nested": "^6.0.1", "postcss-selector-parser": "^6.0.11", + "postcss-value-parser": "^4.2.0", "resolve": "^1.22.2", "sucrase": "^3.32.0" }, diff --git a/caddy/Caddyfile.dev b/caddy/Caddyfile.dev new file mode 100644 index 0000000..995e486 --- /dev/null +++ b/caddy/Caddyfile.dev @@ -0,0 +1,11 @@ +{ + auto_https off +} + +http://localhost:80 { + handle_path /strapi* { + reverse_proxy http://strapi:8001 + } + + reverse_proxy http://app:3000 +} diff --git a/strapi/.env.example b/strapi/.env.example index 0c67025..b532981 100644 --- a/strapi/.env.example +++ b/strapi/.env.example @@ -1,5 +1,6 @@ HOST=0.0.0.0 PORT=8001 +URL=http://localhost/strapi APP_KEYS="toBeModified1,toBeModified2" API_TOKEN_SALT=tobemodified ADMIN_JWT_SECRET=tobemodified diff --git a/strapi/config/middlewares.ts b/strapi/config/middlewares.ts index 5191241..3884bda 100644 --- a/strapi/config/middlewares.ts +++ b/strapi/config/middlewares.ts @@ -9,4 +9,5 @@ export default [ "strapi::session", "strapi::favicon", "strapi::public", + { resolve: "./src/middlewares/admin-redirect" }, ]; diff --git a/strapi/config/server.ts b/strapi/config/server.ts index b73a6e5..871c114 100644 --- a/strapi/config/server.ts +++ b/strapi/config/server.ts @@ -4,4 +4,5 @@ export default ({ env }) => ({ app: { keys: env.array("APP_KEYS"), }, + url: env("URL", "http://localhost/strapi"), }); diff --git a/strapi/src/middlewares/admin-redirect.ts b/strapi/src/middlewares/admin-redirect.ts new file mode 100644 index 0000000..632310e --- /dev/null +++ b/strapi/src/middlewares/admin-redirect.ts @@ -0,0 +1,15 @@ +/** + * `admin-redirect` middleware + */ +import { Strapi } from "@strapi/strapi"; + +export default (config, { strapi }: { strapi: Strapi }) => { + const redirects = ["/", "/index.html"].map((path) => ({ + method: "GET", + path, + handler: (ctx) => ctx.redirect(strapi.config.admin.url), + config: { auth: false }, + })); + + strapi.server.routes(redirects); +};