MavonEngine 0.0.20-alpha: queues, mail, notifications and email for auth
This release gives the game server a job queue and builds mail and notifications on top of it. The auth plugin can now confirm emails and reset forgotten passwords.
Packages
@mavonengine/core 0.0.25
@mavonengine/cli 0.0.6
@mavonengine/auth 0.0.2
@mavonengine/mail 0.0.1 (new)
@mavonengine/notifications 0.0.1 (new)
- Multiplayer template 0.0.8, which
create now uses
Job queue (core)
The server has a job queue for work that shouldn't hold up the game. Jobs are retried when they fail, and you can keep them in memory or in the database. The dashboard's overview graphs the queue.
New: @mavonengine/mail
Send mail from the game server: welcome mails, password resets, receipts. Mail goes on the queue and is tried again when the mail server is down. Until you set up a transport, mail is written to the server log, so you can build and test mail in development without an account anywhere.
await ctx.plugin('@mavonengine/mail')?.to(order.email).send(new Receipt(order))
Mails are classes (Mailable) and go out in a layout your project can change.
New: @mavonengine/notifications
Notify players, and anything else you make notifiable, in the game and by mail:
await player.notify(new LevelUp(5))
await notify(account(accountId), new SeasonEnded()) // connected or not
A notification says which channels it goes to (via()) and what it says on each (toGame(), toMail()). Notifications are kept in the database so players can read them later. player.notify() is part of the engine, so your game's code can use it before you install the plugin.
Auth: confirm emails and reset passwords
With the mail plugin installed, auth:
- mails a link to confirm an account's email when it registers or changes it
- lets players reset a forgotten password through a link mailed to them
- limits how many mails one address gets, so nobody can fill an inbox through your game
The links open pages the plugin ships with, or your game's own pages through verifyUrl and resetUrl.
Project settings
mavonengine.json takes a few project-wide settings next to plugins:
appUrl: where your game lives. Links in mails point there, and MAVONENGINE_APP_URL overrides it per deployment.
appName: your game's name, used in mails and in the browser tab (%MAVONENGINE_APP_NAME% in index.html). create now fills it in from the project name.
database, auth and notifications: which plugin to use when more than one of a kind is enabled.
Plugins
- Plugins can use each other's API with
ctx.plugin('<package>'), which is how notifications reaches mail and auth's hooks reach other plugins.
mavonengine asset:publish <plugin> copies the files a plugin lets you customise, such as the mail layout, into resources/ in your project. The plugin uses your copy from then on.
Upgrading
npm i @mavonengine/core@0.0.25 -D @mavonengine/cli@0.0.6
npx @mavonengine/cli install @mavonengine/mail
npx @mavonengine/cli install @mavonengine/notifications
auth 0.0.2 needs core 0.0.25 or newer. New projects get all of this with npx @mavonengine/create-bootstrap.