0.0.5 • Published 10 months ago

@creative-web-solution/express-layer-remote-api v0.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Remote API

Plugins to allow access to clear the cache, view and clear logs directly from some html pages.

This plugin only works with ExpressLayer.

Install

Install package:

npm install @creative-web-solution/express-layer-remote-api

Then, in the expressLayerConfiguration.ts of your project:

import RemoteApiFactory from "@creative-web-solution/express-layer-remote-api";

export const expressLayerConfiguration: ExpressLayerOptions = {
    ...,
    "addPlugins": async (expressLayer: ExpressLayer) => {
      return [new RemoteApiFactory()]
    }
};

Configuration


In the parameters.json, set:

  • remote_access_token => a secret tokent
  • remote_access_method => the http method to access the api: get, rest or post

Here the url to access the API in the different method:

  • get => https://yourdomain/api/tools/someaction?token={token}
  • rest => https://yourdomain/{token}/api/tools/someaction
  • post => https://yourdomain/api/tools/someaction + a token field in the post body.

Url display


You can see all generated urls in the console with the command:

npm run console exportRemoteAPIUrl

You can also generate a small HTML code that you can save in a .html file :

npm run console exportRemoteAPIUrl -- --html

If the remote API mode is post, it will always display the HTML code, as you can't access it with a simple url.

For simplicity, all examples below will use the rest method:

Clear cache


You can remotly clear the cache by calling: https://yourdomain/{token}/api/tools/clearcache.

  • /{token}/api/tools/clearcache => Clear all caches
  • /{token}/api/tools/clearcache?args=front => Empty public/assets/js_config
  • /{token}/api/tools/clearcache?args=back => Empty var/cache

Log viewer


Log table: https://yourdomain/{token}/api/tools/viewlogs

You can remotly view the application logs by calling:

  • https://yourdomain/{token}/api/tools/viewlogs/app/log
  • https://yourdomain/{token}/api/tools/viewlogs/app/exception

Clear logs


You can remotly clear the cache by calling: https://yourdomain/{token}/api/tools/clearlogs.

  • /{token}/api/tools/clearlogs => Clear all logs
  • /{token}/api/tools/clearlogs?args=app => Clear application logs
0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago