Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-dp committed Dec 11, 2024
1 parent 7f5be73 commit df7a132
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/proxy-auth/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const config = {
},
}

export default config
export default config
1 change: 1 addition & 0 deletions examples/proxy-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build": "next build",
"db:migrate": "dotenv -e ../../.env.dev -- pnpm exec pg-migrations apply --directory ./db/migrations",
"dev": "next dev --turbo -p 5173",
"format": "eslint . --fix",
"start": "next start",
"stylecheck": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"typecheck": "tsc --noEmit"
Expand Down
26 changes: 16 additions & 10 deletions examples/proxy-auth/sst.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="./.sst/platform/config.d.ts" />
import { execSync } from "child_process"

Expand All @@ -6,14 +7,14 @@ const isProduction = (stage: string) => stage.toLowerCase() === `production`
export default $config({
app(input) {
return {
name: "proxy-auth",
removal: input?.stage === "production" ? "retain" : "remove",
protect: ["production"].includes(input?.stage),
home: "aws",
name: `proxy-auth`,
removal: input?.stage === `production` ? `retain` : `remove`,
protect: [`production`].includes(input?.stage),
home: `aws`,
providers: {
cloudflare: `5.42.0`,
aws: { version: `6.57.0`, region: `eu-west-1` },
postgresql: "3.14.0",
postgresql: `3.14.0`,
},
}
},
Expand All @@ -22,29 +23,34 @@ export default $config({
throw new Error(
`Env variables ELECTRIC_API and ELECTRIC_ADMIN_API must be set`
)

if (!process.env.EXAMPLES_DATABASE_HOST || !process.env.EXAMPLES_DATABASE_PASSWORD) {

if (
!process.env.EXAMPLES_DATABASE_HOST ||
!process.env.EXAMPLES_DATABASE_PASSWORD
) {
throw new Error(
`Env variables EXAMPLES_DATABASE_HOST and EXAMPLES_DATABASE_PASSWORD must be set`
)
}

const provider = new postgresql.Provider("neon", {
const provider = new postgresql.Provider(`neon`, {
host: process.env.EXAMPLES_DATABASE_HOST,
database: `neondb`,
username: `neondb_owner`,
password: process.env.EXAMPLES_DATABASE_PASSWORD,
})

const dbName = isProduction($app.stage) ? `proxy-auth-production` : `proxy-auth-${$app.stage}`
const dbName = isProduction($app.stage)
? `proxy-auth-production`
: `proxy-auth-${$app.stage}`
const pg = new postgresql.Database(dbName, {}, { provider })

const pgUri = $interpolate`postgresql://${provider.username}:${provider.password}@${provider.host}/${pg.name}?sslmode=require`
const electricInfo = pgUri.apply((uri) => {
return addDatabaseToElectric(uri, `eu-west-1`)
})

const staticSite = new sst.aws.Nextjs("proxy-auth", {
const staticSite = new sst.aws.Nextjs(`proxy-auth`, {
environment: {
ELECTRIC_URL: process.env.ELECTRIC_API!,
ELECTRIC_TOKEN: electricInfo.token,
Expand Down

0 comments on commit df7a132

Please sign in to comment.