This repository was archived by the owner on Sep 17, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +28
-12
lines changed Expand file tree Collapse file tree 7 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ interface LobbyListEntry {
1919 id : string ;
2020 version : string ;
2121 tags : Record < string , string > ;
22+ createdAt : string ;
23+ players : number ;
24+ maxPlayers : number ;
25+ maxPlayersDirect : number ;
2226}
2327
2428export async function run (
@@ -46,11 +50,11 @@ export async function run(
4650 id : lobby . id ,
4751 version : lobby . version ,
4852 tags : lobby . tags ,
49- createdAt : lobby . createdAt ,
53+ createdAt : new Date ( lobby . createdAt ) . toISOString ( ) ,
5054 players : lobby . players ,
5155 maxPlayers : lobby . maxPlayers ,
5256 maxPlayersDirect : lobby . maxPlayersDirect ,
53- } ) ) ;
57+ } satisfies LobbyListEntry ) ) ;
5458
5559 return { lobbies : lobbyList } ;
5660}
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ test("lobby tags", async (ctx: TestContext) => {
8282 {
8383 version : VERSION ,
8484 region : REGION ,
85- tags : { gameMode : "a" , region : "atl" } ,
85+ tags : { gameMode : "a" } ,
8686 players : [ { } ] ,
8787 maxPlayers : 8 ,
8888 maxPlayersDirect : 8 ,
Original file line number Diff line number Diff line change 11import { ScriptContext , Database , Query } from "../module.gen.ts" ;
2- import { TokenWithSecret , tokenFromRow } from "../utils/types.ts" ;
2+ import { TokenWithSecret , tokenFromRow , tokenWithSecretFromRow } from "../utils/types.ts" ;
33
44export interface Request {
55 type : string ;
@@ -28,7 +28,7 @@ export async function run(
2828 . returning ( ) ;
2929
3030 return {
31- token : tokenFromRow ( rows [ 0 ] ! ) ,
31+ token : tokenWithSecretFromRow ( rows [ 0 ] ! ) ,
3232 } ;
3333}
3434
Original file line number Diff line number Diff line change 11import { ScriptContext , Query , Database } from "../module.gen.ts" ;
2- import { tokenFromRow , TokenWithSecret } from "../utils/types.ts" ;
2+ import { tokenFromRow , TokenWithSecret , tokenWithSecretFromRow } from "../utils/types.ts" ;
33
44export interface Request {
55 token : string ;
@@ -27,6 +27,6 @@ export async function run(
2727
2828 // Return the updated token
2929 return {
30- token : tokenFromRow ( rows [ 0 ] ! ) ,
30+ token : tokenWithSecretFromRow ( rows [ 0 ] ! ) ,
3131 } ;
3232}
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export interface Request {
55}
66
77export interface Response {
8- updates : { [ key : string ] : TokenUpdate } ;
8+ updates : Record < string , TokenUpdate > ;
99}
1010
1111export enum TokenUpdate {
Original file line number Diff line number Diff line change 33 assertEquals ,
44 assertGreater ,
55 assertRejects ,
6- } from "https://deno.land/std@0.217.0/assert/mod.ts" ;
6+ } from "jsr:@std/assert" ;
7+ import { omit } from "jsr:@std/collections" ;
78
89test (
910 "validate token not found" ,
9596 ...validateResAfterWait . token ,
9697 expireAt : null ,
9798 } , {
98- ...token ,
99+ ...omit ( token , [ "token" ] ) ,
99100 expireAt : null ,
100101 } ) ;
101102 } ,
Original file line number Diff line number Diff line change @@ -15,11 +15,22 @@ export interface TokenWithSecret extends Token {
1515
1616export function tokenFromRow (
1717 row : typeof Database . tokens . $inferSelect
18- ) : TokenWithSecret {
18+ ) : Token {
1919 return {
20- ...row ,
20+ id : row . id ,
21+ type : row . type ,
22+ meta : row . meta ,
2123 createdAt : row . createdAt . toISOString ( ) ,
2224 expireAt : row . expireAt ?. toISOString ( ) ?? null ,
2325 revokedAt : row . revokedAt ?. toISOString ( ) ?? null ,
2426 } ;
2527}
28+
29+ export function tokenWithSecretFromRow (
30+ row : typeof Database . tokens . $inferSelect
31+ ) : TokenWithSecret {
32+ return {
33+ ...tokenFromRow ( row ) ,
34+ token : row . token ,
35+ } ;
36+ }
You can’t perform that action at this time.
0 commit comments