Custom plugin's server API doesn't work

System Information
  • Strapi Version: 4.21.1
  • Operating System: MacOs Ventura
  • Database: SQLite
  • Node Version: 18.20.0
  • NPM Version: 10.5.0
  • Yarn Version:

Hello everyone, I’ve recently came across a problem with developing Server API of a custom plugin. It seems that Strapi doesn’t add the plugin’s API to the project. Thus, plugin’s routes and lifecycle functions don’t work. If I try to request a default route localhost:1337/{pluginName} it sends code 404 back. I also tried to use logging to check if the server side works. That’s how I realised that lifecycle functions also don’t work

How can I solve the issue? How to enable a plugin send me proper responses from the specified routes? What should I do to make lifecycle functions of the Server API work?

I would be pleasant if somebody helps me

I’ve already made some attempts to fix the trouble. That’s what I’ve done:

  1. Rebuild project in the plugin`s route with npm run build
  2. Send request to some routes such as localhost:1337/api/{pluginName} and etc.
  3. Tried to log data from server side with strapi.log.debug()

My code
strapi-server.js

"use strict"

module.exports = () => ({
  register({ strapi }) {
    strapi.log.debug('success')
  },
  bootstrap({ strapi }) {
  },
})

routes/index.ts

export default [
  {
    method: 'GET',
    path: '/test',
    handler: 'myController.index',
    config: {
      policies: [],
      middlewares: [],
    },
  },
];

controllers/my-controller.ts

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

export default ({ strapi }: { strapi: Strapi }) => ({
  index(ctx) {
    console.log('test')
    strapi.log.debug('TEST')
    ctx.body = strapi
      .plugin('strapi-data-upload')
      .service('myService')
      .getWelcomeMessage();
    ctx.send({ status: 200 })
  },
});