Skip to content

Commit

Permalink
Merge pull request #412 from joonaun93/review-readMe
Browse files Browse the repository at this point in the history
docs(readme): tested create-wallet.js and added section for scripts
  • Loading branch information
Kpoke authored Aug 28, 2023
2 parents 92564b9 + ee39f4a commit 00d5fa2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@ PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nXXXXXXXXXXXXXXXXXXXXX\n-----END RS

Copy and paste the PUBLIC_KEY and PRIVATE_KEY strings above exactly as is. Then, go to your jwtRS256.key.pub and jwtRS256.key files generated earlier in your config folder and remove all the new lines. Replace the "XXXXX.." with the key codes between the BEGIN PUBLIC KEY and END PUBLIC KEY sections (pasted as a single line) from your respective jwtRS256.key.pub and jwtRS256.key files. \*\*Don't just copy and paste the whole block from these files into these sections since we need to preserve this format with the "\n" injected into the strings here. To find out more, read the dotenv documentation on Multiline Values https://www.npmjs.com/package/dotenv


### Running Scripts

#### To create a new wallet:

1. Ensure that the database is already set up and running.

2. Open the terminal and navigate to the root of the tree-tracker-api directory.

3. Execute the following command, replacing <username> with your desired username:

```
NODE_ENV=development node scripts/create/create-wallet.js <username>
```


### We are using linter to keep the project in shape

if you are using VScode as your IDE, you can set up linter to run on save, which is very handy
Expand Down
5 changes: 3 additions & 2 deletions scripts/create/create-wallet.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require('dotenv').config({ path: `.env.${process.env.NODE_ENV}` });

function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
Expand All @@ -9,10 +10,10 @@ function getRandomArbitrary(min, max) {
const { v4: uuidv4 } = require('uuid');
const generator = require('generate-password');

const Config = require('./config/config');
const Config = require('../../config/config');
const knex = Knex({
client: 'pg',
connection: Config.connectionString[process.env.NODE_ENV]
connection: Config.connectionString
})

const Crypto = require('crypto');
Expand Down

0 comments on commit 00d5fa2

Please sign in to comment.