import { hooks } from "@colyseus/social";
hooks.beforeAuthenticate((provider, $setOnInsert, $set) => {
// assign default metadata upon registration
$setOnInsert = {
metadata: {
coins: 100,
trophies: 0
}
};
});
hooks.beforeUserUpdate((_id, fields) => {
if (fields['username']) {
if (fields['username'] === "bad word!") {
throw new Error("can't have bad words!");
}
}
})
MONGO_URI
: MongoDB connection URIJWT_SECRET
: Secure secret string for authentication.FACEBOOK_APP_TOKEN
: Facebook App Token ("appid|appsecret"
)WEBPUSH_SUBJECT
- mailto: or URL.WEBPUSH_PUBLIC_KEY
- VAPID Public KeyWEBPUSH_PRIVATE_KEY
- VAPID Private KeyYou can generate VAIPD keys using npx web-push generate-vapid-keys
import express from "express";
import socialRoutes from "@colyseus/social/express"
const app = express();
app.use("/", socialRoutes);
app.listen(8080);
MIT License.