Skip to content

Commit

Permalink
feat: make app port configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Sep 18, 2023
1 parent 7f8f797 commit 5db1132
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ In the `CHIA_ROOT` directory (usually `~/.chia/mainnet` on Linux), Climate Token
* **CADT_API_SERVER_HOST**: Defaults to localhost. It is strongly recommended to run the Climate Tokenization Engine on the same machine as the CADT API server.
* **CADT_API_KEY**: If your CADT API server is protected with an API key, add the same key here so the Climate Tokenization Engine can make the proper requests to the CADT service.
* **CLIMATE_TOKENIZATION_CHIA_HOST**: Defaults to localhost. It is strongly recommended to run the Climate Tokenization Engine on the same machine as the Climate Tokenization Chia host.
* **CLIMATE_TOKENIZATION_ENGINE_PORT** Specifiy the port that Climate Tokenization Engine runs on.
* **CORE_REGISTRY_MODE**: Defaults to `FALSE`. Set this parameter to `TRUE` if you'd like CADT to automatically be updated when tokenization occurs.
* **UNITS_FILTER**: This parameter determines which carbon units in CADT will show up as available to be tokenized in the Climate Tokenization Engine. By default, `Retired` `Cancelled` and `Expired` units will not be displayed as available to tokenize in the Climate Tokenization Engine.
* **LOG_LEVEL**: Determines the amount of logs that get written by the service. Defaults to `INFO`, but can be set to `DEBUG` if necessary.
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": "climate-tokenization-engine",
"version": "1.3.6",
"version": "1.3.7",
"bin": "./server.js",
"description": "",
"main": "proxy.js",
Expand Down
18 changes: 11 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const { getStoreIds } = require("./chia/datalayer.js");
const { logger } = require("./utils/logger");

const app = express();
const port = 31311;
let CONFIG = getConfig();

const headerKeys = Object.freeze({
ORG_UID: "x-org-uid",
});

app.use(
cors({
exposedHeaders: Object.values(headerKeys).join(","),
Expand Down Expand Up @@ -270,7 +270,7 @@ const updateUnitMarketplaceIdentifierWithAssetId = async (
delete unitToBeUpdated.issuanceId;
delete unitToBeUpdated.orgUid;
delete unitToBeUpdated.serialNumberBlock;

delete unitToBeUpdated.unitCount;
delete unitToBeUpdated.unitBlockStart;
delete unitToBeUpdated.unitBlockEnd;
Expand Down Expand Up @@ -345,9 +345,9 @@ const registerTokenCreationOnClimateWarehouse = async (
try {
if (CONFIG.CORE_REGISTRY_MODE) {
token.detokenization = {
mod_hash: '',
public_key: '',
signature: ''
mod_hash: "",
public_key: "",
signature: "",
};
}

Expand Down Expand Up @@ -667,8 +667,12 @@ if (
(bindAddress !== "localhost" && CONFIG.CLIMATE_TOKENIZATION_ENGINE_API_KEY) ||
bindAddress === "localhost"
) {
app.listen(port, bindAddress, () => {
console.log(`Application is running on port ${port}.`);
app.listen(CONFIG.CLIMATE_TOKENIZATION_ENGINE_PORT || 31311, bindAddress, () => {
console.log(
`Application is running on port ${
CONFIG.CLIMATE_TOKENIZATION_ENGINE_PORT || 31311
}.`
);
});

if (CONFIG.CORE_REGISTRY_MODE) {
Expand Down
3 changes: 2 additions & 1 deletion utils/defaultConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"LOG_LEVEL": "info",
"LOG_RETENTION_DAYS": "30",
"BIND_ADDRESS": "localhost",
"CERTIFICATE_FOLDER_PATH": null
"CERTIFICATE_FOLDER_PATH": null,
"CLIMATE_TOKENIZATION_ENGINE_PORT": 31311
}

0 comments on commit 5db1132

Please sign in to comment.