Lattyware/massivedecks

Cannot generate secret

Opened this issue · 5 comments

Describe the bug

Cannot generate secret for new deployment of massivedecks

How to reproduce the bug

I am trying to deploy a new instance of massivedecks to my private server via docker.

I have pulled a complete copy of md from Git Hub. In addition, I have put a copy of compose.yml from massivedecks/deployment
/memory/ into /md.

When I attempt to generate a new secret for config.json5 I get an error from the npm command:

_npm run generate-secret_

> @massivedecks/server@2.0.0 generate-secret
> npm run prestart && node dist/secret.js


> @massivedecks/server@2.0.0 prestart
> npm run build


> @massivedecks/server@2.0.0 build
> npx tsc

src/ts/action/validation.validator.ts:16:24 - error TS2351: This expression is not constructable.
  Type 'typeof import("/md/server/node_modules/ajv/dist/ajv")' has no construct signatures.

16 export const ajv = new Ajv({
                          ~~~

src/ts/action/validation.validator.ts:21:1 - error TS2349: This expression is not callable.
  Type 'typeof import("/md/server/node_modules/ajv-formats/dist/index")' has no call signatures.

21 addFormats(ajv, { mode: "full" });
   ~~~~~~~~~~

src/ts/caches/postgres.ts:209:11 - error TS18047: 'result.rowCount' is possibly 'null'.

209       if (result.rowCount > 0) {
              ~~~~~~~~~~~~~~~

src/ts/caches/postgres.ts:241:11 - error TS18047: 'about.rowCount' is possibly 'null'.

241       if (about.rowCount > 0 && about.rows[0]["cards_updated"] !== undefined) {
              ~~~~~~~~~~~~~~

src/ts/store/postgres.ts:138:5 - error TS2322: Type 'number | null' is not assignable to type 'number'.
  Type 'null' is not assignable to type 'number'.

138     return await this.pg.withClient(async (client) => {
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139       const result = await client.query(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... 
147       return result.rowCount;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
148     });
    ~~~~~~~

src/ts/store/postgres.ts:243:11 - error TS18047: 'get.rowCount' is possibly 'null'.

243       if (get.rowCount < 1) {
              ~~~~~~~~~~~~


Found 6 errors in 3 files.

Errors  Files
     2  src/ts/action/validation.validator.ts:16
     2  src/ts/caches/postgres.ts:209
     2  src/ts/store/postgres.ts:138

Expected behaviour

I'm pretty sure that I am supposed to get a message to the effect of "Your secret is ..."

I have a fix for the error with "export const ajv = new Ajv", which is to use "export const ajv = new Ajv.default"

Apologies for the delay here, I'd suggest just generating a secret another way (any secure way of generating a random string) for now, and seeing if things work otherwise. This should be fixed with the next version, but no specific timeline on that right now.

Apologies for the delay here, I'd suggest just generating a secret another way (any secure way of generating a random string) for now, and seeing if things work otherwise. This should be fixed with the next version, but no specific timeline on that right now.

First and foremost, thank you for taking the time to reply, but could you please reread my message -- I am getting errors on what should be fairly innocuous Typescript code. The comment about the Secret was meant as sarcasm. TY!

Apologies for the delay here, I'd suggest just generating a secret another way (any secure way of generating a random string) for now, and seeing if things work otherwise. This should be fixed with the next version, but no specific timeline on that right now.

First and foremost, thank you for taking the time to reply, but could you please reread my message -- I am getting errors on what should be fairly innocuous Typescript code. The comment about the Secret was meant as sarcasm. TY!

Yes, I could be wrong but I believe this is probably an error due to an incorrect tsconfig when running specifically to generate secrets, I believe it may work if you do a normal build, as the build did run through when the commit was made for the image. If not I'll have to take another look, although like I say this has all changed with the next version so whenever that comes it should fix things.

Good morning and thank you (again) for writing back, but I am concerned there is a disconnect between our understanding here.

In the course of generating a secret to run massive decks, a script is executed with three steps (or I should more correctly say, the script fails on the third step):

npm run prestart && node dist/secret.js npm run build npx tsc

I receive four errors on this last step:

`src/ts/action/validation.validator.ts:13:24 - error TS2351: This expression is not constructable.
Type 'typeof import("/md/server/node_modules/ajv/dist/ajv")' has no construct signatures.

13 export const ajv = new Ajv({
~~~

src/ts/action/validation.validator.ts:18:1 - error TS2349: This expression is not callable.
Type 'typeof import("/md/server/node_modules/ajv-formats/dist/index")' has no call signatures.

18 addFormats(ajv, { mode: "full" });


src/ts/games/cards/sources/json-against-humanity.ts:239:28 - error TS2339: Property 'get' does not exist on type 'typeof import("/md/server/node_modules/axios/index")'.

239   const data = await Axios.get("", httpConfig);
                            ~~~

src/ts/games/cards/sources/many-decks.ts:154:35 - error TS2339: Property 'create' does not exist on type 'typeof import("/md/server/node_modules/axios/index")'.

154         create: async () => Axios.create(httpConfig),
                                   ~~~~~~


Found 4 errors in 3 files.

Errors  Files
  2  src/ts/action/validation.validator.ts:13
  1  src/ts/games/cards/sources/json-against-humanity.ts:239
  1  src/ts/games/cards/sources/many-decks.ts:154`

Here is my tsconfig.json file in /md/server

```
{
"$schema": "https://json.schemastore.org/tsconfig",

"include": ["src/**/*"],

"compilerOptions": {
 "lib": ["es2022"],
 "module": "nodenext",
 "target": "es2022",
 "moduleResolution": "nodenext",

 "sourceMap": true,
 "rootDir": "src/ts",
 "outDir": "dist",
 "removeComments": true,
 "newLine": "lf",

 "strict": true,
 "esModuleInterop": true,
 "skipLibCheck": true,
 "forceConsistentCasingInFileNames": true,
 "allowUnusedLabels": false,
 "noFallthroughCasesInSwitch": true,
 "noImplicitOverride": true,
 "noImplicitReturns": true,
 "noPropertyAccessFromIndexSignature": true,
 "noUncheckedIndexedAccess": true,
 "importsNotUsedAsValues": "error",
 "checkJs": true
}
}
```
It seems fairly innocuous to me.  Furthermore, it is (or should be) unchanged from the pull off of github.

FYSA, I am building this on a Raspberry Pi 4 I have lying around.