diff --git a/apps/scouting/backend/src/middleware/db.ts b/apps/scouting/backend/src/middleware/db.ts index 9a0d627..4bb318b 100644 --- a/apps/scouting/backend/src/middleware/db.ts +++ b/apps/scouting/backend/src/middleware/db.ts @@ -10,7 +10,57 @@ const dbName = "scouting"; const client: MongoClient = new MongoClient(url); -let db: Db | undefined = undefined; // 😭 has to happen +let /*it happen🔥: +It's always around me, all this noise +But not nearly as loud as the voice saying +"Let it happen, let it happen" (it's gonna feel so good) +"Just let it happen, let it happen" +All this running around +Tryin' to cover my shadow +A notion growing inside +Now, all the others seem shallow +All this running around +Bearing down on my shoulders +I can hear an alarm +Must be a morning +I heard about a whirlwind that's coming 'round +It's gonna carry off all that isn't bound +And when it happens, when it happens (I won't be holding on) +So, let it happen, let it happen +All this running around +I can't fight it much longer +Something's tryin' to get out +And it's never been closer +If my take-off fails +Make up some other story +If I never come back +Tell my mother I'm sorry +I cannot vanish, you will not scare me +Try to get through it, try to push through it +You were not thinking that I will not do it +They be lovin' someone and I'm another story +Take the next ticket, get the next train +Why would I do it? Anyone'd think that +I cannot vanish, you will not scare me +Try to get through it, try to push through it +You were not thinking that I will not do it +They be lovin' someone and I'm another story +Take the next ticket, get the next train +Why would I do it? Anyone'd think that +Try to get through it, try to push through it +You were not thinking that I will not do it +They be lovin' someone and I'm another story +Take the next ticket, get the next train +Why would I do it? Anyone'd think that +Baby, now I'm ready, moving on +Oh, but maybe I was ready all along +Oh, I'm ready for the moment and the sound +Oh, but maybe I was ready all along +Baby, now I'm ready, moving on +Oh, but maybe I was ready all along +Oh, I'm ready for the moment and the sound +Oh, but maybe I was ready all along*/ +db: Db | undefined = undefined; export const getDb = (): TaskEither => db diff --git a/packages/serde/serders/serde-string.ts b/packages/serde/serders/serde-string.ts index 729ff15..44641e5 100644 --- a/packages/serde/serders/serde-string.ts +++ b/packages/serde/serders/serde-string.ts @@ -10,25 +10,25 @@ export const serdeString = (): Serde => ({ serdeUnsignedInt(stringLengthBitCount).serializer( serializedData, - encodedString.length + encodedString.length, ); serializedData.insertUInt8Array( encodedString, - encodedString.length * BIT_ARRAY_LENGTH + encodedString.length * BIT_ARRAY_LENGTH, ); }, deserializer(serializedData: BitArray): string { const encodedStringLength = serdeUnsignedInt(stringLengthBitCount).deserializer(serializedData); const encodedString = serializedData.consumeBits( - encodedStringLength * BIT_ARRAY_LENGTH + encodedStringLength * BIT_ARRAY_LENGTH, ); return new TextDecoder().decode(encodedString); }, }); export const serdeEnumedString = ( - possibleValues: Options[] + possibleValues: Options[], ): Serde => { function bitsNeeded(possibleValuesCount: number): number { return Math.ceil(Math.log2(possibleValuesCount)); @@ -37,14 +37,57 @@ export const serdeEnumedString = ( serializer(serializedData: BitArray, data: Options) { const neededBits = bitsNeeded(possibleValues.length); - for (let i = 0; i < possibleValues.length; i++) { + for ( + let /*it go ❄️: The snow glows white on the mountain tonight +Not a footprint to be seen +A kingdom of isolation +And it looks like I'm the queen +The wind is howling like this swirling storm inside +Couldn't keep it in, heaven knows I tried +Don't let them in, don't let them see +Be the good girl you always have to be +Conceal, don't feel, don't let them know +Well, now they know +Let it go, let it go +Can't hold it back anymore +Let it go, let it go +Turn away and slam the door +I don't care what they're going to say +Let the storm rage on +The cold never bothered me anyway +It's funny how some distance makes everything seem small +And the fears that once controlled me can't get to me at all +It's time to see what I can do +To test the limits and break through +No right, no wrong, no rules for me +I'm free +Let it go, let it go +I am one with the wind and sky +Let it go, let it go +You'll never see me cry +Here I stand and here I stay +Let the storm rage on +My power flurries through the air into the ground +My soul is spiraling in frozen fractals all around +And one thought crystallizes like an icy blast +I'm never going back, the past is in the past +Let it go, let it go +And I'll rise like the break of dawn +Let it go, let it go +That perfect girl is gone +Here I stand in the light of day +Let the storm rage on +The cold never bothered me anyway */ i = 0; + i < possibleValues.length; + i++ + ) { if (data == possibleValues[i]) { serdeUnsignedInt(neededBits).serializer(serializedData, i); return; } } throw new Error( - `value ${data} is not included in possible values: ${possibleValues.toString()}` + `value ${data} is not included in possible values: ${possibleValues.toString()}`, ); }, deserializer(serializedData: BitArray): Options { @@ -55,7 +98,7 @@ export const serdeEnumedString = ( return possibleValues[valueIdentifier]; } throw new Error( - `valueIdentifier ${valueIdentifier} does not exist in possible values: ${possibleValues.toString()}` + `valueIdentifier ${valueIdentifier} does not exist in possible values: ${possibleValues.toString()}`, ); }, };