metamigo-api: runs in docker now

* great typescript module import refactor
* refactor metamigo-cli so it is the entrypoint for the db, api, and
  worker
This commit is contained in:
Abel Luck 2023-06-02 14:05:20 +00:00
parent b45e2e8c11
commit 696ba16cb7
78 changed files with 319 additions and 180 deletions

View file

@ -1,6 +1,8 @@
import process from "node:process";
import { existsSync } from "node:fs";
import path from "node:path";
import { exec } from "node:child_process";
import { fileURLToPath } from 'node:url';
import type { IAppConfig } from "@digiresilience/metamigo-config";
/**
@ -34,10 +36,11 @@ export const migrateWrapper = async (
DATABASE_VISITOR: config.postgraphile.visitor,
};
const cmd = `npx --no-install graphile-migrate ${commands.join(" ")}`;
const dbDir = `../../db`;
const gmrc = `${dbDir}/.gmrc`;
if (!existsSync(gmrc)) {
throw new Error(`graphile migrate config not found at ${gmrc}`);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const dbDir = path.resolve(__dirname, '../../');
const gmrcPath = path.resolve(__dirname, '../../.gmrc');
if (!existsSync(gmrcPath)) {
throw new Error(`graphile migrate config not found at ${gmrcPath}`);
}
if (!silent) console.log("executing:", cmd);

View file

@ -2,7 +2,7 @@ import type { IAppConfig } from "@digiresilience/metamigo-config";
import camelcaseKeys from "camelcase-keys";
import PgSimplifyInflectorPlugin from "@graphile-contrib/pg-simplify-inflector";
import PgManyToManyPlugin from "@graphile-contrib/pg-many-to-many";
import * as ConnectionFilterPlugin from "postgraphile-plugin-connection-filter";
import ConnectionFilterPlugin from "postgraphile-plugin-connection-filter";
import type { PostGraphileOptions } from "postgraphile";
import {
@ -20,7 +20,7 @@ import {
WhatsappMessageRecordRepository,
WhatsappAttachmentRecordRepository,
SignalBotRecordRepository,
} from "./records";
} from "./records/index.js";
import type { IInitOptions, IDatabase } from "pg-promise";
@ -83,5 +83,5 @@ export const getPostGraphileOptions = (): PostGraphileOptions => ({
],
});
export * from "./helpers";
export * from "./records";
export * from "./helpers.js";
export * from "./records/index.js";

View file

@ -1,9 +1,9 @@
export * from "./settings";
export * from "./signal/bots";
export * from "./whatsapp/bots";
export * from "./whatsapp/messages";
export * from "./whatsapp/attachments";
export * from "./settings";
export * from "./voice/voice-line";
export * from "./voice/voice-provider";
export * from "./webhooks";
export * from "./settings.js";
export * from "./signal/bots.js";
export * from "./whatsapp/bots.js";
export * from "./whatsapp/messages.js";
export * from "./whatsapp/attachments.js";
export * from "./settings.js";
export * from "./voice/voice-line.js";
export * from "./voice/voice-provider.js";
export * from "./webhooks.js";