Skip to content

Commit

Permalink
Merge pull request #8 from calimania/feat/markket-content-type
Browse files Browse the repository at this point in the history
created markket content type and associated resources
  • Loading branch information
dvidsilva authored Jan 3, 2025
2 parents a58fd45 + bedff94 commit 2ea29f9
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/api/markket/content-types/markket/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"kind": "collectionType",
"collectionName": "markkets",
"info": {
"singularName": "markket",
"pluralName": "markkets",
"displayName": "Markket",
"description": "Instance of a markket - usage records"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"Key": {
"type": "string",
"required": true
},
"Content": {
"type": "json",
"required": true
},
"user_key_or_id": {
"type": "string",
"required": false
}
}
}
45 changes: 45 additions & 0 deletions src/api/markket/controllers/markket.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* markket controller
*/
import { version } from '../../../../package.json';
const { createCoreController } = require('@strapi/strapi').factories;
const modelId = "api::markket.markket";

const NODE_ENV = process.env.NODE_ENV || 'development';
const STRIPE_PUBLIC_KEY = process.env.STRIPE_PUBLIC_KEY || 'n/a';
const SENDGRID_REPLY_TO_EMAIL = process.env.SENDGRID_REPLY_TO_EMAIL || 'n/a';

module.exports = createCoreController(modelId, ({ strapi }) => ({
async about(ctx: any) {
console.info('markket.get');
ctx.send({
message: 'This is the about endpoint',
data: {
info: 'Markket.place is an international commercial community',
version,
NODE_ENV,
STRIPE_PUBLIC_KEY,
SENDGRID_REPLY_TO_EMAIL,
},
});
},
async create(ctx: any) {
console.info('markket.create');
await strapi.service(modelId).create({
locale: 'en',
data: {
Key: "markket.create",
Content: ctx.request.body,
user_key_or_id: "", // @TODO: Review authorization, token or related user
}
});
// @TODO: send notification emails, perform STRIPE actions, etc, here
ctx.send({
message: 'This is the create endpoint',
data: {
info: 'Markket.place is an international commercial community',
version,
},
});
}
}));
26 changes: 26 additions & 0 deletions src/api/markket/routes/markket.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Markket router
*/

module.exports = {
routes: [
{
method: 'GET',
path: '/markket',
handler: 'markket.about',
config: {
policies: [],
middlewares: [],
},
},
{
method: 'POST',
path: '/markket',
handler: 'markket.create',
config: {
policies: [],
middlewares: [],
},
}
],
};
7 changes: 7 additions & 0 deletions src/api/markket/services/markket.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* markket service
*/

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

export default factories.createCoreService('api::markket.markket');
3 changes: 3 additions & 0 deletions src/components/common/seo.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
"metaUrl": {
"type": "string"
},
"metaDate": {
"type": "datetime"
},
"metaAuthor": {
"type": "string"
},
Expand Down
1 change: 1 addition & 0 deletions types/generated/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export interface CommonSeo extends Struct.ComponentSchema {
excludeFromSearch: Schema.Attribute.Boolean &
Schema.Attribute.DefaultTo<false>;
metaAuthor: Schema.Attribute.String;
metaDate: Schema.Attribute.DateTime;
metaDescription: Schema.Attribute.String;
metaKeywords: Schema.Attribute.String;
metaTitle: Schema.Attribute.String;
Expand Down
32 changes: 32 additions & 0 deletions types/generated/contentTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,37 @@ export interface ApiInboxInbox extends Struct.CollectionTypeSchema {
};
}

export interface ApiMarkketMarkket extends Struct.CollectionTypeSchema {
collectionName: 'markkets';
info: {
description: 'Instance of a markket - usage records';
displayName: 'Markket';
pluralName: 'markkets';
singularName: 'markket';
};
options: {
draftAndPublish: true;
};
attributes: {
Content: Schema.Attribute.JSON & Schema.Attribute.Required;
createdAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
Key: Schema.Attribute.String & Schema.Attribute.Required;
locale: Schema.Attribute.String & Schema.Attribute.Private;
localizations: Schema.Attribute.Relation<
'oneToMany',
'api::markket.markket'
> &
Schema.Attribute.Private;
publishedAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
user_key_or_id: Schema.Attribute.String;
};
}

export interface ApiOrderOrder extends Struct.CollectionTypeSchema {
collectionName: 'orders';
info: {
Expand Down Expand Up @@ -1473,6 +1504,7 @@ declare module '@strapi/strapi' {
'api::category.category': ApiCategoryCategory;
'api::extension.extension': ApiExtensionExtension;
'api::inbox.inbox': ApiInboxInbox;
'api::markket.markket': ApiMarkketMarkket;
'api::order.order': ApiOrderOrder;
'api::page.page': ApiPagePage;
'api::product.product': ApiProductProduct;
Expand Down

0 comments on commit 2ea29f9

Please sign in to comment.