Loading .strapi-updater.json +1 −1 Original line number Diff line number Diff line { "latest": "5.12.5", "lastUpdateCheck": 1744806284674, "lastUpdateCheck": 1745211071553, "lastNotification": 1744867304898 } src/api/contacts-page/content-types/contacts-page/schema.json 0 → 100644 +31 −0 Original line number Diff line number Diff line { "kind": "collectionType", "collectionName": "contacts_pages", "info": { "singularName": "contacts-page", "pluralName": "contacts-pages", "displayName": "ContactsPage", "description": "" }, "options": { "draftAndPublish": true }, "attributes": { "pageTitle": { "type": "string", "default": "Контакты", "required": true }, "contactsSection": { "type": "component", "repeatable": false, "component": "page-block.section-with-contacts" }, "site": { "type": "relation", "relation": "oneToOne", "target": "api::site.site", "inversedBy": "contacts_page" } } } src/api/contacts-page/controllers/contacts-page.ts 0 → 100644 +16 −0 Original line number Diff line number Diff line /** * contacts-page controller */ import { Context } from "koa"; import { factories } from "@strapi/strapi"; export default factories.createCoreController( "api::contacts-page.contacts-page", ({ strapi }) => ({ getContactsPage(ctx: Context) { return strapi.service("api::contacts-page.contacts-page").getPage(ctx); }, }), ); src/api/contacts-page/routes/contacts-page.ts 0 → 100644 +14 −0 Original line number Diff line number Diff line /** * contacts-page router */ export default { routes: [ { method: "GET", path: "/pages/contacts-page", handler: "contacts-page.getContactsPage", config: { auth: false }, }, ], }; src/api/contacts-page/services/contacts-page.ts 0 → 100644 +43 −0 Original line number Diff line number Diff line import { Context } from "koa"; import { factories } from "@strapi/strapi"; import { CUSTOM_REQUEST_HEADERS } from "../../../lib/constants/custom-headers"; import { formatSectionWithContacts, sectionWithContactsRetrievingConfig, } from "../../../lib/api-utils/data-retrieving-configs/section-witch-contacts"; export default factories.createCoreService( "api::contacts-page.contacts-page", ({ strapi }) => ({ async getPage(ctx: Context) { const contactsPage = await strapi .documents("api::contacts-page.contacts-page") .findFirst({ filters: { site: { documentId: ctx.request.headers[ CUSTOM_REQUEST_HEADERS.siteDocumentId ] as string, }, }, fields: ["pageTitle"], populate: { contactsSection: sectionWithContactsRetrievingConfig, }, }); if (!contactsPage) { return ctx.notFound("Page not found"); } const responseBody = { pageTitle: contactsPage.pageTitle, contactsSection: formatSectionWithContacts( contactsPage.contactsSection, ), }; ctx.body = responseBody; }, }), ); Loading
.strapi-updater.json +1 −1 Original line number Diff line number Diff line { "latest": "5.12.5", "lastUpdateCheck": 1744806284674, "lastUpdateCheck": 1745211071553, "lastNotification": 1744867304898 }
src/api/contacts-page/content-types/contacts-page/schema.json 0 → 100644 +31 −0 Original line number Diff line number Diff line { "kind": "collectionType", "collectionName": "contacts_pages", "info": { "singularName": "contacts-page", "pluralName": "contacts-pages", "displayName": "ContactsPage", "description": "" }, "options": { "draftAndPublish": true }, "attributes": { "pageTitle": { "type": "string", "default": "Контакты", "required": true }, "contactsSection": { "type": "component", "repeatable": false, "component": "page-block.section-with-contacts" }, "site": { "type": "relation", "relation": "oneToOne", "target": "api::site.site", "inversedBy": "contacts_page" } } }
src/api/contacts-page/controllers/contacts-page.ts 0 → 100644 +16 −0 Original line number Diff line number Diff line /** * contacts-page controller */ import { Context } from "koa"; import { factories } from "@strapi/strapi"; export default factories.createCoreController( "api::contacts-page.contacts-page", ({ strapi }) => ({ getContactsPage(ctx: Context) { return strapi.service("api::contacts-page.contacts-page").getPage(ctx); }, }), );
src/api/contacts-page/routes/contacts-page.ts 0 → 100644 +14 −0 Original line number Diff line number Diff line /** * contacts-page router */ export default { routes: [ { method: "GET", path: "/pages/contacts-page", handler: "contacts-page.getContactsPage", config: { auth: false }, }, ], };
src/api/contacts-page/services/contacts-page.ts 0 → 100644 +43 −0 Original line number Diff line number Diff line import { Context } from "koa"; import { factories } from "@strapi/strapi"; import { CUSTOM_REQUEST_HEADERS } from "../../../lib/constants/custom-headers"; import { formatSectionWithContacts, sectionWithContactsRetrievingConfig, } from "../../../lib/api-utils/data-retrieving-configs/section-witch-contacts"; export default factories.createCoreService( "api::contacts-page.contacts-page", ({ strapi }) => ({ async getPage(ctx: Context) { const contactsPage = await strapi .documents("api::contacts-page.contacts-page") .findFirst({ filters: { site: { documentId: ctx.request.headers[ CUSTOM_REQUEST_HEADERS.siteDocumentId ] as string, }, }, fields: ["pageTitle"], populate: { contactsSection: sectionWithContactsRetrievingConfig, }, }); if (!contactsPage) { return ctx.notFound("Page not found"); } const responseBody = { pageTitle: contactsPage.pageTitle, contactsSection: formatSectionWithContacts( contactsPage.contactsSection, ), }; ctx.body = responseBody; }, }), );