-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Source config from dotenv everywhere.
- Loading branch information
Showing
10 changed files
with
65 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ package-lock.json | |
coverage | ||
public | ||
yt-dlp | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import sodium from 'sodium-native' | ||
import { writeFile } from 'fs/promises' | ||
import desm from 'desm' | ||
import { resolve } from 'path' | ||
import { schema } from '../plugins/env.js' | ||
|
||
const __dirname = desm(import.meta.url) | ||
|
||
// This script sets up a default .env dotenv file for use in development | ||
// Do not run this in production or when deploying. | ||
|
||
const varsNeedingDevKeys = [ | ||
'COOKIE_SECRET', | ||
'JWT_SECRET' | ||
] | ||
|
||
const dotenv = [] | ||
|
||
for (const envVar of varsNeedingDevKeys) { | ||
const buf = Buffer.allocUnsafe(sodium.crypto_secretbox_KEYBYTES) | ||
sodium.randombytes_buf(buf) | ||
const hexString = buf.toString('hex') | ||
dotenv.push(`${envVar}=${hexString}`) | ||
} | ||
|
||
for (const [name, opts] of Object.entries(schema.properties)) { | ||
if (opts.default) dotenv.push(`${name}=${opts.default}`) | ||
} | ||
|
||
dotenv.push('') | ||
await writeFile(resolve(__dirname, '../.env'), dotenv.join('\n')) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
import envSchema from 'env-schema' | ||
import { readFile } from 'fs/promises' | ||
import desm from 'desm' | ||
import { join } from 'path' | ||
import { schema } from '../plugins/env.js' | ||
|
||
const config = envSchema({ | ||
schema, | ||
dotenv: true | ||
}) | ||
|
||
const __dirname = desm(import.meta.url) | ||
|
||
export default async () => { | ||
return { | ||
siteName: '🥖 Breadcrum', | ||
disableRegistration: true, | ||
registration: config.REGISTRATION, | ||
version: JSON.parse(await readFile(new URL(join(__dirname, '../package.json'), import.meta.url))).version | ||
} | ||
} | ||
|
||
export const browser = { | ||
'process.env.REGISTRATION': config.REGISTRATION | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters