Constructors

Methods

  • You can set one or many middlewares in global scope with this method.

    Parameters

    Returns Promise<void>

    core.globalMiddleware(authMiddleware)
    core.globalMiddleware([uploadMiddleware, userMiddleware])
  • Start listening to http incoming requests

    Parameters

    • host: string = "127.0.0.1"

      server host address

    • port: number | {
          http: number;
          https: number;
      } = 8000

      server port

    • Optionalcallback: ((mode?: string) => void)

      callback a function to run after starting to listen

        • (mode?): void
        • Parameters

          • Optionalmode: string

          Returns void

    Returns Promise<void>

    core.listen("0.0.0.0", 80)
    // or
    core.listen("0.0.0.0", {
    https: 443,
    http: 80
    })
  • Loads a specified Axon plugin using the plugin loader.

    Parameters

    • plugin: AxonPlugin

      The plugin to be loaded. It should be an instance of AxonPlugin.

    Returns Promise<void>

    // this class must implements AxonPlugin type
    class MyPlugin implements AxonPlugin {
    name = "plugin"
    version = "1.0.0"

    init(core) {}
    }

    core.loadPlugin(new MyPlugin())
  • loads created routes

    Parameters

    • router: AxonRouter

      instance of Router which routes set with it.

    Returns Promise<void>

    const router = Router(); // without prefix
    const router2 = Router("/api/v1"); // with prefix

    router.get('/', async (req, res) => {});

    core.loadRoute(router);
  • unload routes based on entered parameters

    Parameters

    Returns Promise<void>

    // this one unloads a route with path `/api/v1/user`.
    core.unloadRoute({
    route: '/api/v1/user'
    });

    // this one unloads all routes with method `GET`
    core.unloadRoute({
    method: 'GET'
    });

    const userRouter = Router();

    // this one unloads all routes of userRouter.
    core.unloadRoute({
    router: userRouter
    });

    // this one unloads a route with path `/api/v1/user`, all routes with method `GET` and all routes of userRouter.
    core.unloadRoute({
    route: '/api/v1/user',
    method: "GET",
    router: userRouter
    })
  • unload all routes

    Returns Promise<void>

    core.unloadRoutes();