metamigo-cli no longer starts the worker or the api
it is now just responsible for db migrations and config generation/help
This commit is contained in:
parent
5c2187c7b7
commit
b0fd810563
3 changed files with 0 additions and 99 deletions
|
|
@ -2,7 +2,6 @@ import {
|
|||
generateConfig,
|
||||
printConfigOptions,
|
||||
} from "@digiresilience/metamigo-common";
|
||||
import { IAppConfig, IAppConvict } from "@digiresilience/metamigo-config";
|
||||
import { loadConfigRaw } from "@digiresilience/metamigo-config";
|
||||
|
||||
export const genConf = async (): Promise<void> => {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,13 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { Command } from "commander";
|
||||
import { startWithout } from "@digiresilience/montar";
|
||||
import { migrateWrapper } from "@digiresilience/metamigo-db";
|
||||
import { loadConfig } from "@digiresilience/metamigo-config";
|
||||
import { genConf, listConfig } from "./config.js";
|
||||
import { createTokenForTesting, generateJwks } from "./jwks.js";
|
||||
import { exportGraphqlSchema } from "./metamigo-postgraphile.js";
|
||||
import "@digiresilience/metamigo-api";
|
||||
import "@digiresilience/metamigo-worker";
|
||||
|
||||
const program = new Command();
|
||||
|
||||
export async function runServer(): Promise<void> {
|
||||
await startWithout(["worker"]);
|
||||
}
|
||||
|
||||
export async function runWorker(): Promise<void> {
|
||||
await startWithout(["server"]);
|
||||
}
|
||||
|
||||
program
|
||||
.command("config-generate")
|
||||
|
|
@ -30,16 +19,6 @@ program
|
|||
.description("Prints the entire convict config ")
|
||||
.action(listConfig);
|
||||
|
||||
program
|
||||
.command("api")
|
||||
.description("Run the application api server")
|
||||
.action(runServer);
|
||||
|
||||
program
|
||||
.command("worker")
|
||||
.description("Run the worker to process jobs")
|
||||
.action(runWorker);
|
||||
|
||||
program
|
||||
.command("db <commands...>")
|
||||
.description("Run graphile-migrate commands with your app's config loaded.")
|
||||
|
|
@ -48,16 +27,6 @@ program
|
|||
return migrateWrapper(args, config);
|
||||
});
|
||||
|
||||
program
|
||||
.command("gen-jwks")
|
||||
.description("Generate the JWKS")
|
||||
.action(generateJwks);
|
||||
|
||||
program
|
||||
.command("gen-testing-jwt")
|
||||
.description("Generate a JWT for the test suite")
|
||||
.action(createTokenForTesting);
|
||||
|
||||
program
|
||||
.command("export-graphql-schema")
|
||||
.description("Export the graphql schema")
|
||||
|
|
|
|||
|
|
@ -1,67 +0,0 @@
|
|||
import jose from "node-jose";
|
||||
import * as jwt from "jsonwebtoken";
|
||||
|
||||
const generateKeystore = async () => {
|
||||
const keystore = jose.JWK.createKeyStore();
|
||||
await keystore.generate("oct", 256, {
|
||||
alg: "A256GCM",
|
||||
use: "enc",
|
||||
});
|
||||
await keystore.generate("oct", 256, {
|
||||
alg: "HS512",
|
||||
use: "sig",
|
||||
});
|
||||
return keystore;
|
||||
};
|
||||
|
||||
const safeString = (input) =>
|
||||
Buffer.from(JSON.stringify(input)).toString("base64");
|
||||
|
||||
const stringify = (v) => JSON.stringify(v, undefined, 2);
|
||||
|
||||
const _generateJwks = async () => {
|
||||
const keystore = await generateKeystore();
|
||||
const encryption = keystore.all({ use: "enc" })[0].toJSON(true);
|
||||
const signing = keystore.all({ use: "sig" })[0].toJSON(true);
|
||||
|
||||
return {
|
||||
nextAuth: {
|
||||
signingKeyB64: safeString(signing),
|
||||
encryptionKeyB64: safeString(encryption),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const generateJwks = async (): Promise<void> => {
|
||||
console.log(stringify(await _generateJwks()));
|
||||
};
|
||||
|
||||
export const createTokenForTesting = async (): Promise<void> => {
|
||||
const keys = await _generateJwks();
|
||||
const signingKey = Buffer.from(
|
||||
JSON.parse(
|
||||
Buffer.from(keys.nextAuth.signingKeyB64, "base64").toString("utf-8")
|
||||
).k,
|
||||
"base64"
|
||||
);
|
||||
|
||||
const token = jwt.sign(
|
||||
{
|
||||
iss: "Test Env",
|
||||
iat: 1606893960,
|
||||
aud: "metamigo",
|
||||
sub: "abel@guardianproject.info",
|
||||
name: "Abel Luck",
|
||||
email: "abel@guardianproject.info",
|
||||
userRole: "admin",
|
||||
},
|
||||
signingKey,
|
||||
{ expiresIn: "100y", algorithm: "HS512" }
|
||||
);
|
||||
console.log("CONFIG");
|
||||
console.log(stringify(keys));
|
||||
console.log();
|
||||
console.log("TOKEN");
|
||||
console.log(token);
|
||||
console.log();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue