all repos — caroster @ locales-mdraps

[Octree] Group carpool to your event https://caroster.io

backend/src/index.ts (view raw)

 1import bootstrapActions from "./bootstrap";
 2import graphqlExtends from "./graphql";
 3import userLifecycles from "./extensions/users-permissions/content-types/user/lifecycles";
 4
 5export default {
 6  /**
 7   * An asynchronous register function that runs before
 8   * your application is initialized.
 9   *
10   * This gives you an opportunity to extend code.
11   */
12  register(context) {
13    graphqlExtends(context);
14
15    // Because of bug https://github.com/strapi/strapi/issues/17995, we're forced
16    // to enable "plugin::users-permissions.user" permission for Authenticated role.
17    // Disable REST endpoints
18    context.strapi.controller("plugin::users-permissions.user").find = (ctx) =>
19      ctx.unauthorized();
20    context.strapi.controller("api::event.event").find = (ctx) =>
21      ctx.unauthorized();
22    // Disable GQL methods
23    strapi
24      .plugin("graphql")
25      .service("extension")
26      .shadowCRUD("plugin::users-permissions.user")
27      .disableAction("find");
28    strapi
29      .plugin("graphql")
30      .service("extension")
31      .shadowCRUD("api::event.event")
32      .disableAction("find");
33  },
34
35  /**
36   * An asynchronous bootstrap function that runs before
37   * your application gets started.
38   *
39   * This gives you an opportunity to set up your data model,
40   * run jobs, or perform some special logic.
41   */
42  async bootstrap(context) {
43    for (let action of bootstrapActions) {
44      await action(context);
45    }
46
47    strapi.db.lifecycles.subscribe({
48      models: ["plugin::users-permissions.user"],
49      ...userLifecycles,
50    });
51  },
52};