get nsec from ssm
This commit is contained in:
@@ -27,7 +27,7 @@ const htmlToAscii = html => {
|
||||
export const handler = async (event) => {
|
||||
const region = process.env.AWS_REGION || "us-east-1"
|
||||
const feed = event.feedUrl
|
||||
const privkey = toHexString(event.nostrNsec)
|
||||
const nostrNsecParam = event.nostrNsecParam
|
||||
const lastRunTimeParam = event.lastRunTimeParam
|
||||
const dryrun = event.dryRun
|
||||
|
||||
@@ -42,13 +42,12 @@ export const handler = async (event) => {
|
||||
}
|
||||
|
||||
const ssmClient = new SSMClient({ region })
|
||||
const params = {
|
||||
Name: lastRunTimeParam
|
||||
}
|
||||
const ssmGetCommand = new GetParameterCommand(params);
|
||||
const ssmGetLastRunCommand = new GetParameterCommand({
|
||||
Name: lastRunTimeParam
|
||||
});
|
||||
|
||||
let since = new Date()
|
||||
await ssmClient.send(ssmGetCommand)
|
||||
await ssmClient.send(ssmGetLastRunCommand)
|
||||
.then(data => {
|
||||
since = data.Parameter.Value
|
||||
}).catch(err => {
|
||||
@@ -56,7 +55,21 @@ export const handler = async (event) => {
|
||||
response.errors.push(err)
|
||||
return response
|
||||
})
|
||||
|
||||
|
||||
const ssmGetNsecCommand = new GetParameterCommand({
|
||||
Name: nostrNsecParam,
|
||||
WithDecryption: true
|
||||
})
|
||||
|
||||
let privkey = ''
|
||||
await ssmClient.send(ssmGetNsecCommand)
|
||||
.then(data => {
|
||||
privkey = toHexString(data.Parameter.Value)
|
||||
}).catch(err => {
|
||||
console.dir(err)
|
||||
response.errors.push(err)
|
||||
return response
|
||||
})
|
||||
|
||||
if (feed === "") {
|
||||
console.dir("feedUrl was not set.")
|
||||
@@ -100,7 +113,6 @@ export const handler = async (event) => {
|
||||
})
|
||||
|
||||
if (dryrun) {
|
||||
console.dir(ndkEvent)
|
||||
response.successes++
|
||||
continue
|
||||
}
|
||||
@@ -111,12 +123,12 @@ export const handler = async (event) => {
|
||||
if (published) {
|
||||
response.successes++
|
||||
|
||||
params.Name = lastRunTimeParam
|
||||
params.Value = new Date().toISOString()
|
||||
params.Type = "String"
|
||||
params.Overwrite = true
|
||||
|
||||
const ssmPutCommand = new PutParameterCommand(params)
|
||||
const ssmPutCommand = new PutParameterCommand({
|
||||
Name: lastRunTimeParam,
|
||||
Value: new Date().toISOString(),
|
||||
Type: "String",
|
||||
Overwrite: true
|
||||
})
|
||||
await ssmClient.send(ssmPutCommand)
|
||||
.catch(err => {
|
||||
console.dir(err)
|
||||
|
||||
Reference in New Issue
Block a user