Skip to content

Commit

Permalink
embed calendar data as part of rse response object
Browse files Browse the repository at this point in the history
  • Loading branch information
markdturner committed Aug 27, 2024
1 parent aff653f commit d0c52ee
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 310 deletions.
20 changes: 18 additions & 2 deletions src/api/rse/controllers/rse.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,25 @@
const { createCoreController } = require('@strapi/strapi').factories

module.exports = createCoreController('api::rse.rse', ({ strapi }) => ({
calendar: async (ctx, next) => {
find: async (ctx) => {
try {
return await strapi.service('api::rse.rse').calendar(ctx.params.id, ctx.request.query)
return await strapi.service('api::rse.rse').find(ctx.request.query)
} catch (err) {
console.error(err)
return err
}
},
// Override findOne to use a filter on the find method for service code reuse
findOne: async (ctx) => {
try {
ctx.request.query.filters = { id: ctx.params.id }
const response = await strapi.service('api::rse.rse').find(ctx.request.query)
if (response.results.length === 1) {
return {
data: response.results[0],
meta: {}
}
}
} catch (err) {
console.error(err)
return err
Expand Down
9 changes: 0 additions & 9 deletions src/api/rse/routes/calendar.js

This file was deleted.

Loading

0 comments on commit d0c52ee

Please sign in to comment.