Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
keyurboss committed Nov 9, 2023
1 parent 8758288 commit 8096fa8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
8 changes: 6 additions & 2 deletions apps/server/whatsapp-common/src/firebaseRD.creds.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,28 @@ import {
proto,
} from '@whiskeysockets/baileys';
import { firebaseDb } from './firebase.app';
function processFileName(name: string): string {
return name.replaceAll('.', '@');
}
export const useFireBaseRealTimeDatabaseStoreAuthState = async (
collectionName: string,
serverName: string,
): Promise<{ state: AuthenticationState; saveCreds: () => Promise<void> }> => {
const collection = firebaseDb.ref(collectionName).child(serverName);
// eslint-disable-next-line @typescript-eslint/no-explicit-any

const writeData = async (data: any, file: string) => {
data = JSON.stringify(data, BufferJSON.replacer);
console.log('Writing data type ', typeof data);
console.log('Writing data ', data);
collection.child(file).set(data);
collection.child(processFileName(file)).set(data);
return;
};

const readData = async (file: string) => {
try {
console.log('Reading ', file);
const data = await collection.child(file).get();
const data = await collection.child(processFileName(file)).get();
if (!data.exists()) {
return null;
}
Expand Down
33 changes: 17 additions & 16 deletions apps/server/whatsapp-common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"extends": "../../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"esModuleInterop": true
}
}
{
"extends": "../../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"lib": ["ES2021.String"],
"esModuleInterop": true
}
}

0 comments on commit 8096fa8

Please sign in to comment.