From 4c49c570b693027ab8821705356b1626331a6fd4 Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Mon, 5 May 2025 12:32:35 -0400 Subject: [PATCH] update strapi definitions --- strapi/Dockerfile | 2 +- .../api/blog/content-types/blog/schema.json | 38 +++++++++++++++++++ strapi/src/api/blog/controllers/blog.ts | 7 ++++ strapi/src/api/blog/routes/blog.ts | 7 ++++ strapi/src/api/blog/services/blog.ts | 7 ++++ strapi/src/components/shared/tag.json | 14 +++++++ strapi/types/generated/components.d.ts | 12 ++++++ strapi/types/generated/contentTypes.d.ts | 28 ++++++++++++++ 8 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 strapi/src/api/blog/content-types/blog/schema.json create mode 100644 strapi/src/api/blog/controllers/blog.ts create mode 100644 strapi/src/api/blog/routes/blog.ts create mode 100644 strapi/src/api/blog/services/blog.ts create mode 100644 strapi/src/components/shared/tag.json diff --git a/strapi/Dockerfile b/strapi/Dockerfile index 000851c..fdd5e6a 100644 --- a/strapi/Dockerfile +++ b/strapi/Dockerfile @@ -6,7 +6,7 @@ ENV NODE_ENV=${NODE_ENV} WORKDIR /opt/ COPY package.json bun.lock ./ -RUN bun add --global node-gyp && bun install --production --frozen-lockfile +RUN bun add --global node-gyp && bun install --filter 'strapi' --production --frozen-lockfile ENV PATH=/opt/node_modules/.bin:$PATH WORKDIR /opt/app COPY . . diff --git a/strapi/src/api/blog/content-types/blog/schema.json b/strapi/src/api/blog/content-types/blog/schema.json new file mode 100644 index 0000000..1ad29a1 --- /dev/null +++ b/strapi/src/api/blog/content-types/blog/schema.json @@ -0,0 +1,38 @@ +{ + "kind": "collectionType", + "collectionName": "blogs", + "info": { + "singularName": "blog", + "pluralName": "blogs", + "displayName": "Blog", + "description": "" + }, + "options": { + "draftAndPublish": true + }, + "attributes": { + "Title": { + "type": "string", + "required": true, + "unique": true + }, + "Body": { + "type": "richtext", + "required": true + }, + "Topics": { + "displayName": "Tag", + "type": "component", + "repeatable": true, + "component": "shared.tag" + }, + "Header": { + "type": "media", + "multiple": false, + "required": true, + "allowedTypes": [ + "images" + ] + } + } +} diff --git a/strapi/src/api/blog/controllers/blog.ts b/strapi/src/api/blog/controllers/blog.ts new file mode 100644 index 0000000..93a4bc2 --- /dev/null +++ b/strapi/src/api/blog/controllers/blog.ts @@ -0,0 +1,7 @@ +/** + * blog controller + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreController('api::blog.blog'); diff --git a/strapi/src/api/blog/routes/blog.ts b/strapi/src/api/blog/routes/blog.ts new file mode 100644 index 0000000..79ec878 --- /dev/null +++ b/strapi/src/api/blog/routes/blog.ts @@ -0,0 +1,7 @@ +/** + * blog router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::blog.blog'); diff --git a/strapi/src/api/blog/services/blog.ts b/strapi/src/api/blog/services/blog.ts new file mode 100644 index 0000000..4707574 --- /dev/null +++ b/strapi/src/api/blog/services/blog.ts @@ -0,0 +1,7 @@ +/** + * blog service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::blog.blog'); diff --git a/strapi/src/components/shared/tag.json b/strapi/src/components/shared/tag.json new file mode 100644 index 0000000..b319ab8 --- /dev/null +++ b/strapi/src/components/shared/tag.json @@ -0,0 +1,14 @@ +{ + "collectionName": "components_shared_tags", + "info": { + "displayName": "Tag", + "icon": "priceTag" + }, + "options": {}, + "attributes": { + "Topic": { + "type": "enumeration", + "enum": ["development", "work", "life"] + } + } +} diff --git a/strapi/types/generated/components.d.ts b/strapi/types/generated/components.d.ts index 9833389..d9fdd5d 100644 --- a/strapi/types/generated/components.d.ts +++ b/strapi/types/generated/components.d.ts @@ -50,6 +50,17 @@ export interface SharedSeo extends Struct.ComponentSchema { }; } +export interface SharedTag extends Struct.ComponentSchema { + collectionName: 'components_shared_tags'; + info: { + displayName: 'Tag'; + icon: 'priceTag'; + }; + attributes: { + Topic: Schema.Attribute.Enumeration<['development', 'work', 'life']>; + }; +} + declare module '@strapi/strapi' { export module Public { export interface ComponentSchemas { @@ -57,6 +68,7 @@ declare module '@strapi/strapi' { 'shared.quote': SharedQuote; 'shared.rich-text': SharedRichText; 'shared.seo': SharedSeo; + 'shared.tag': SharedTag; } } } diff --git a/strapi/types/generated/contentTypes.d.ts b/strapi/types/generated/contentTypes.d.ts index 76b7e8e..3a8e0a7 100644 --- a/strapi/types/generated/contentTypes.d.ts +++ b/strapi/types/generated/contentTypes.d.ts @@ -336,6 +336,33 @@ export interface AdminUser extends Struct.CollectionTypeSchema { }; } +export interface ApiBlogBlog extends Struct.CollectionTypeSchema { + collectionName: 'blogs'; + info: { + description: ''; + displayName: 'Blog'; + pluralName: 'blogs'; + singularName: 'blog'; + }; + options: { + draftAndPublish: true; + }; + attributes: { + Body: Schema.Attribute.RichText & Schema.Attribute.Required; + createdAt: Schema.Attribute.DateTime; + createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & Schema.Attribute.Private; + Header: Schema.Attribute.Media<'images'> & Schema.Attribute.Required; + locale: Schema.Attribute.String & Schema.Attribute.Private; + localizations: Schema.Attribute.Relation<'oneToMany', 'api::blog.blog'> & + Schema.Attribute.Private; + publishedAt: Schema.Attribute.DateTime; + Title: Schema.Attribute.String & Schema.Attribute.Required & Schema.Attribute.Unique; + Topics: Schema.Attribute.Component<'shared.tag', true>; + updatedAt: Schema.Attribute.DateTime; + updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & Schema.Attribute.Private; + }; +} + export interface PluginContentReleasesRelease extends Struct.CollectionTypeSchema { collectionName: 'strapi_releases'; info: { @@ -763,6 +790,7 @@ declare module '@strapi/strapi' { 'admin::transfer-token': AdminTransferToken; 'admin::transfer-token-permission': AdminTransferTokenPermission; 'admin::user': AdminUser; + 'api::blog.blog': ApiBlogBlog; 'plugin::content-releases.release': PluginContentReleasesRelease; 'plugin::content-releases.release-action': PluginContentReleasesReleaseAction; 'plugin::i18n.locale': PluginI18NLocale;