Skip to content

Commit 3e136e8

Browse files
committed
chore: Update config usages
1 parent 50fbb7f commit 3e136e8

13 files changed

Lines changed: 50 additions & 48 deletions

File tree

apps/juxtaposition-ui/src/config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { z } = require('zod');
55
const schema = z.object({
66
logFolder: z.string().default(`${__dirname}/../logs`),
77
httpPort: z.coerce.number().default(8080),
8+
httpCookieDomain: z.string().default('.pretendo.network'),
89
postLimit: z.coerce.number().default(10),
910
miiImageCdn: z.string(),
1011
cdnDomain: z.string(),
@@ -64,7 +65,8 @@ const unmappedConfig = createConfigLoader()
6465
module.exports.config = {
6566
logFolder: unmappedConfig.logFolder,
6667
http: {
67-
port: unmappedConfig.httpPort
68+
port: unmappedConfig.httpPort,
69+
cookieDomain: unmappedConfig.httpCookieDomain
6870
},
6971
accountServerAddress: unmappedConfig.accountServerAddress,
7072
aesKey: unmappedConfig.aesKey,

apps/juxtaposition-ui/src/middleware/checkBan.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async function checkBan(request, response, next) {
2121

2222
// Check if user has access to the environment
2323
let accessAllowed = false;
24-
switch (config.server_environment) {
24+
switch (config.serverEnvironment) {
2525
case 'dev':
2626
accessAllowed = request.developer;
2727
break;

apps/juxtaposition-ui/src/middleware/discovery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const db = require('../database');
22
const { config } = require('../config');
33

44
async function checkDiscovery(request, response, next) {
5-
const discovery = await db.getEndPoint(config.server_environment);
5+
const discovery = await db.getEndPoint(config.serverEnvironment);
66

77
if (!discovery || discovery.status !== 0) {
88
let message = '';
@@ -29,7 +29,7 @@ async function checkDiscovery(request, response, next) {
2929
} else {
3030
request.guest_access = discovery ? discovery.guest_access : false;
3131
request.new_users = discovery ? discovery.new_users : false;
32-
response.locals.cdnURL = config.CDN_domain;
32+
response.locals.cdnURL = config.cdnDomain;
3333
}
3434

3535
next();

apps/juxtaposition-ui/src/middleware/webAuth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const util = require('../util');
22
const { config } = require('../config');
33

4-
const cookieDomain = config.http.cookie_domain || '.pretendo.network';
4+
const cookieDomain = config.http.cookieDomain;
55

66
async function webAuth(request, response, next) {
77
// Get pid and fetch user data

apps/juxtaposition-ui/src/services/juxt-web/routes/admin/admin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ router.get('/accounts/:pid', async function (req, res) {
8585
return res.redirect('/404');
8686
}
8787
const userSettings = await database.getUserSettings(req.params.pid);
88-
const posts = await database.getNumberUserPostsByID(req.params.pid, config.post_limit);
88+
const posts = await database.getNumberUserPostsByID(req.params.pid, config.postLimit);
8989
const communityMap = await util.getCommunityHash();
9090

9191
res.render(req.directory + '/moderate_user.ejs', {

apps/juxtaposition-ui/src/services/juxt-web/routes/console/communities.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ router.get('/:communityID/:type', async function (req, res) {
109109
let type;
110110

111111
if (req.params.type === 'hot') {
112-
posts = await database.getNumberPopularCommunityPostsByID(community, config.post_limit);
112+
posts = await database.getNumberPopularCommunityPostsByID(community, config.postLimit);
113113
type = 1;
114114
} else if (req.params.type === 'verified') {
115-
posts = await database.getNumberVerifiedCommunityPostsByID(community, config.post_limit);
115+
posts = await database.getNumberVerifiedCommunityPostsByID(community, config.postLimit);
116116
type = 2;
117117
} else {
118-
posts = await database.getNewPostsByCommunity(community, config.post_limit);
118+
posts = await database.getNewPostsByCommunity(community, config.postLimit);
119119
type = 0;
120120
}
121121
const numPosts = await database.getTotalPostsByCommunity(community);
@@ -145,7 +145,7 @@ router.get('/:communityID/:type', async function (req, res) {
145145
totalNumPosts: numPosts,
146146
userSettings: userSettings,
147147
userContent: userContent,
148-
account_server: config.account_server_domain.slice(8),
148+
account_server: config.accountServerAddress.slice(8),
149149
pnid: req.user,
150150
children,
151151
type,
@@ -168,13 +168,13 @@ router.get('/:communityID/:type/more', async function (req, res) {
168168
}
169169
switch (req.params.type) {
170170
case 'popular':
171-
posts = await database.getNumberPopularCommunityPostsByID(community, config.post_limit, offset);
171+
posts = await database.getNumberPopularCommunityPostsByID(community, config.postLimit, offset);
172172
break;
173173
case 'verified':
174-
posts = await database.getNumberVerifiedCommunityPostsByID(community, config.post_limit, offset);
174+
posts = await database.getNumberVerifiedCommunityPostsByID(community, config.postLimit, offset);
175175
break;
176176
default:
177-
posts = await database.getNewPostsByCommunity(community, config.post_limit, offset);
177+
posts = await database.getNewPostsByCommunity(community, config.postLimit, offset);
178178
break;
179179
}
180180

@@ -193,7 +193,7 @@ router.get('/:communityID/:type/more', async function (req, res) {
193193
moment: moment,
194194
database: database,
195195
bundle,
196-
account_server: config.account_server_domain.slice(8)
196+
account_server: config.accountServerAddress.slice(8)
197197
});
198198
} else {
199199
res.sendStatus(204);

apps/juxtaposition-ui/src/services/juxt-web/routes/console/feed.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ router.get('/', async function (req, res) {
1212
if (!userContent) {
1313
return res.redirect('/404');
1414
}
15-
const posts = await database.getNewsFeed(userContent, config.post_limit);
15+
const posts = await database.getNewsFeed(userContent, config.postLimit);
1616

1717
const bundle = {
1818
posts,
@@ -35,7 +35,7 @@ router.get('/', async function (req, res) {
3535
userContent: userContent,
3636
posts: posts,
3737
communityMap: communityMap,
38-
account_server: config.account_server_domain.slice(8),
38+
account_server: config.accountServerAddress.slice(8),
3939
bundle,
4040
tab: 0,
4141
template: 'posts_list',
@@ -53,7 +53,7 @@ router.get('/all', async function (req, res) {
5353
parent: null,
5454
message_to_pid: null,
5555
removed: false
56-
}).limit(config.post_limit).sort({ created_at: -1 });
56+
}).limit(config.postLimit).sort({ created_at: -1 });
5757

5858
const bundle = {
5959
posts,
@@ -76,7 +76,7 @@ router.get('/all', async function (req, res) {
7676
userContent: userContent,
7777
posts: posts,
7878
communityMap: communityMap,
79-
account_server: config.account_server_domain.slice(8),
79+
account_server: config.accountServerAddress.slice(8),
8080
bundle,
8181
tab: 1,
8282
template: 'posts_list'
@@ -90,7 +90,7 @@ router.get('/more', async function (req, res) {
9090
if (!offset) {
9191
offset = 0;
9292
}
93-
const posts = await database.getNewsFeedOffset(userContent, config.post_limit, offset);
93+
const posts = await database.getNewsFeedOffset(userContent, config.postLimit, offset);
9494

9595
const bundle = {
9696
posts,
@@ -107,7 +107,7 @@ router.get('/more', async function (req, res) {
107107
moment: moment,
108108
database: database,
109109
bundle,
110-
account_server: config.account_server_domain.slice(8)
110+
account_server: config.accountServerAddress.slice(8)
111111
});
112112
} else {
113113
res.sendStatus(204);
@@ -126,7 +126,7 @@ router.get('/all/more', async function (req, res) {
126126
parent: null,
127127
message_to_pid: null,
128128
removed: false
129-
}).skip(offset).limit(config.post_limit).sort({ created_at: -1 });
129+
}).skip(offset).limit(config.postLimit).sort({ created_at: -1 });
130130

131131
const bundle = {
132132
posts,
@@ -135,7 +135,7 @@ router.get('/all/more', async function (req, res) {
135135
communityMap,
136136
userContent,
137137
lang: req.lang,
138-
mii_image_CDN: config.mii_image_CDN,
138+
mii_image_CDN: config.miiImageCdn,
139139
link: `/feed/more?offset=${offset + posts.length}&pjax=true`,
140140
moderator: req.moderator
141141
};
@@ -146,7 +146,7 @@ router.get('/all/more', async function (req, res) {
146146
moment: moment,
147147
database: database,
148148
bundle,
149-
account_server: config.account_server_domain.slice(8)
149+
account_server: config.accountServerAddress.slice(8)
150150
});
151151
} else {
152152
res.sendStatus(204);
@@ -165,7 +165,7 @@ router.get('/all/more', async function (req, res) {
165165
parent: null,
166166
message_to_pid: null,
167167
removed: false
168-
}).skip(offset).limit(config.post_limit).sort({ created_at: -1 });
168+
}).skip(offset).limit(config.postLimit).sort({ created_at: -1 });
169169

170170
const bundle = {
171171
posts,
@@ -174,7 +174,7 @@ router.get('/all/more', async function (req, res) {
174174
communityMap,
175175
userContent,
176176
lang: req.lang,
177-
mii_image_CDN: config.mii_image_CDN,
177+
mii_image_CDN: config.miiImageCdn,
178178
link: `/feed/all/more?offset=${offset + posts.length}&pjax=true`,
179179
moderator: req.moderator
180180
};
@@ -185,10 +185,10 @@ router.get('/all/more', async function (req, res) {
185185
moment: moment,
186186
database: database,
187187
bundle,
188-
account_server: config.account_server_domain.slice(8),
189-
cdnURL: config.CDN_domain,
188+
account_server: config.accountServerAddress.slice(8),
189+
cdnURL: config.cdnDomain,
190190
lang: req.lang,
191-
mii_image_CDN: config.mii_image_CDN,
191+
mii_image_CDN: config.miiImageCdn,
192192
pid: req.pid,
193193
moderator: req.moderator
194194
});

apps/juxtaposition-ui/src/services/juxt-web/routes/console/messages.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ router.post('/new', async function (req, res) {
132132
is_app_jumpable: req.body.is_app_jumpable,
133133
language_id: req.body.language_id,
134134
mii: req.user.mii.data,
135-
mii_face_url: `${config.CDN_domain}/mii/${req.pid}/${miiFace}`,
135+
mii_face_url: `${config.cdnDomain}/mii/${req.pid}/${miiFace}`,
136136
pid: req.pid,
137137
platform_id: req.paramPackData ? req.paramPackData.platform_id : 0,
138138
region_id: req.paramPackData ? req.paramPackData.region_id : 2,
@@ -198,7 +198,7 @@ router.get('/new/:pid', async function (req, res) {
198198
created_at: new Date(),
199199
id: await generatePostUID(21),
200200
mii: req.user.mii.data,
201-
mii_face_url: `${config.CDN_domain}/mii/${req.pid}/normal_face.png`,
201+
mii_face_url: `${config.cdnDomain}/mii/${req.pid}/normal_face.png`,
202202
pid: req.pid,
203203
verified: (req.user.accessLevel >= 2),
204204
parent: null,

apps/juxtaposition-ui/src/services/juxt-web/routes/console/posts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ async function newPost(req, res) {
291291
is_app_jumpable: req.body.is_app_jumpable,
292292
language_id: req.body.language_id,
293293
mii: req.user.mii.data,
294-
mii_face_url: `${config.CDN_domain}/mii/${req.user.pid}/${miiFace}`,
294+
mii_face_url: `${config.cdnDomain}/mii/${req.user.pid}/${miiFace}`,
295295
pid: req.pid,
296296
platform_id: req.paramPackData ? req.paramPackData.platform_id : 0,
297297
region_id: req.paramPackData ? req.paramPackData.region_id : 2,

apps/juxtaposition-ui/src/services/juxt-web/routes/console/topics.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ router.get('/', async function (req, res) {
3636
userContent: userContent,
3737
posts: posts,
3838
communityMap: communityMap,
39-
account_server: config.account_server_domain.slice(8),
39+
account_server: config.accountServerAddress.slice(8),
4040
tab: 1,
4141
bundle,
4242
template: 'posts_list'
@@ -67,7 +67,7 @@ router.get('/more', async function (req, res) {
6767
moment: moment,
6868
database: database,
6969
bundle,
70-
account_server: config.account_server_domain.slice(8)
70+
account_server: config.accountServerAddress.slice(8)
7171
});
7272
} else {
7373
res.sendStatus(204);

0 commit comments

Comments
 (0)