-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb79b72
commit 43b5add
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import axios from 'axios' | ||
import { join } from 'path' | ||
import { Utils } from '@shardus/types' | ||
import * as crypto from '@shardus/crypto-utils' | ||
import { config, overrideDefaultConfig } from '../src/Config' | ||
|
||
const configFile = join(process.cwd(), 'archiver-config.json') | ||
overrideDefaultConfig(configFile) | ||
|
||
crypto.init(config.ARCHIVER_HASH_KEY) | ||
|
||
const DEV_KEYS = { | ||
pk: config.ARCHIVER_PUBLIC_KEY, | ||
sk: config.ARCHIVER_SECRET_KEY, | ||
} | ||
|
||
function sign<T>(obj: T, sk: string, pk: string): T & any { | ||
const objCopy = JSON.parse(crypto.stringify(obj)) | ||
crypto.signObj(objCopy, sk, pk) | ||
return objCopy | ||
} | ||
|
||
function createSignature(data: any, pk: string, sk: string): any { | ||
return sign({ ...data }, sk, pk) | ||
} | ||
|
||
const UPDATE_CONFIG = { | ||
/* Add Config properties that need to be updated here */ | ||
VERBOSE: true, | ||
RATE_LIMIT: 200, | ||
} | ||
|
||
const INPUT = Utils.safeStringify(createSignature(UPDATE_CONFIG, DEV_KEYS.pk, DEV_KEYS.sk)) | ||
|
||
axios | ||
.patch('http://127.0.0.1:4000/set-config', INPUT, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
.then((response) => { | ||
console.log(response.data) | ||
}) | ||
.catch((error) => { | ||
if (error.response) { | ||
console.error(error.response) | ||
} else { | ||
console.error(error.message) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters