use datePivot more places
This commit is contained in:
parent
53a6c9489f
commit
e668b1f7f3
@ -1,6 +1,7 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import AWS from 'aws-sdk'
|
import AWS from 'aws-sdk'
|
||||||
import { PassThrough } from 'stream'
|
import { PassThrough } from 'stream'
|
||||||
|
import { datePivot } from '../../../lib/time'
|
||||||
const { spawn } = require('child_process')
|
const { spawn } = require('child_process')
|
||||||
const encodeS3URI = require('node-s3-url-encode')
|
const encodeS3URI = require('node-s3-url-encode')
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ export default async function handler (req, res) {
|
|||||||
aws.headObject({
|
aws.headObject({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Key: s3PathPUT,
|
Key: s3PathPUT,
|
||||||
IfModifiedSince: new Date(new Date().getTime() - 15 * 60000)
|
IfModifiedSince: datePivot(new Date(), { minutes: -15 })
|
||||||
}).promise().then(() => {
|
}).promise().then(() => {
|
||||||
// this path is cached so return it
|
// this path is cached so return it
|
||||||
res.writeHead(302, { Location: bucketUrl + s3PathGET }).end()
|
res.writeHead(302, { Location: bucketUrl + s3PathGET }).end()
|
||||||
|
@ -5,6 +5,7 @@ import { lnurlPayDescriptionHashForUser } from '../../../../lib/lnurl'
|
|||||||
import serialize from '../../../../api/resolvers/serial'
|
import serialize from '../../../../api/resolvers/serial'
|
||||||
import { schnorr } from '@noble/curves/secp256k1'
|
import { schnorr } from '@noble/curves/secp256k1'
|
||||||
import { createHash } from 'crypto'
|
import { createHash } from 'crypto'
|
||||||
|
import { datePivot } from '../../../../lib/time'
|
||||||
|
|
||||||
export default async ({ query: { username, amount, nostr } }, res) => {
|
export default async ({ query: { username, amount, nostr } }, res) => {
|
||||||
const user = await models.user.findUnique({ where: { name: username } })
|
const user = await models.user.findUnique({ where: { name: username } })
|
||||||
@ -36,7 +37,7 @@ export default async ({ query: { username, amount, nostr } }, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate invoice
|
// generate invoice
|
||||||
const expiresAt = new Date(new Date().setMinutes(new Date().getMinutes() + 1))
|
const expiresAt = datePivot(new Date(), { minutes: 1 })
|
||||||
const invoice = await createInvoice({
|
const invoice = await createInvoice({
|
||||||
description,
|
description,
|
||||||
description_hash: descriptionHash,
|
description_hash: descriptionHash,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
import models from '../../api/models'
|
import models from '../../api/models'
|
||||||
import getSSRApolloClient from '../../api/ssrApollo'
|
import getSSRApolloClient from '../../api/ssrApollo'
|
||||||
import { CREATE_WITHDRAWL } from '../../fragments/wallet'
|
import { CREATE_WITHDRAWL } from '../../fragments/wallet'
|
||||||
|
import { datePivot } from '../../lib/time'
|
||||||
|
|
||||||
export default async ({ query }, res) => {
|
export default async ({ query }, res) => {
|
||||||
if (!query.k1) {
|
if (!query.k1) {
|
||||||
@ -19,7 +20,7 @@ export default async ({ query }, res) => {
|
|||||||
where: {
|
where: {
|
||||||
k1: query.k1,
|
k1: query.k1,
|
||||||
createdAt: {
|
createdAt: {
|
||||||
gt: new Date(new Date().setHours(new Date().getHours() - 1))
|
gt: datePivot(new Date(), { hours: -1 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user