Skip to content

Commit

Permalink
[DEV-1390] Add Product schema and productsShowcase component to homep…
Browse files Browse the repository at this point in the history
…age in Strapi CMS (#631)

* Add Product schema, controller, routes and service di Strapi CMS

* Add productsShowcase component to Strapi CMS

* Fix linting in controller autogenerated file

* Add changeset

* Update .changeset/sweet-planets-change.md

Co-authored-by: Marco Comi <[email protected]>

* Add @strapi/provider-upload-aws-s3 and plugins.ts configuration file

* Update .env.default file

---------

Co-authored-by: Marco Comi <[email protected]>
Co-authored-by: AF <[email protected]>
Co-authored-by: AF <[email protected]>
Co-authored-by: Marco Ponchia <[email protected]>
  • Loading branch information
5 people authored Feb 15, 2024
1 parent 7ca58a0 commit 68ac9bc
Show file tree
Hide file tree
Showing 11 changed files with 1,288 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-planets-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"strapi-cms": minor
---

Add Product schema and productsShowcase component to homepage in Strapi CMS
10 changes: 10 additions & 0 deletions apps/strapi-cms/.env.default
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ API_TOKEN_SALT=tobemodified
ADMIN_JWT_SECRET=tobemodified
TRANSFER_TOKEN_SALT=tobemodified
JWT_SECRET=tobemodified

UPLOAD_PLUGIN_PROVIDER=local

# if UPLOAD_PLUGIN_PROVIDER == 'aws-s3'
AWS_ACCESS_KEY_ID=
AWS_ACCESS_SECRET=
AWS_BUCKET_ENDPOINT=
AWS_BUCKET_NAME=
AWS_BUCKET_FULL_URL=
CDN_URL=
20 changes: 20 additions & 0 deletions apps/strapi-cms/config/plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default ({ env }: any) => ({
upload: {
config: {
provider: env('UPLOAD_PLUGIN_PROVIDER', 'aws-s3'),
providerOptions: {
baseUrl: env('CDN_URL'),
s3Options: {
accessKeyId: env('AWS_ACCESS_KEY_ID'),
secretAccessKey: env('AWS_ACCESS_SECRET'),
endpoint: env('AWS_BUCKET_ENDPOINT'),
params: {
ACL: 'private',
signedUrlExpires: 15 * 60,
Bucket: env('AWS_BUCKET_NAME'),
},
}
},
},
},
});
1 change: 1 addition & 0 deletions apps/strapi-cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dependencies": {
"@strapi/plugin-i18n": "4.19.0",
"@strapi/plugin-users-permissions": "4.19.0",
"@strapi/provider-upload-aws-s3": "^4.20.1",
"@strapi/strapi": "4.19.0",
"better-sqlite3": "8.6.0",
"react": "^18.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,37 @@
"info": {
"singularName": "homepage",
"pluralName": "homepages",
"displayName": "Homepage"
"displayName": "Homepage",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"pluginOptions": {
"i18n": {
"localized": true
}
},
"attributes": {
"productsShowcase": {
"type": "component",
"repeatable": false,
"component": "products.products-showcase",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"comingsoonDocumentation": {
"type": "component",
"repeatable": false,
"component": "common.related-links"
"component": "common.related-links",
"pluginOptions": {
"i18n": {
"localized": true
}
}
}
}
}
61 changes: 61 additions & 0 deletions apps/strapi-cms/src/api/product/content-types/product/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"kind": "collectionType",
"collectionName": "products",
"info": {
"singularName": "product",
"pluralName": "products",
"displayName": "Product",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {
"i18n": {
"localized": true
}
},
"attributes": {
"name": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "string",
"required": true,
"unique": true
},
"description": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "text"
},
"logo": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images"
],
"pluginOptions": {
"i18n": {
"localized": false
}
}
},
"slug": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "string",
"required": true,
"unique": true
}
}
}
7 changes: 7 additions & 0 deletions apps/strapi-cms/src/api/product/controllers/product.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* product controller
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreController('api::product.product');
7 changes: 7 additions & 0 deletions apps/strapi-cms/src/api/product/routes/product.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* product router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::product.product');
7 changes: 7 additions & 0 deletions apps/strapi-cms/src/api/product/services/product.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* product service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::product.product');
19 changes: 19 additions & 0 deletions apps/strapi-cms/src/components/products/products-showcase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"collectionName": "components_products_products_showcases",
"info": {
"displayName": "ProductsShowcase",
"icon": "oneToMany"
},
"options": {},
"attributes": {
"title": {
"type": "string",
"required": true
},
"products": {
"type": "relation",
"relation": "oneToMany",
"target": "api::product.product"
}
}
}
Loading

0 comments on commit 68ac9bc

Please sign in to comment.