Skip to content

Commit

Permalink
🔀 Merge branch 'main' into webdav-express
Browse files Browse the repository at this point in the history
  • Loading branch information
ddlsmurf committed Jan 5, 2025
2 parents 1550217 + f04e5f0 commit 4343e6c
Show file tree
Hide file tree
Showing 140 changed files with 2,048 additions and 468 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ To get a local copy up and running, please follow these simple steps.
```
2. Run it with Docker
```sh
docker-compose up -d
cd tdrive
docker compose -f docker-compose.minimal.yml up
```
3. Open <http://localhost/> in a browser


## Development
Expand Down
9 changes: 9 additions & 0 deletions tdrive/backend/node/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
"logger": {
"level": "LOG_LEVEL"
},
"diagnostics": {
"skipKeys": {
"__name": "DIAG_SKIP_KEYS",
"__format": "json"
},
"probeSecret": "DIAG_PROBE_SECRET",
"statsLogPeriodMs": "DIAG_STATS_PRINT_PERIOD_MS",
"statsFullStatsLogPeriodMs": "DIAG_FULL_STATS_PRINT_PERIOD_MS"
},
"webserver": {
"host": "TWAKE_DRIVE_HOST",
"logger": {
Expand Down
7 changes: 7 additions & 0 deletions tdrive/backend/node/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"logger": {
"level": "debug"
},
"diagnostics": {
"skipKeys": [],
"probeSecret": "",
"statsLogPeriodMs": 120000,
"statsFullStatsLogPeriodMs": 600000
},
"tracker": {
"type": "segment",
"segment": {
Expand Down Expand Up @@ -226,6 +232,7 @@
},
"services": [
"auth",
"diagnostics",
"push",
"storage",
"webserver",
Expand Down
53 changes: 53 additions & 0 deletions tdrive/backend/node/src/cli/cmds/dev_cmds/set_local_user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import yargs from "yargs";

import runWithPlatform from "../../lib/run-with-platform";
import gr from "../../../services/global-resolver";
import { ConsoleController } from "../../../services/console/web/controller";

type CLIArgs = {
email: string;
password: string;
};

export default {
command: "set_local_user <email> <password>",
describe: "Create or update a local account user and password",
builder: {
email: {
demandOption: true,
type: "string",
},
password: {
demandOption: true,
type: "string",
},
},
handler: async (argv: CLIArgs) => {
await runWithPlatform("set_local_user", async ({ spinner: _spinner, platform: _platform }) => {
// Validation copied from tdrive/frontend/src/app/views/login/internal/signin/signin.jsx
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(argv.email))
throw new Error(`Invalid e-mail ${JSON.stringify(argv.email)}`);
if (!(argv.password.length >= 8))
throw new Error(`Invalid password ${JSON.stringify(argv.password)}`);
await gr.services.users.init();
const existingUser = await gr.services.users.getByEmail(argv.email);
if (existingUser) {
_spinner.info(
`Setting password of user ${existingUser.id} (${existingUser.email_canonical})`,
);
await gr.services.users.setPassword({ id: existingUser.id }, argv.password);
} else {
_spinner.info(`Creating user with email: ${argv.email}`);
await new ConsoleController().signup({
body: {
email: argv.email,
password: argv.password,
first_name: "set_local_user firstname",
last_name: "set_local_user lastname",
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any);
}
});
},
} as yargs.CommandModule<object, CLIArgs>;
10 changes: 5 additions & 5 deletions tdrive/backend/node/src/core/platform/framework/api/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TdriveService } from "./service";
import { TdriveServiceProvider } from "./service-provider";
import { ServiceDefinition } from "./service-definition";
import { TdriveServiceState } from "./service-state";
import { logger } from "../logger";
import { platformLogger } from "../logger";

export class TdriveComponent {
instance: TdriveService<TdriveServiceProvider>;
Expand Down Expand Up @@ -38,7 +38,7 @@ export class TdriveComponent {
recursionDepth?: number,
): Promise<void> {
if (recursionDepth > 10) {
logger.error("Maximum recursion depth exceeded (will exit process)");
platformLogger.error("Maximum recursion depth exceeded (will exit process)");
process.exit(1);
}

Expand All @@ -50,10 +50,10 @@ export class TdriveComponent {
for (const component of this.components) {
await component.switchToState(state, (recursionDepth || 0) + 1);
}
logger.info(`Children of ${this.name} are all in ${state} state`);
logger.info(this.getStateTree());
platformLogger.info(`Children of ${this.name} are all in ${state} state`);
platformLogger.info(this.getStateTree());
} else {
logger.info(`${this.name} does not have children`);
platformLogger.info(`${this.name} does not have children`);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Loading

0 comments on commit 4343e6c

Please sign in to comment.