@playcademy/vite-plugin 0.0.1-beta.26 → 0.0.1-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +23 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -118033,6 +118033,28 @@ async function generateRealtimeToken(ctx) {
|
|
|
118033
118033
|
throw ApiError.internal("Internal server error", error2);
|
|
118034
118034
|
}
|
|
118035
118035
|
}
|
|
118036
|
+
async function generateSandboxRealtimeToken(ctx) {
|
|
118037
|
+
const gameIdOrSlug = ctx.params?.gameId;
|
|
118038
|
+
const db = getDatabase();
|
|
118039
|
+
let resolvedGameId = gameIdOrSlug;
|
|
118040
|
+
if (gameIdOrSlug && db) {
|
|
118041
|
+
const isUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(gameIdOrSlug);
|
|
118042
|
+
if (!isUuid) {
|
|
118043
|
+
const game = await db.query.games.findFirst({
|
|
118044
|
+
where: eq(games.slug, gameIdOrSlug),
|
|
118045
|
+
columns: { id: true }
|
|
118046
|
+
});
|
|
118047
|
+
if (game) {
|
|
118048
|
+
resolvedGameId = game.id;
|
|
118049
|
+
}
|
|
118050
|
+
}
|
|
118051
|
+
}
|
|
118052
|
+
const newCtx = {
|
|
118053
|
+
...ctx,
|
|
118054
|
+
params: { ...ctx.params, gameId: resolvedGameId }
|
|
118055
|
+
};
|
|
118056
|
+
return generateRealtimeToken(newCtx);
|
|
118057
|
+
}
|
|
118036
118058
|
|
|
118037
118059
|
class BigEndian {
|
|
118038
118060
|
uint8(data, offset) {
|
|
@@ -119003,7 +119025,7 @@ gamesRouter.post("/:gameId/realtime/token", async (c2) => {
|
|
|
119003
119025
|
request: c2.req.raw
|
|
119004
119026
|
};
|
|
119005
119027
|
try {
|
|
119006
|
-
const result = await
|
|
119028
|
+
const result = await generateSandboxRealtimeToken(ctx);
|
|
119007
119029
|
return c2.json(result);
|
|
119008
119030
|
} catch (error2) {
|
|
119009
119031
|
if (error2 instanceof ApiError) {
|