Why isn't this snippet from v3 working in v4?

I had the same problem too. This works for me:

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::post.post', ({ strapi }) =>  ({
    async create(ctx) {
        ... your code ...
    }
    async update(ctx) {
        ... your code ...
    }
}))