Skip to content

Commit

Permalink
add kafka vars; update var naming and README
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanBulmer committed Mar 20, 2023
1 parent f58f3f7 commit be7f7c5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ app.listen(config.express.port, config.express.host, () => {

Location of environment variable is postfixed to `Config.{location}` (e.g. `Config.express.host`).

| Env var | Location | Required | Description |
| ---------------------- | ---------------------- | -------- | --------------------------------------------------------------------------------------- |
| `ENV` | `env` | `true` | Deployment envionment - `dev`, `qa`, `stage`, `prod` |
| `EXPRESS_HOST` | `express.host` | `false` | Express server - listener host |
| `EXPRESS_PORT` | `express.port` | `false` | Express server - listener port |
| `MONGO_URI` | `mongo.uri` | `false` | MongoDB - server URL, please include username and password to this string. |
| `KAFKA_CONSUMER_GROUP` | `kafka.consumer.group` | `false` | Kafka server - consumer group |
| `JWT_SECRET` | `jwt.secret` | `true` | JWT - secret, key to decode jwt, must be the same across all services in an environment |
| `JWT_ISSUER` | `jwt.issuer` | `true` | JWT - issuer, default `codrjs.com` |
| Env var | Location | Description |
| ---------------------- | ---------------------- | --------------------------------------------------------------------------------------- |
| `ENV` | `env` | Deployment envionment - `dev`, `qa`, `stage`, `prod` |
| `EXPRESS_HOST` | `express.host` | Express server - listener host |
| `EXPRESS_PORT` | `express.port` | Express server - listener port |
| `MONGO_URI` | `mongo.uri` | MongoDB - server URL, please include username and password to this string |
| `KAFKA_BROKERS` | `kafka.brokers` | Kafka server - comma seperated locations of the kafka brokers |
| `KAFKA_CLIENT_ID` | `kafka.clientId` | Kafka server - name of the kafka cluster |
| `KAFKA_CONSUMER_GROUP` | `kafka.consumer.group` | Kafka server - consumer group |
| `JWT_SECRET` | `jwt.secret` | JWT - secret, key to decode jwt, must be the same across all services in an environment |
| `JWT_ISSUER` | `jwt.issuer` | JWT - issuer, default `codrjs.com` |

## TODO

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codrjs/config",
"version": "1.0.0",
"version": "1.0.1",
"description": "Codr configuration, unified",
"main": "./cjs/index.js",
"module": "./esm/index.js",
Expand Down
4 changes: 4 additions & 0 deletions src/config/KafkaConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export const KafkaConfig: {
brokers: string;
clientId: string;
consumer: { group: string };
} = {
brokers: process.env.KAFKA_BROKERS as string,
clientId: process.env.KAFKA_CLIENT_ID as string,
consumer: { group: process.env.KAFKA_CONSUMER_GROUP as string },
};
4 changes: 2 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { JWTConfig } from "./JWTConfig";
import { KafkaConfig } from "./KafkaConfig";
import { MonogoConfig } from "./MongoConfig";

const config = {
const Config = {
env: process.env.ENV as "dev" | "qa" | "stage" | "prod",
express: ExpressConfig,
jwt: JWTConfig,
Expand All @@ -15,4 +15,4 @@ const config = {
};

export { ExpressConfig, JWTConfig, KafkaConfig, MonogoConfig };
export default config;
export default Config;
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import config from "./config";
import Config from "./config";

export * from "./config";
export default config
export default Config

0 comments on commit be7f7c5

Please sign in to comment.