@creative-web-solution/express-layer-remote-api
v0.0.5
Published
Plugins to allow access to clear the cache, view and clear logs.
Readme
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-apiThen, 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 tokentremote_access_method=> the http method to access the api:get,restorpost
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/someactionpost=>https://yourdomain/api/tools/someaction+ atokenfield in the post body.
Url display
You can see all generated urls in the console with the command:
npm run console exportRemoteAPIUrlYou can also generate a small HTML code that you can save in a .html file :
npm run console exportRemoteAPIUrl -- --htmlIf 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=> Emptypublic/assets/js_config/{token}/api/tools/clearcache?args=back=> Emptyvar/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/loghttps://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
