I am a noob to nakama so please be patient.
I just completed the getting started tutorial for typescript and the nakama server. With some amendments I was able to get it to print the “Hello World” message to the console on startup with docker compose.
I am having difficulty when I try to add event handlers.
Here is the init code I’ve created:
let InitModule: nkruntime.InitModule =
function(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, initializer: nkruntime.Initializer) {
logger.info("Hello World!");
const registerBeforeAuthenticateEmail: nkruntime.BeforeHookFunction<nkruntime.AuthenticateEmailRequest> = (ctx, logger, nk, req) => {
logger.info(`login received ${req.username}`)
}
initializer.registerBeforeAuthenticateEmail(registerBeforeAuthenticateEmail)
}
I see the following error on startup
nakama_1 | {"level":"info","ts":"2022-01-01T12:44:35.106Z","caller":"server/runtime.go:697","msg":"Registered JavaScript runtime Before function invocation","id":"authenticateemail"}
And then the following error on login:
nakama_1 | {"level":"error","ts":"2022-01-01T12:49:56.427Z","caller":"server/runtime_javascript.go:348","msg":"JavaScript runtime function invalid.","key":"registerBeforeAuthenticateEmail"}
I wonder could someone help me with understanding how to proceed from here.