[Proposal] add __frontity_info endpoint in server application

Description

We should add an /__frontity_info endpoint in the Frontity server with information about the setup could be added for debugging purposes and to display project data in the/a Frontity WP Plugin.

The data could be similar to the output of npx frontity info, although for security reasons this has to be reviewed, and additional data can be added.

Examples

The endpoint can be used in the WP Frontity plugin to display information about the project. This could help with monitoring the website from WP Admin and debugging issues. Also update notices of packages could be tracked (using npm-check-updates for example).

Also for issues posted here it could be a good alternative to asking people to dump npx frontity info, especially for less tech-savy members.

Functionalities

The endpoint should gather information about the server (envinfo), the project (frontity.settings.js) and installed packages (package.json), and return this as a JSON object.

For security reasons it should be possible to enable/disable the endpoint.
Additionally settings could be used to manage which data is visible or even limit by domain/IP.

Although since this might be slow (eg. envinfo can take some time) a solution could be to dump static data when building the project, since most variables won’t change.

Requirements

none at this time

Dependencies

none (unless major server-side changes are planned, which I couldn’t find)

Possible solution

Quick and dirty implementation:

// in https://github.com/frontity/frontity/blob/dev/packages/core/src/server/index.ts
const returnInfo = () => {
   let data = {};
   // fill data with `envinfo`
   // fill data with frontity.settings.js information
   // fill data with package.json information
   // ... more info?
   return data;
};
app.use(get("/__frontity_info", returnInfo));

As mentioned in the Functionalities, a cached dump could be created at dev/build with Webpack which gets imported and returned when accessing the endpoint.