Flatten lib namespace

Move all functions and classes currently available through lib/name and
libName to be under a single flat namespace in lib.  This make
reorganising the lib namespace much simpler as the location of symbols
can move without breaking the consumers of lib.

The multi-entrypoint design was already problematic for the web plugin
system which couldn't effectively use it due to how webpack's shared
module system is awkward to set up with multiple entrypoints per package.
This commit is contained in:
Hornwitser committed 2023-07-28 16:03:29 +02:00
1 parent bb58670597
commit bfe119eaa3
143 files changed
+1798 -1918

No files matched your search

+5 -6
View File
@@ -7,9 +7,8 @@ const express = require("express");
const util = require("util");
const jwt = require("jsonwebtoken");
const libPlugin = require("@clusterio/lib/plugin");
const libErrors = require("@clusterio/lib/errors");
const { basicType } = require("@clusterio/lib/helpers");
const lib = require("@clusterio/lib");
const { basicType } = lib;
const { FetchPlayerCodeRequest, SetVerifyCodeRequest } = require("./messages");
@@ -30,7 +29,7 @@ async function generateCode(length) {
}
class ControllerPlugin extends libPlugin.BaseControllerPlugin {
class ControllerPlugin extends lib.BaseControllerPlugin {
async init() {
// Store of validation attempts by players
this.players = new Map();
@@ -174,12 +173,12 @@ class ControllerPlugin extends libPlugin.BaseControllerPlugin {
async handleSetVerifyCodeRequest(request) {
let { player, verifyCode } = request;
if (!this.players.has(player)) {
throw new libErrors.RequestError("invalid player");
throw new lib.RequestError("invalid player");
}
let entry = this.players.get(player);
if (entry.expires < Date.now()) {
throw new libErrors.RequestError("invalid player");
throw new lib.RequestError("invalid player");
}
entry.verifyCode = verifyCode;