From 75afdfed7d42a1f9513fbc4ac2f8c3922960c7f7 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 13 Nov 2023 05:42:06 +0000 Subject: [PATCH] add infiscal --- .env-example | 2 +- .infisical.json | 5 ++ next.config.js | 148 ++++++++++++++++++------------------------------ package.json | 1 + pnpm-lock.yaml | 84 +++++++++++++++++++++++++++ src/db/redis.ts | 2 +- src/secrets.js | 8 +++ tsconfig.json | 8 ++- 8 files changed, 162 insertions(+), 96 deletions(-) create mode 100644 .infisical.json create mode 100644 src/secrets.js diff --git a/.env-example b/.env-example index 9d765cf..2537d93 100644 --- a/.env-example +++ b/.env-example @@ -1,4 +1,4 @@ -SENTRY_AUTH_TOKEN=hi +INFISICAL_TOKEN=hi # Redis REDIS_URL=redis://localhost:6379/0 \ No newline at end of file diff --git a/.infisical.json b/.infisical.json new file mode 100644 index 0000000..67bc0eb --- /dev/null +++ b/.infisical.json @@ -0,0 +1,5 @@ +{ + "workspaceId": "6551ad1ded9edd83540488e0", + "defaultEnvironment": "", + "gitBranchToEnvironmentMapping": null +} \ No newline at end of file diff --git a/next.config.js b/next.config.js index be0fd2f..6a33c07 100644 --- a/next.config.js +++ b/next.config.js @@ -1,31 +1,47 @@ const nextBuildId = require("next-build-id"); const { withSentryConfig } = require("@sentry/nextjs"); -const withBundleAnalyzer = require("@next/bundle-analyzer")({ - enabled: false, -}); +const withBundleAnalyzer = require("@next/bundle-analyzer")({ enabled: false }); +const infisicalClient = require("./src/secrets"); + +// Define remote patterns for images +const remotePatterns = [ + { protocol: "https", hostname: "cdn.fascinated.cc", pathname: "/**" }, + { protocol: "https", hostname: "cdn.scoresaber.com", pathname: "/**" }, + { protocol: "https", hostname: "cdn.jsdelivr.net", pathname: "/**" }, + { protocol: "https", hostname: "eu.cdn.beatsaver.com", pathname: "/**" }, + { protocol: "https", hostname: "na.cdn.beatsaver.com", pathname: "/**" }, + { + protocol: "https", + hostname: "avatars.akamai.steamstatic.com", + pathname: "/**", + }, +]; + +// Define optimized package imports +const optimizePackageImports = [ + "react", + "react-dom", + "next-themes", + "react-tostify", + "websocket", + "cslx", + "chart.js", + "react-chartjs-2", + "country-list", + "@sentry/nextjs", +]; /** @type {import('next').NextConfig} */ const nextConfig = { generateEtags: true, reactStrictMode: true, swcMinify: true, - experimental: { - webpackBuildWorker: true, - optimizePackageImports: [ - "react", - "react-dom", - "next-themes", - "react-tostify", - "websocket", - "cslx", - "chart.js", - "react-chartjs-2", - "country-list", - "@sentry/nextjs", - ], - }, compress: false, poweredByHeader: false, + experimental: { + webpackBuildWorker: true, + optimizePackageImports, + }, env: { NEXT_PUBLIC_BUILD_ID: process.env.GIT_REV || nextBuildId.sync({ dir: __dirname }), @@ -37,80 +53,26 @@ const nextConfig = { minute: "numeric", }), }, - images: { - remotePatterns: [ - { - protocol: "https", - hostname: "cdn.fascinated.cc", - port: "", - pathname: "/**", - }, - { - protocol: "https", - hostname: "cdn.scoresaber.com", - port: "", - pathname: "/**", - }, - { - protocol: "https", - hostname: "cdn.jsdelivr.net", - port: "", - pathname: "/**", - }, - { - protocol: "https", - hostname: "eu.cdn.beatsaver.com", - port: "", - pathname: "/**", - }, - { - protocol: "https", - hostname: "na.cdn.beatsaver.com", - port: "", - pathname: "/**", - }, - { - protocol: "https", - hostname: "avatars.akamai.steamstatic.com", - port: "", - pathname: "/**", - }, - ], - }, + images: { remotePatterns }, }; -module.exports = withBundleAnalyzer(nextConfig); - -module.exports = withSentryConfig( - module.exports, - { - // For all available options, see: - // https://github.com/getsentry/sentry-webpack-plugin#options - - // Suppresses source map uploading logs during build - silent: true, - org: "sentry", - project: "scoresaber-reloaded", - url: "https://sentry.fascinated.cc", - authToken: process.env.SENTRY_AUTH_TOKEN, - }, - { - // For all available options, see: - // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ - - // Upload a larger set of source maps for prettier stack traces (increases build time) - widenClientFileUpload: false, - - // Transpiles SDK to be compatible with IE11 (increases bundle size) - transpileClientSDK: false, - - // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load) - tunnelRoute: "/monitoring", - - // Hides source maps from generated client bundles - hideSourceMaps: true, - - // Automatically tree-shake Sentry logger statements to reduce bundle size - disableLogger: true, - }, -); +module.exports = async () => + withSentryConfig( + withBundleAnalyzer(nextConfig), + { + silent: true, + org: "sentry", + project: "scoresaber-reloaded", + url: "https://sentry.fascinated.cc", + authToken: (await infisicalClient.getSecret("SENTRY_AUTH_TOKEN")) + .secretValue, + dryRun: process.env.NODE_ENV !== "development", + }, + { + widenClientFileUpload: false, + transpileClientSDK: false, + tunnelRoute: "/monitoring", + hideSourceMaps: true, + disableLogger: true, + }, + ); diff --git a/package.json b/package.json index 5b1c358..89111ec 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "date-fns": "^2.30.0", "encoding": "^0.1.13", "idb-keyval": "^6.2.1", + "infisical-node": "^1.5.0", "lucide-react": "^0.292.0", "next": "14.0.2", "next-build-id": "^3.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1c47a91..6cb06f1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,6 +62,9 @@ dependencies: idb-keyval: specifier: ^6.2.1 version: 6.2.1 + infisical-node: + specifier: ^1.5.0 + version: 1.5.0 lucide-react: specifier: ^0.292.0 version: 0.292.0(react@18.2.0) @@ -1581,6 +1584,10 @@ packages: has-symbols: 1.0.3 dev: true + /asynckit@0.4.0: + resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + dev: false + /autoprefixer@10.4.16(postcss@8.4.31): resolution: {integrity: sha512-7vd3UC6xKp0HLfua5IjZlcXvGAGy7cBAXTg2lyQ/8WpNhd6SiZ8Be+xm3FyBSYJx5GKcpRCzBh7RH4/0dnY+uQ==} engines: {node: ^10 || ^12 || >=14} @@ -1607,6 +1614,16 @@ packages: engines: {node: '>=4'} dev: true + /axios@1.6.1: + resolution: {integrity: sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==} + dependencies: + follow-redirects: 1.15.3 + form-data: 4.0.0 + proxy-from-env: 1.1.0 + transitivePeerDependencies: + - debug + dev: false + /axobject-query@3.2.1: resolution: {integrity: sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==} dependencies: @@ -1800,6 +1817,13 @@ packages: color-string: 1.9.1 dev: false + /combined-stream@1.0.8: + resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} + engines: {node: '>= 0.8'} + dependencies: + delayed-stream: 1.0.0 + dev: false + /commander@4.1.1: resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} engines: {node: '>= 6'} @@ -1957,6 +1981,11 @@ packages: object-keys: 1.1.1 dev: true + /delayed-stream@1.0.0: + resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} + engines: {node: '>=0.4.0'} + dev: false + /dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} @@ -2025,6 +2054,11 @@ packages: domhandler: 5.0.3 dev: false + /dotenv@16.3.1: + resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==} + engines: {node: '>=12'} + dev: false + /duplexer@0.1.2: resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==} dev: true @@ -2540,12 +2574,31 @@ packages: resolution: {integrity: sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==} dev: true + /follow-redirects@1.15.3: + resolution: {integrity: sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + dev: false + /for-each@0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} dependencies: is-callable: 1.2.7 dev: true + /form-data@4.0.0: + resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} + engines: {node: '>= 6'} + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + mime-types: 2.1.35 + dev: false + /fraction.js@4.3.7: resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==} dev: true @@ -2822,6 +2875,17 @@ packages: engines: {node: '>=0.8.19'} dev: true + /infisical-node@1.5.0: + resolution: {integrity: sha512-mMdhhu50J7pI4Y89M2HMbNWRyRY6ian3oBIXW+pAWz1z8XWn5yT0ge6/YNXwTPKLnBuR1py+GwiNQUaqxkOXZw==} + dependencies: + axios: 1.6.1 + dotenv: 16.3.1 + tweetnacl: 1.0.3 + tweetnacl-util: 0.15.1 + transitivePeerDependencies: + - debug + dev: false + /inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} dependencies: @@ -3177,6 +3241,18 @@ packages: braces: 3.0.2 picomatch: 2.3.1 + /mime-db@1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + dev: false + + /mime-types@2.1.35: + resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} + engines: {node: '>= 0.6'} + dependencies: + mime-db: 1.52.0 + dev: false + /mimic-response@3.1.0: resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==} engines: {node: '>=10'} @@ -4319,6 +4395,14 @@ packages: safe-buffer: 5.2.1 dev: false + /tweetnacl-util@0.15.1: + resolution: {integrity: sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw==} + dev: false + + /tweetnacl@1.0.3: + resolution: {integrity: sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==} + dev: false + /type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} diff --git a/src/db/redis.ts b/src/db/redis.ts index 7939a2f..d2dee72 100644 --- a/src/db/redis.ts +++ b/src/db/redis.ts @@ -3,7 +3,7 @@ import { createClient } from "redis"; let redisClient = await connectRedis(); async function connectRedis(): Promise { - console.log("Connecting to redis"); + // console.log("Connecting to redis"); const client = createClient({ url: process.env.REDIS_URL, }); diff --git a/src/secrets.js b/src/secrets.js new file mode 100644 index 0000000..6a3b7b6 --- /dev/null +++ b/src/secrets.js @@ -0,0 +1,8 @@ +const InfisicalClient = require("infisical-node"); + +const infisicalClient = new InfisicalClient({ + token: process.env.INFISICAL_TOKEN, + siteURL: "https://secrets.fascinated.cc", +}); + +module.exports = infisicalClient; diff --git a/tsconfig.json b/tsconfig.json index 9a6b153..d6ac59d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,6 +23,12 @@ "@/*": ["./src/*"] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts", + "src/secrets.js" + ], "exclude": ["node_modules"] }