Hello,
We are using Nakama with Typescript (with rollup configured) and we are having a hard time adding external libs to Nakama. I’m trying to find a schema validator that I can use to validate that the JSON payload is correct, and I tried several libs already zod
, ajv
, etc. None of them seems to work, I keep receiving some crazy errors like Cannot assign to read only property 'opts'
. The weird thing here is that if I add the piece of code to the entrypoint server.ts
, it works fine. If I add the same piece of code to the RPC function, it fails with the error above. I added a snippet with an example of the code I’m trying to use.
- Versions: Nakama 3.12, Docker
- Server Framework Runtime language: Typescript
import Ajv from 'ajv';
const ajv = new Ajv({ logger: false });
const schema = {
type: 'object',
properties: {
foo: { type: 'integer' },
bar: { type: 'string' },
},
required: ['foo'],
additionalProperties: false,
};
ajv.validate(schema, {});
Media: