From d4b7654be58188198bfea20f973b3ab26ce02225 Mon Sep 17 00:00:00 2001 From: trivernis Date: Tue, 25 Jun 2024 23:29:50 +0200 Subject: [PATCH] rename blog entry to blog post --- .dockerignore | 9 ++ Dockerfile | 27 +++-- .../author/content-types/author/schema.json | 31 +++++ .../controllers/author.js} | 4 +- .../blog-entry.js => author/routes/author.js} | 4 +- .../services/author.js} | 4 +- .../content-types/blog-entry/schema.json | 21 ---- .../content-types/blog-post/schema.json | 29 +++++ src/api/blog-post/controllers/blog-post.js | 9 ++ src/api/blog-post/routes/blog-post.js | 9 ++ src/api/blog-post/services/blog-post.js | 9 ++ types/generated/contentTypes.d.ts | 106 ++++++++++++------ 12 files changed, 194 insertions(+), 68 deletions(-) create mode 100644 .dockerignore create mode 100644 src/api/author/content-types/author/schema.json rename src/api/{blog-entry/controllers/blog-entry.js => author/controllers/author.js} (50%) rename src/api/{blog-entry/routes/blog-entry.js => author/routes/author.js} (51%) rename src/api/{blog-entry/services/blog-entry.js => author/services/author.js} (51%) delete mode 100644 src/api/blog-entry/content-types/blog-entry/schema.json create mode 100644 src/api/blog-post/content-types/blog-post/schema.json create mode 100644 src/api/blog-post/controllers/blog-post.js create mode 100644 src/api/blog-post/routes/blog-post.js create mode 100644 src/api/blog-post/services/blog-post.js diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..19fecde --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.tmp/ +.cache/ +.git/ +.env +build/ +node_modules/ +# Ignoring folders that might be used in starter templates +data/ +backup/ diff --git a/Dockerfile b/Dockerfile index 3ec8751..d77d238 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,28 @@ -FROM node:18-alpine3.18 - -RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev git -ARG NODE_ENV=development -ENV NODE_ENV=${NODE_ENV} +# Creating multi-stage build for production +FROM node:18-alpine as build +RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev git > /dev/null 2>&1 +ENV NODE_ENV=production WORKDIR /opt/ COPY package.json yarn.lock ./ RUN yarn global add node-gyp -RUN yarn config set network-timeout 600000 -g && yarn install +RUN yarn config set network-timeout 600000 -g && yarn install --production ENV PATH /opt/node_modules/.bin:$PATH - WORKDIR /opt/app COPY . . +RUN yarn build + +# Creating final production image +FROM node:18-alpine +RUN apk add --no-cache vips-dev +ENV NODE_ENV=production +WORKDIR /opt/ +COPY --from=build /opt/node_modules ./node_modules +WORKDIR /opt/app +COPY --from=build /opt/app ./ +ENV PATH /opt/node_modules/.bin:$PATH + RUN chown -R node:node /opt/app USER node -RUN ["yarn", "build"] EXPOSE 1337 -CMD ["yarn", "develop"] +CMD ["yarn", "start"] diff --git a/src/api/author/content-types/author/schema.json b/src/api/author/content-types/author/schema.json new file mode 100644 index 0000000..61d1760 --- /dev/null +++ b/src/api/author/content-types/author/schema.json @@ -0,0 +1,31 @@ +{ + "kind": "collectionType", + "collectionName": "authors", + "info": { + "singularName": "author", + "pluralName": "authors", + "displayName": "Author" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "name": { + "type": "string" + }, + "profilePicture": { + "allowedTypes": [ + "images", + "files", + "videos", + "audios" + ], + "type": "media", + "multiple": true + }, + "slug": { + "type": "uid" + } + } +} diff --git a/src/api/blog-entry/controllers/blog-entry.js b/src/api/author/controllers/author.js similarity index 50% rename from src/api/blog-entry/controllers/blog-entry.js rename to src/api/author/controllers/author.js index b5cece5..93de2e1 100644 --- a/src/api/blog-entry/controllers/blog-entry.js +++ b/src/api/author/controllers/author.js @@ -1,9 +1,9 @@ 'use strict'; /** - * blog-entry controller + * author controller */ const { createCoreController } = require('@strapi/strapi').factories; -module.exports = createCoreController('api::blog-entry.blog-entry'); +module.exports = createCoreController('api::author.author'); diff --git a/src/api/blog-entry/routes/blog-entry.js b/src/api/author/routes/author.js similarity index 51% rename from src/api/blog-entry/routes/blog-entry.js rename to src/api/author/routes/author.js index c31b7b6..934f67b 100644 --- a/src/api/blog-entry/routes/blog-entry.js +++ b/src/api/author/routes/author.js @@ -1,9 +1,9 @@ 'use strict'; /** - * blog-entry router + * author router */ const { createCoreRouter } = require('@strapi/strapi').factories; -module.exports = createCoreRouter('api::blog-entry.blog-entry'); +module.exports = createCoreRouter('api::author.author'); diff --git a/src/api/blog-entry/services/blog-entry.js b/src/api/author/services/author.js similarity index 51% rename from src/api/blog-entry/services/blog-entry.js rename to src/api/author/services/author.js index d256a65..61f296f 100644 --- a/src/api/blog-entry/services/blog-entry.js +++ b/src/api/author/services/author.js @@ -1,9 +1,9 @@ 'use strict'; /** - * blog-entry service + * author service */ const { createCoreService } = require('@strapi/strapi').factories; -module.exports = createCoreService('api::blog-entry.blog-entry'); +module.exports = createCoreService('api::author.author'); diff --git a/src/api/blog-entry/content-types/blog-entry/schema.json b/src/api/blog-entry/content-types/blog-entry/schema.json deleted file mode 100644 index 06d2d52..0000000 --- a/src/api/blog-entry/content-types/blog-entry/schema.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "kind": "collectionType", - "collectionName": "blog_entries", - "info": { - "singularName": "blog-entry", - "pluralName": "blog-entries", - "displayName": "Blog Entry" - }, - "options": { - "draftAndPublish": true - }, - "pluginOptions": {}, - "attributes": { - "content": { - "type": "blocks" - }, - "Title": { - "type": "string" - } - } -} diff --git a/src/api/blog-post/content-types/blog-post/schema.json b/src/api/blog-post/content-types/blog-post/schema.json new file mode 100644 index 0000000..d06ebc6 --- /dev/null +++ b/src/api/blog-post/content-types/blog-post/schema.json @@ -0,0 +1,29 @@ +{ + "kind": "collectionType", + "collectionName": "blog_posts", + "info": { + "singularName": "blog-post", + "pluralName": "blog-posts", + "displayName": "Blog Post" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "slug": { + "type": "uid" + }, + "title": { + "type": "string" + }, + "author": { + "type": "relation", + "relation": "oneToOne", + "target": "api::author.author" + }, + "content": { + "type": "richtext" + } + } +} diff --git a/src/api/blog-post/controllers/blog-post.js b/src/api/blog-post/controllers/blog-post.js new file mode 100644 index 0000000..95e9692 --- /dev/null +++ b/src/api/blog-post/controllers/blog-post.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * blog-post controller + */ + +const { createCoreController } = require('@strapi/strapi').factories; + +module.exports = createCoreController('api::blog-post.blog-post'); diff --git a/src/api/blog-post/routes/blog-post.js b/src/api/blog-post/routes/blog-post.js new file mode 100644 index 0000000..65bbad8 --- /dev/null +++ b/src/api/blog-post/routes/blog-post.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * blog-post router + */ + +const { createCoreRouter } = require('@strapi/strapi').factories; + +module.exports = createCoreRouter('api::blog-post.blog-post'); diff --git a/src/api/blog-post/services/blog-post.js b/src/api/blog-post/services/blog-post.js new file mode 100644 index 0000000..4387fed --- /dev/null +++ b/src/api/blog-post/services/blog-post.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * blog-post service + */ + +const { createCoreService } = require('@strapi/strapi').factories; + +module.exports = createCoreService('api::blog-post.blog-post'); diff --git a/types/generated/contentTypes.d.ts b/types/generated/contentTypes.d.ts index 5ef225b..35d72e0 100644 --- a/types/generated/contentTypes.d.ts +++ b/types/generated/contentTypes.d.ts @@ -362,37 +362,6 @@ export interface AdminTransferTokenPermission extends Schema.CollectionType { }; } -export interface ApiBlogEntryBlogEntry extends Schema.CollectionType { - collectionName: 'blog_entries'; - info: { - singularName: 'blog-entry'; - pluralName: 'blog-entries'; - displayName: 'Blog Entry'; - }; - options: { - draftAndPublish: true; - }; - attributes: { - content: Attribute.Blocks; - Title: Attribute.String; - createdAt: Attribute.DateTime; - updatedAt: Attribute.DateTime; - publishedAt: Attribute.DateTime; - createdBy: Attribute.Relation< - 'api::blog-entry.blog-entry', - 'oneToOne', - 'admin::user' - > & - Attribute.Private; - updatedBy: Attribute.Relation< - 'api::blog-entry.blog-entry', - 'oneToOne', - 'admin::user' - > & - Attribute.Private; - }; -} - export interface PluginUploadFile extends Schema.CollectionType { collectionName: 'files'; info: { @@ -819,6 +788,78 @@ export interface PluginI18NLocale extends Schema.CollectionType { }; } +export interface ApiAuthorAuthor extends Schema.CollectionType { + collectionName: 'authors'; + info: { + singularName: 'author'; + pluralName: 'authors'; + displayName: 'Author'; + }; + options: { + draftAndPublish: true; + }; + attributes: { + name: Attribute.String; + profilePicture: Attribute.Media< + 'images' | 'files' | 'videos' | 'audios', + true + >; + slug: Attribute.UID; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; + createdBy: Attribute.Relation< + 'api::author.author', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + updatedBy: Attribute.Relation< + 'api::author.author', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + }; +} + +export interface ApiBlogPostBlogPost extends Schema.CollectionType { + collectionName: 'blog_posts'; + info: { + singularName: 'blog-post'; + pluralName: 'blog-posts'; + displayName: 'Blog Post'; + }; + options: { + draftAndPublish: true; + }; + attributes: { + slug: Attribute.UID; + title: Attribute.String; + author: Attribute.Relation< + 'api::blog-post.blog-post', + 'oneToOne', + 'api::author.author' + >; + content: Attribute.RichText; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; + createdBy: Attribute.Relation< + 'api::blog-post.blog-post', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + updatedBy: Attribute.Relation< + 'api::blog-post.blog-post', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + }; +} + declare module '@strapi/types' { export module Shared { export interface ContentTypes { @@ -829,7 +870,6 @@ declare module '@strapi/types' { 'admin::api-token-permission': AdminApiTokenPermission; 'admin::transfer-token': AdminTransferToken; 'admin::transfer-token-permission': AdminTransferTokenPermission; - 'api::blog-entry.blog-entry': ApiBlogEntryBlogEntry; 'plugin::upload.file': PluginUploadFile; 'plugin::upload.folder': PluginUploadFolder; 'plugin::content-releases.release': PluginContentReleasesRelease; @@ -838,6 +878,8 @@ declare module '@strapi/types' { 'plugin::users-permissions.role': PluginUsersPermissionsRole; 'plugin::users-permissions.user': PluginUsersPermissionsUser; 'plugin::i18n.locale': PluginI18NLocale; + 'api::author.author': ApiAuthorAuthor; + 'api::blog-post.blog-post': ApiBlogPostBlogPost; } } }