Skip to content

Commit 002ba70

Browse files
authored
fix(classes): fix fetching user response
1 parent 099ae11 commit 002ba70

File tree

6 files changed

+28
-26
lines changed

6 files changed

+28
-26
lines changed

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import { Announcements } from "./src/classes/Announcements.js";
1616
const PORT = process.env.PORT || 8000;
1717
const APP_VERSION = process.env.npm_package_version;
1818

19-
app.listen(PORT, async () => {
20-
await Announcements.loadAll();
21-
await Users.loadAll();
22-
await Congregations.loadAll();
23-
await CongregationRequests.loadAll();
19+
await Announcements.loadAll();
20+
await Users.loadAll();
21+
await Congregations.loadAll();
22+
await CongregationRequests.loadAll();
2423

24+
app.listen(PORT, async () => {
2525
logger("info", JSON.stringify({ details: `server up and running (v${APP_VERSION})` }));
2626
});

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/classes/Congregation.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class Congregation {
1616
cong_sourceMaterial_draft = [];
1717
cong_schedule_draft = [];
1818
cong_swsPocket = [];
19+
cong_settings;
1920
last_backup = {};
2021

2122
constructor() {}
@@ -36,6 +37,7 @@ export class Congregation {
3637
cong.cong_sourceMaterial_draft = congSnap.data().cong_sourceMaterial_draft || [];
3738
cong.cong_schedule_draft = congSnap.data().cong_schedule_draft || [];
3839
cong.cong_swsPocket = congSnap.data().cong_swsPocket || [];
40+
cong.cong_settings = congSnap.data().cong_settings || [];
3941
cong.members = [];
4042

4143
const usersList = Users.list;
@@ -107,10 +109,10 @@ export class Congregation {
107109

108110
const obj = {
109111
cong_persons: decryptedPersons,
110-
cong_schedule: cong_schedule_draft,
111-
cong_sourceMaterial: cong_sourceMaterial_draft,
112-
cong_swsPocket: cong_swsPocket,
113-
cong_settings: cong_settings,
112+
cong_schedule: this.cong_schedule_draft,
113+
cong_sourceMaterial: this.cong_sourceMaterial_draft,
114+
cong_swsPocket: this.cong_swsPocket,
115+
cong_settings: this.cong_settings,
114116
};
115117

116118
return obj;

src/classes/Users.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { getAuth } from 'firebase-admin/auth';
2-
import { getFirestore } from 'firebase-admin/firestore';
3-
import { decryptData } from '../utils/encryption-utils.js';
4-
import { sendVerificationEmail } from '../utils/sendEmail.js';
5-
import { User } from './User.js';
1+
import { getAuth } from "firebase-admin/auth";
2+
import { getFirestore } from "firebase-admin/firestore";
3+
import { decryptData } from "../utils/encryption-utils.js";
4+
import { sendVerificationEmail } from "../utils/sendEmail.js";
5+
import { User } from "./User.js";
66

77
const db = getFirestore(); //get default database
88

99
const getUsers = async () => {
10-
const userRef = db.collection('users');
10+
const userRef = db.collection("users");
1111
const snapshot = await userRef.get();
1212

1313
const tmpUsers = [];
@@ -42,12 +42,12 @@ class clsUsers {
4242

4343
findUserByEmail = (email) => {
4444
const found = this.list.find((user) => user.user_uid === email);
45-
return { ...found };
45+
return found;
4646
};
4747

4848
findUserById = (id) => {
4949
const found = this.list.find((user) => user.id === id);
50-
return { ...found };
50+
return found;
5151
};
5252

5353
findUserByOTPCode = (code) => {
@@ -73,7 +73,7 @@ class clsUsers {
7373

7474
findPocketUser = (pocketId) => {
7575
const found = this.list.find((user) => user.pocket_local_id === pocketId);
76-
return { ...found };
76+
return found;
7777
};
7878

7979
findPocketByVisitorId = async (visitorId) => {
@@ -110,18 +110,18 @@ class clsUsers {
110110
const data = {
111111
about: {
112112
name: fullname,
113-
role: 'vip',
113+
role: "vip",
114114
user_uid: userEmail,
115115
},
116116
};
117117

118-
await db.collection('users').add(data);
118+
await db.collection("users").add(data);
119119

120120
await this.loadAll();
121121
};
122122

123123
delete = async (userId, authId) => {
124-
await db.collection('users').doc(userId).delete();
124+
await db.collection("users").doc(userId).delete();
125125

126126
// remove from auth if qualified
127127
if (authId) await getAuth().deleteUser(authId);

src/middleware/update-tracker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const updateTracker = () => {
3939

4040
log.method = req.method;
4141
log.status = res.statusCode;
42-
log.path = req.path;
42+
log.path = req.headers['x-original-uri'];
4343
log.origin = req.headers.origin || req.hostname;
4444
if (clientIp) log.ip = clientIp;
4545
log.details = res.locals.message.replace(/\n|\r/g, "");
@@ -55,7 +55,7 @@ export const updateTracker = () => {
5555

5656
log.method = req.method;
5757
log.status = res.statusCode;
58-
log.path = req.path;
58+
log.path = req.headers['x-original-uri'];
5959
log.origin = req.headers.origin || req.hostname;
6060
if (clientIp) log.ip = clientIp;
6161
log.details = "this request was aborted";

src/utils/format-log.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const formatLog = (message, req, res) => {
77
const clientIp = requestIp.getClientIp(req);
88
log.method = req.method;
99
log.status = res.statusCode;
10-
log.path = res.originalUrl;
10+
log.path = req.headers["x-original-uri"];
1111
log.origin = req.headers.origin || req.hostname;
1212
if (clientIp) log.ip = clientIp;
1313
}

0 commit comments

Comments
 (0)