Skip to content

Commit 43fffda

Browse files
author
DylanBulmer
committed
add codr settings; update node module config
1 parent 725f5c5 commit 43fffda

5 files changed

Lines changed: 49 additions & 20 deletions

File tree

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ Location of environment variable is postfixed to `Config.{location}` (e.g. `Conf
4141
| --------------------------- | ------------------------------- | --------------------------------------------------------------------------------------- |
4242
| `ENV` | `env` | Deployment envionment - `dev`, `qa`, `stage`, `prod` |
4343
| `HOSTNAME` | `hostname` | Deployment docker hostname |
44-
| `npm_package_name` | `name` | Deployment service name - example: codr-user-user |
45-
| `npm_package_version` | `version` | Deployment version - example: `1.0.0` |
44+
| Provided via npm | `name` | Deployment service name - example: codr-user-user |
45+
| Provided via npm | `version` | Deployment version - example: `1.0.0` |
4646
| `AWS_REGION` | `aws.region` | AWS - deployment region |
4747
| `AWS_SES_API_VERSION` | `aws.ses.api.version` | AWS SES - api version |
4848
| `AWS_SES_ACCESS_KEY` | `aws.ses.access.key` | AWS SES - IAM access key id |
4949
| `AWS_SES_ACCESS_SECRET` | `aws.ses.access.secret` | AWS SES - IAM access key secret |
50+
| `CODR_USER_AUTH_SVC_URL` | `codr.svc.user.auth` | Codr - user authentication service |
51+
| `CODR_USER_PROFILE_SVC_URL` | `codr.svc.user.profile` | Codr - user profile entity service |
52+
| `CODR_USER_SESSION_SVC_URL` | `codr.svc.user.session` | Codr - user session entity service |
53+
| `CODR_USER_USER_SVC_URL` | `codr.svc.user.user` | Codr - user entity service |
5054
| `EMAIL_FROM` | `email.from` | Email - from address |
5155
| `EMAIL_REPLY_TO` | `email.replyto` | Email - reply to address(es) |
5256
| `EXPRESS_HOST` | `express.host` | Express server - listener host |
@@ -61,10 +65,10 @@ Location of environment variable is postfixed to `Config.{location}` (e.g. `Conf
6165
| `KAFKA_CLIENT_ID` | `kafka.clientId` | Kafka server - name of the kafka cluster |
6266
| `KAFKA_CONSUMER_GROUP` | `kafka.consumer.group` | Kafka server - consumer group |
6367
| `MONGO_URI` | `mongo.uri` | MongoDB - server URL, please include username and password to this string |
64-
| `NODE_ENV` | `node.env` | Node environment - `development`,`production`, `testing` |
65-
| `NODE_VERSION` | `node.verison` | Node version - example: `16.19.1` |
66-
| N/A | `node.modules` | Node modules - string array of all dependencies |
67-
| `YARN_VERSION` | `node.yarnVersion` | Node - package manager version |
68+
| `NODE_ENV` | `node.env` | Node environment - `development`, `production`, `testing` |
69+
| Provided via npm | `node.verison` | Node version - example: `16.19.1` |
70+
| Provided via npm | `node.modules` | Node modules - string array of all dependencies |
71+
| Provided via yarn | `node.yarnVersion` | Node - package manager version |
6872
| `OPENAPI_INFO_TITLE` | `openapi.info.title` | OpenAPI - documentation title |
6973
| `OPENAPI_INFO_DESC` | `openapi.info.description` | OpenAPI - documentation description |
7074
| `OPENAPI_SERVER_ONE_URL` | `openapi.server[0].url` | OpenAPI - server one url |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codrjs/config",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "Codr configuration, unified",
55
"main": "./cjs/index.js",
66
"module": "./esm/index.js",

src/config/CodrConfig.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export const CodrConfig: {
2+
svc: {
3+
user: {
4+
user: string;
5+
profile: string;
6+
session: string;
7+
auth: string;
8+
};
9+
};
10+
} = {
11+
svc: {
12+
user: {
13+
auth: process.env.CODR_USER_AUTH_SVC_URL as string,
14+
profile: process.env.CODR_USER_PROFILE_SVC_URL as string,
15+
session: process.env.CODR_USER_SESSION_SVC_URL as string,
16+
user: process.env.CODR_USER_USER_SVC_URL as string,
17+
},
18+
},
19+
};

src/config/NodeConfig.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@ export const NodeConfig: {
88
version: process.env.NODE_VERSION as string,
99
modules: Object.keys(process.env)
1010
.filter(m => /npm_package_dependencies_/g.test(m))
11-
.map(m => [m, process.env[m]] as [string, string])
12-
.map(m => [m[0].replace(/npm_package_dependencies_/g, ""), m[1]])
11+
.sort()
12+
.map(
13+
m =>
14+
[m.replace(/npm_package_dependencies_/g, ""), process.env[m]] as [
15+
string,
16+
string,
17+
],
18+
)
1319
.map(
1420
m =>
1521
[
16-
m[0]
17-
.split("_")
18-
.map((p, idx) =>
19-
p === ""
20-
? "@"
21-
: idx === m[0].split("_").length - 1 &&
22-
m[0].split("_").length !== 1
23-
? `/${p}`
24-
: p,
25-
)
26-
.join(""),
22+
m[0].split("_").reduce((acc, curr, idx) => {
23+
if (curr === "") acc += "@";
24+
else if (idx === 0) acc += curr;
25+
else if (idx === 1 && acc === "@") acc += `${curr}/`;
26+
else if (idx >= 1 && !/@\w+\//g.test(acc)) acc += `-${curr}`;
27+
else acc += curr;
28+
return acc;
29+
}, ""),
2730
m[1],
2831
] as string[],
2932
)

src/config/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import dotenv from "dotenv";
22
dotenv.config();
33

44
import { AWSConfig } from "./AWSConfig";
5+
import { CodrConfig } from "./CodrConfig";
56
import { EmailConfig } from "./EmailConfig";
67
import { ExpressConfig } from "./ExpressConfig";
78
import { GitConfig } from "./GitConfig";
@@ -20,6 +21,7 @@ const GeneralConfig = {
2021

2122
const Config = {
2223
aws: AWSConfig,
24+
codr: CodrConfig,
2325
email: EmailConfig,
2426
express: ExpressConfig,
2527
jwt: JWTConfig,
@@ -33,6 +35,7 @@ const Config = {
3335

3436
export {
3537
AWSConfig,
38+
CodrConfig,
3639
EmailConfig,
3740
ExpressConfig,
3841
GitConfig,

0 commit comments

Comments
 (0)