Skip to content

Commit

Permalink
Introduces 'dist' dir (#606)
Browse files Browse the repository at this point in the history
* fix: adds order attribute to the ICommunity interface

* chore: moves generated files to the 'dist' directory, and adds it to the .gitignore file

* refactor: removes 'orders' field from the ICommunity interface

The 'orders' field is not part of the Mongoose document, but rather it's something that's calculated on-the-fly
as part of the response to the `/findcomms` command for each community. Converting the mongoose document to a
plain object gets rid of the TSC errors without having to introduce an 'orders' field to the ICommunity interface.

This solution is preferred as the ICommunity interface should ideally mirror what's stored in the database.
  • Loading branch information
bilthon authored Nov 21, 2024
1 parent b80ddc4 commit 4b278ce
Show file tree
Hide file tree
Showing 8 changed files with 606 additions and 577 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.env
admin.macaroon
tls.cert
tls.cert
dist/
5 changes: 3 additions & 2 deletions bot/modules/community/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ async function findCommunities(currency) {
});
const orderCount = await getOrderCountByCommunity();
return communities.map(comm => {
comm.orders = orderCount[comm.id] || 0;
return comm;
const plainCommunity = comm.toObject();
plainCommunity.orders = orderCount[comm.id] || 0;
return plainCommunity;
});
}

Expand Down
2 changes: 1 addition & 1 deletion bot/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ const isBannedFromCommunity = async (user: UserDocument, communityId: string) =>
}
};

module.exports = {
export {
validateSellOrder,
validateBuyOrder,
validateUser,
Expand Down
1,129 changes: 566 additions & 563 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"version": "0.11.1",
"author": "Francisco Calderón <[email protected]>",
"description": "P2P lightning network telegram bot",
"main": "app.js",
"main": "dist/app.js",
"scripts": {
"prestart": "npx tsc",
"start": "node ./app",
"start": "node ./dist/app",
"predev": "npx tsc",
"dev": "nodemon ./app",
"dev": "nodemon ./dist/app",
"lint": "eslint .",
"format": "prettier --write '**/*.js'",
"pretest": "npx tsc",
"test": "export NODE_ENV=test && mocha --exit tests/**/*.spec.js"
"format": "prettier --write '**/*.{js,ts}'",
"pretest": "tsc -p tsconfig.test.json",
"test": "export NODE_ENV=test && mocha --exit 'dist/tests/**/*.spec.js'"
},
"license": "MIT",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tests/bot/bot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('Telegram bot', () => {
flags += flag.length;
});
let langs = 0;
fs.readdirSync(path.join(__dirname, '../../locales')).forEach(file => {
fs.readdirSync(path.join(__dirname, '../../../locales')).forEach(file => {
langs++;
});
expect(flags).to.be.equal(langs);
Expand Down
21 changes: 18 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
{
"compilerOptions": {
"strict": true,
"strict": false,
"esModuleInterop": true,
"resolveJsonModule": true,
"downlevelIteration": true
}
"downlevelIteration": true,
"outDir": "./dist",
"rootDir": ".",
"allowJs": true,
"moduleResolution": "node"
},
"include": [
"app.ts",
"bot/**/*",
"jobs/**/*",
"ln/**/*",
"lnurl/**/*",
"models/**/*",
"util/**/*",
"locales/**/*",
],
"exclude": ["node_modules", "dist", "tests", "locales"]
}
9 changes: 9 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"include": [
"tests/**/*"
],
"exclude": [
"node_modules"
]
}

0 comments on commit 4b278ce

Please sign in to comment.