Skip to content

Commit 49a55a8

Browse files
committed
feat: update API configuration to clarify variable exposure and rename internal/external to private/public
1 parent 8d771af commit 49a55a8

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/config/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
export const config = {
22
api: {
33
/*
4-
Example:
4+
NOTE: Remember to expose the public env vars in next.config.js
5+
6+
Development mode defaults:
57
API_PROTOCOL=http
68
API_HOST=localhost
79
API_PORT=1234
810
API_PREFIX=/api
911
API_VERSION=/v2
1012
*/
11-
internal: {
13+
private: {
1214
protocol: process.env.API_PROTOCOL,
1315
host: process.env.API_HOST,
1416
port: process.env.API_PORT,
1517
prefix: process.env.API_PREFIX,
1618
version: process.env.API_VERSION
1719
},
18-
external: {
20+
public: {
1921
protocol: process.env.NEXT_PUBLIC_API_PROTOCOL,
2022
host: process.env.NEXT_PUBLIC_API_HOST,
2123
port: process.env.NEXT_PUBLIC_API_PORT,

src/factories/apiRequestService.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import { config } from "../config";
33

44
export function getSSRApiRequestService(jwt?: string | null): ApiRequestService {
55
return new ApiRequestService({
6-
protocol: config.api.internal.protocol || '',
7-
host: config.api.internal.host || '',
8-
port: config.api.internal.port || '',
9-
prefix: config.api.internal.prefix || '',
10-
version: config.api.internal.version || '',
6+
protocol: config.api.private.protocol || '',
7+
host: config.api.private.host || '',
8+
port: config.api.private.port || '',
9+
prefix: config.api.private.prefix || '',
10+
version: config.api.private.version || '',
1111
...(jwt ? { jwt } : {})
1212
});
1313
}
1414

1515
export const apiRequestService = new ApiRequestService({
16-
protocol: config.api.external.protocol || '',
17-
host: config.api.external.host || '',
18-
port: config.api.external.port || '',
19-
prefix: config.api.external.prefix || '',
20-
version: config.api.external.version || ''
16+
protocol: config.api.public.protocol || '',
17+
host: config.api.public.host || '',
18+
port: config.api.public.port || '',
19+
prefix: config.api.public.prefix || '',
20+
version: config.api.public.version || ''
2121
});

0 commit comments

Comments
 (0)