The default limit of 100kb to JSON payloads of bodyParser can be
exceeded when running modded games with researchSync. Increase the
limit to 10mb as a bandaid to fix this issue.
This is a port of 25eb5e5.
Move item database, tests, endpoint definitions for /api/place,
/api/remove, /api/inventory, /api/inventoryAsObject, and the web
interface view for the storage page into the clusterioMod plugin.
Remove the .js suffix from help texts of node invocations as well as
actual invocations as this is not necessary. Removing it opens up the
possibility of restructuring the code into a directory with the same
name.
Move getFactorioLocale to the new lib/factorio namespace and refactor it
to use async functions instead of callbacks. Split tests into
integration with factorio and testing of the function itself.
Also removes the cacheing from the function itself as this breaks the
isolated testing of it.
Move the ejs templates to the default Express.js views/ folder and
change their extension to .ejs. Reconfigure Express.js to look for
templates in the views folders as well as the plugins folder. This
enables plugins to render templates using paths of following format
"pluginName/path/to/page-or-view".
After 651b09b the instance ID would be treated differently depending on
wheteher it was a string or a number in the master server. This caused
researchSync to break as it would send the ID as a number while the
master server would have it stored as a string.
Fix by coercing instanceID to a string in the master HTTP API.
Authenticate connections made to the socket.io server via a token query
parameter that's validated in a similar manner to the x-access-token for
HTTP requests.
This is a port of 0c45e57.
Change the ugly global slaves object to be a member of the db object and
implement the items database as a separate integrety verifying class in
lib/database.
Add missing attach calls to the master socket.io object that was
accidentally removed by the refactoring in a3fc1dd. Unfortunately I've
been unable to determine if socket.io actually supports listening on
multiple servers at the same time, this needs further investigation.
Add StartupError that differentiates unhandled errors from errors with
known causes and use it to only print the "please report" banner when an
unhandled error occurs.
Also makes the error reporting more visible in the console.
Remove remoteMap specific code left behind after the removal of the
remoteMap plugin in 6415784. The plugin interface should be versatile
enough to allow all of this code to reside inside the plugin itself.
Remove code pushing metrics to a hardcoded Prometheus pushgateway that
is no longer in operation. There's no point supporting the use of a
pushgateway as there's already a full client implemented and since the
master server is not ephemeral or batch job it shouldn't be using a
pushgateway in the first place.
Rewrite the generateSSLcert lib to be async, use the sslCert and
sslPrivKey config entries and invoke it only if needed during master
server startup instead of in the post install script. Also add note to
the changelog covering both this and the fix in c645fac.
Move server initialization code to startServer and call it only when
master.js is being runned directly. Also refactor the server listen
step to work properly when https is configured and only listen after
plugins have completed loading.
Remove the async function wrapper around the master.js code. This is
just dumb and makes the code untestable.
The masterPlugins array should not be a global. The ejs templates
already have it provided through locals.masterPlugins and plugins get it
through onLoadFinish. Make masterPlugins local to master.js again and
fix the ejs templates to use locals.masterPlugins.
This saved 30ms of the startup on my machine. Even if it saved a second
it's still pretty pointless as we're not depending on the master server
startup being super fast.
Move the contents of node_modules/_app into lib/ as there shouldn't be
any content in node_modules. This directory is automatically managed
and pruned by npm.
Add lib/ as a local package in package.json, this allows scripts
everywhere to require it's content as "lib/path" instead of relying on
local paths. This shadows the StdLib Node.js Bindings package, but I
could care less.
Change all requires with lib as a local path and _app to use just lib.
#add tailing of files to prevent lost data between factorio and clusterio
#move socketio connect to the bottom after the plugins are loaded to prevent plugins not getting the connection event
according to the docs
"The methods on the response object (res) in the following table can send a response to the client, and terminate the request-response cycle. If none of these methods are called from a route handler, the client request will be left hanging."
Last sentence is the critical one.
Sending a status code 200 should fix the issue