-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split data dir into public and private data
- Loading branch information
1 parent
d0ef981
commit f2bab9b
Showing
10 changed files
with
128 additions
and
37 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 |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
|
||
# Data directory | ||
/data/ | ||
# Private data directory | ||
/private_data/ | ||
|
||
# Server logs | ||
*.log | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
"cSpell.words": [ | ||
"Asciinema", | ||
"firstrun", | ||
"Minifolio", | ||
"superstruct" | ||
] | ||
} |
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 @@ | ||
# File locations in Minifolio | ||
|
||
## Data directory | ||
|
||
Determined using environment variable `DATA_REPO_PATH`. | ||
|
||
Main portfolio data. Should be backed up using a `git` repo. | ||
|
||
### `config.json` | ||
|
||
Main site configuration. | ||
|
||
## Private data directory | ||
|
||
Determined using environment variable `PRIVATE_DATA_PATH`. | ||
|
||
Contains private data, including credentials and authentication secrets. | ||
|
||
### `config.local.json` | ||
|
||
Contains the local configuration of the server, including credentials and token | ||
info. | ||
|
||
### `id_ed25519`, `id_ed25519.pub` | ||
|
||
SSH key used by the server. These are used to perform git operations over SSH. | ||
|
||
### `auth.secret` | ||
|
||
Contains the authentication secret used by the server. This is used to validate | ||
JWTs. |
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,24 @@ | ||
/** | ||
* Shared helper functions for common data migration actions. | ||
*/ | ||
import { dev } from '$app/environment'; | ||
import fs from 'fs/promises'; | ||
|
||
/** Move config.local.json to the private data directory */ | ||
export async function moveLocalConfig(dataDir: string, privateDataDir: string) { | ||
const originalPath = `${dataDir}/config.local.json`; | ||
const newPath = `${privateDataDir}/config.local.json`; | ||
await fs.rename(originalPath, newPath); | ||
} | ||
|
||
/** Write auth secret from environment variable */ | ||
export async function writeAuthSecret(privateDataDir: string) { | ||
const secret = process.env.AUTH_SECRET; | ||
if (!secret) { | ||
throw new Error('AUTH_SECRET environment variable must be set to a value'); | ||
} | ||
if (!dev && secret === 'CHANGE ME') { | ||
throw new Error('AUTH_SECRET must be changed when running in production'); | ||
} | ||
await fs.writeFile(`${privateDataDir}/auth.secret`, secret, { encoding: 'utf-8' }); | ||
} |
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,7 @@ | ||
/** | ||
* Migrate to v0.6.0 | ||
* | ||
* Primary changes: | ||
* | ||
* * Move `config.local.json` to the new private data directory. | ||
*/ |
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,12 @@ | ||
/** Code for managing the server's SSH keys */ | ||
import fs from 'fs/promises'; | ||
|
||
/** Generate an SSH key */ | ||
export async function sshKeygen() { | ||
|
||
} | ||
|
||
export async function getPublicKey(): Promise<string> { | ||
const data | ||
return fs.readFile() | ||
} |