diff --git a/.ebextensions/autoscaling.config b/.ebextensions/autoscaling.config
new file mode 100644
index 00000000..a44295cd
--- /dev/null
+++ b/.ebextensions/autoscaling.config
@@ -0,0 +1,6 @@
+Resources:
+ AWSEBAutoScalingGroup:
+ Type: "AWS::AutoScaling::AutoScalingGroup"
+ Properties:
+ HealthCheckType: ELB
+ HealthCheckGracePeriod: 300
\ No newline at end of file
diff --git a/.platform/confighooks/predeploy/00_build.sh b/.platform/confighooks/predeploy/00_build.sh
index 8ceacc1a..0068a45c 100755
--- a/.platform/confighooks/predeploy/00_build.sh
+++ b/.platform/confighooks/predeploy/00_build.sh
@@ -4,4 +4,4 @@ echo primsa migrate
npm run migrate
echo build with npm
-npm run build
\ No newline at end of file
+sudo -E -u webapp npm run build
\ No newline at end of file
diff --git a/.platform/hooks/predeploy/00_build.sh b/.platform/hooks/predeploy/00_build.sh
index 8ceacc1a..0068a45c 100755
--- a/.platform/hooks/predeploy/00_build.sh
+++ b/.platform/hooks/predeploy/00_build.sh
@@ -4,4 +4,4 @@ echo primsa migrate
npm run migrate
echo build with npm
-npm run build
\ No newline at end of file
+sudo -E -u webapp npm run build
\ No newline at end of file
diff --git a/.platform/nginx/nginx.conf b/.platform/nginx/nginx.conf
index 56b39d96..4faf5adf 100644
--- a/.platform/nginx/nginx.conf
+++ b/.platform/nginx/nginx.conf
@@ -28,9 +28,9 @@ http {
listen 8008 default_server;
access_log /var/log/nginx/access.log main;
- client_header_timeout 60;
- client_body_timeout 60;
- keepalive_timeout 60;
+ client_header_timeout 90;
+ client_body_timeout 90;
+ keepalive_timeout 90;
gzip on;
gzip_comp_level 4;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
diff --git a/Dockerfile b/Dockerfile
index a2b59949..5425a3ad 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
-FROM node:16.16.0-bullseye
+FROM node:18.17.0-bullseye
ENV NODE_ENV=development
diff --git a/api/resolvers/rewards.js b/api/resolvers/rewards.js
index bb4d3aa7..f7e6fdd4 100644
--- a/api/resolvers/rewards.js
+++ b/api/resolvers/rewards.js
@@ -12,6 +12,8 @@ export default {
}
})
+ if (!lastReward) return { total: 0, sources: [] }
+
const [result] = await models.$queryRaw`
SELECT coalesce(FLOOR(sum(sats)), 0) as total, json_build_array(
json_build_object('name', 'donations', 'value', coalesce(FLOOR(sum(sats) FILTER(WHERE type = 'DONATION')), 0)),
diff --git a/api/resolvers/serial.js b/api/resolvers/serial.js
index 5edd2c2e..9971a3b9 100644
--- a/api/resolvers/serial.js
+++ b/api/resolvers/serial.js
@@ -35,17 +35,17 @@ async function serialize (models, ...calls) {
if (error.message.includes('SN_REVOKED_OR_EXHAUSTED')) {
bail(new Error('faucet has been revoked or is exhausted'))
}
- if (error.message.includes('23514')) {
- bail(new Error('constraint failure'))
- }
if (error.message.includes('SN_INV_PENDING_LIMIT')) {
bail(new Error('too many pending invoices'))
}
if (error.message.includes('SN_INV_EXCEED_BALANCE')) {
bail(new Error('pending invoices must not cause balance to exceed 1m sats'))
}
- if (error.message.includes('40001')) {
- throw new Error('wallet balance serialization failure - retry again')
+ if (error.message.includes('40001') || error.code === 'P2034') {
+ throw new Error('wallet balance serialization failure - try again')
+ }
+ if (error.message.includes('23514') || ['P2002', 'P2003', 'P2004'].includes(error.code)) {
+ bail(new Error('constraint failure'))
}
bail(error)
}
diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js
index 08d716bd..c32845da 100644
--- a/api/resolvers/wallet.js
+++ b/api/resolvers/wallet.js
@@ -172,7 +172,7 @@ export default {
}
switch (f.type) {
case 'withdrawal':
- f.msats = (-1 * f.msats) - f.msatsFee
+ f.msats = (-1 * Number(f.msats)) - Number(f.msatsFee)
break
case 'spent':
f.msats *= -1
diff --git a/api/ssrApollo.js b/api/ssrApollo.js
index 1341f47d..26aa5d94 100644
--- a/api/ssrApollo.js
+++ b/api/ssrApollo.js
@@ -38,14 +38,14 @@ export default async function getSSRApolloClient ({ req, res, me = null }) {
assumeImmutableResults: true,
defaultOptions: {
watchQuery: {
- fetchPolicy: 'cache-only',
- nextFetchPolicy: 'cache-only',
+ fetchPolicy: 'no-cache',
+ nextFetchPolicy: 'no-cache',
canonizeResults: true,
ssr: true
},
query: {
- fetchPolicy: 'cache-first',
- nextFetchPolicy: 'cache-only',
+ fetchPolicy: 'no-cache',
+ nextFetchPolicy: 'no-cache',
canonizeResults: true,
ssr: true
}
diff --git a/components/charts.js b/components/charts.js
index aa586d0d..d1a10561 100644
--- a/components/charts.js
+++ b/components/charts.js
@@ -89,7 +89,7 @@ export function WhenAreaChart ({ data }) {
tick={{ fill: 'var(--theme-grey)' }}
/>
{itemString})} diff --git a/pages/notifications.js b/pages/notifications.js index 95c90856..67afefa6 100644 --- a/pages/notifications.js +++ b/pages/notifications.js @@ -1,13 +1,27 @@ +import { useEffect } from 'react' import { getGetServerSideProps } from '../api/ssrApollo' import Layout from '../components/layout' -import Notifications from '../components/notifications' -import { NOTIFICATIONS } from '../fragments/notifications' +import Notifications, { NotificationAlert } from '../components/notifications' +import { HAS_NOTIFICATIONS, NOTIFICATIONS } from '../fragments/notifications' +import { useApolloClient } from '@apollo/client' export const getServerSideProps = getGetServerSideProps(NOTIFICATIONS) export default function NotificationPage ({ ssrData }) { + const client = useApolloClient() + + useEffect(() => { + client?.writeQuery({ + query: HAS_NOTIFICATIONS, + data: { + hasNewNotes: false + } + }) + }, []) + return (