Docker build updates
This commit is contained in:
parent
3e36aef9c5
commit
67a5b60ad5
34 changed files with 89 additions and 52 deletions
|
|
@ -33,18 +33,15 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
|
|||
apt-get install -y --no-install-recommends \
|
||||
dumb-init
|
||||
RUN mkdir -p ${APP_DIR}
|
||||
RUN chown -R node ${APP_DIR}/
|
||||
|
||||
USER node
|
||||
WORKDIR ${APP_DIR}
|
||||
COPY --from=installer ${APP_DIR}/node_modules/ ./node_modules/
|
||||
COPY --from=installer ${APP_DIR}/apps/bridge-frontend/ ./apps/bridge-frontend/
|
||||
COPY --from=installer ${APP_DIR}/package.json ./package.json
|
||||
USER root
|
||||
RUN chown -R node:node ${APP_DIR}/
|
||||
WORKDIR ${APP_DIR}/apps/bridge-frontend/
|
||||
RUN chmod +x docker-entrypoint.sh
|
||||
USER node
|
||||
EXPOSE 3000
|
||||
ENV PORT 3000
|
||||
ENV NODE_ENV production
|
||||
ENTRYPOINT ["/opt/link/apps/bridge-frontend/docker-entrypoint.sh"]
|
||||
ENTRYPOINT ["/opt/bridge-frontend/apps/bridge-frontend/docker-entrypoint.sh"]
|
||||
|
|
|
|||
93
apps/bridge-frontend/database/migrate.ts
Normal file
93
apps/bridge-frontend/database/migrate.ts
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
import * as path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { promises as fs } from "fs";
|
||||
import {
|
||||
Kysely,
|
||||
Migrator,
|
||||
MigrationResult,
|
||||
FileMigrationProvider,
|
||||
PostgresDialect,
|
||||
CamelCasePlugin,
|
||||
} from "kysely";
|
||||
import pkg from "pg";
|
||||
const { Pool } = pkg;
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
interface Database {}
|
||||
|
||||
export const migrate = async (arg: string) => {
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
dotenv.config({ path: path.join(__dirname, "../.env.local") });
|
||||
}
|
||||
const db = new Kysely<Database>({
|
||||
dialect: new PostgresDialect({
|
||||
pool: new Pool({
|
||||
host: process.env.DATABASE_HOST,
|
||||
database: process.env.DATABASE_NAME,
|
||||
port: parseInt(process.env.DATABASE_PORT!),
|
||||
user: process.env.DATABASE_USER,
|
||||
password: process.env.DATABASE_PASSWORD,
|
||||
}),
|
||||
}),
|
||||
plugins: [new CamelCasePlugin()],
|
||||
});
|
||||
const migrator = new Migrator({
|
||||
db,
|
||||
provider: new FileMigrationProvider({
|
||||
fs,
|
||||
path,
|
||||
migrationFolder: path.join(__dirname, "migrations"),
|
||||
}),
|
||||
});
|
||||
|
||||
let error: any = null;
|
||||
let results: MigrationResult[] = [];
|
||||
|
||||
if (arg === "up:all") {
|
||||
const out = await migrator.migrateToLatest();
|
||||
results = out.results ?? [];
|
||||
error = out.error;
|
||||
} else if (arg === "up:one") {
|
||||
const out = await migrator.migrateUp();
|
||||
results = out.results ?? [];
|
||||
error = out.error;
|
||||
} else if (arg === "down:all") {
|
||||
const migrations = await migrator.getMigrations();
|
||||
for (const _ of migrations) {
|
||||
const out = await migrator.migrateDown();
|
||||
if (out.results) {
|
||||
results = results.concat(out.results);
|
||||
error = out.error;
|
||||
}
|
||||
}
|
||||
} else if (arg === "down:one") {
|
||||
const out = await migrator.migrateDown();
|
||||
if (out.results) {
|
||||
results = out.results ?? [];
|
||||
error = out.error;
|
||||
}
|
||||
}
|
||||
|
||||
results?.forEach((it) => {
|
||||
if (it.status === "Success") {
|
||||
console.log(
|
||||
`Migration "${it.migrationName} ${it.direction.toLowerCase()}" was executed successfully`,
|
||||
);
|
||||
} else if (it.status === "Error") {
|
||||
console.error(`Failed to execute migration "${it.migrationName}"`);
|
||||
}
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error("Failed to migrate");
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
await db.destroy();
|
||||
};
|
||||
|
||||
const arg = process.argv.slice(2).pop();
|
||||
migrate(arg as string);
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
import { Kysely, sql } from "kysely";
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable("User")
|
||||
.addColumn("id", "uuid", (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
||||
)
|
||||
.addColumn("name", "text")
|
||||
.addColumn("email", "text", (col) => col.unique().notNull())
|
||||
.addColumn("emailVerified", "timestamptz")
|
||||
.addColumn("image", "text")
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createTable("Account")
|
||||
.addColumn("id", "uuid", (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
||||
)
|
||||
.addColumn("userId", "uuid", (col) =>
|
||||
col.references("User.id").onDelete("cascade").notNull(),
|
||||
)
|
||||
.addColumn("type", "text", (col) => col.notNull())
|
||||
.addColumn("provider", "text", (col) => col.notNull())
|
||||
.addColumn("providerAccountId", "text", (col) => col.notNull())
|
||||
.addColumn("refresh_token", "text")
|
||||
.addColumn("access_token", "text")
|
||||
.addColumn("expires_at", "bigint")
|
||||
.addColumn("token_type", "text")
|
||||
.addColumn("scope", "text")
|
||||
.addColumn("id_token", "text")
|
||||
.addColumn("session_state", "text")
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createTable("Session")
|
||||
.addColumn("id", "uuid", (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
||||
)
|
||||
.addColumn("userId", "uuid", (col) =>
|
||||
col.references("User.id").onDelete("cascade").notNull(),
|
||||
)
|
||||
.addColumn("sessionToken", "text", (col) => col.notNull().unique())
|
||||
.addColumn("expires", "timestamptz", (col) => col.notNull())
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createTable("VerificationToken")
|
||||
.addColumn("identifier", "text", (col) => col.notNull())
|
||||
.addColumn("token", "text", (col) => col.notNull().unique())
|
||||
.addColumn("expires", "timestamptz", (col) => col.notNull())
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex("Account_userId_index")
|
||||
.on("Account")
|
||||
.column("userId")
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex("Session_userId_index")
|
||||
.on("Session")
|
||||
.column("userId")
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable("Account").ifExists().execute();
|
||||
await db.schema.dropTable("Session").ifExists().execute();
|
||||
await db.schema.dropTable("User").ifExists().execute();
|
||||
await db.schema.dropTable("VerificationToken").ifExists().execute();
|
||||
}
|
||||
35
apps/bridge-frontend/database/migrations/0002-add-signal.ts
Normal file
35
apps/bridge-frontend/database/migrations/0002-add-signal.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { Kysely, sql } from "kysely";
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable("SignalBot")
|
||||
.addColumn("id", "uuid", (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
||||
)
|
||||
.addColumn("phone_number", "text")
|
||||
.addColumn("token", "text", (col) => col.unique().notNull())
|
||||
.addColumn("user_id", "uuid")
|
||||
.addColumn("name", "text")
|
||||
.addColumn("description", "text")
|
||||
.addColumn("auth_info", "text")
|
||||
.addColumn("is_verified", "boolean", (col) =>
|
||||
col.notNull().defaultTo(false),
|
||||
)
|
||||
.addColumn("created_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn("updated_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex("SignalBotToken")
|
||||
.on("SignalBot")
|
||||
.column("token")
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable("SignalBot").ifExists().execute();
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import { Kysely, sql } from "kysely";
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable("WhatsappBot")
|
||||
.addColumn("id", "uuid", (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
||||
)
|
||||
.addColumn("phone_number", "text")
|
||||
.addColumn("token", "text", (col) => col.unique().notNull())
|
||||
.addColumn("user_id", "uuid")
|
||||
.addColumn("name", "text")
|
||||
.addColumn("description", "text")
|
||||
.addColumn("qr_code", "text")
|
||||
.addColumn("verified", "boolean", (col) => col.notNull().defaultTo(false))
|
||||
.addColumn("created_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn("updated_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex("WhatsappBotToken")
|
||||
.on("WhatsappBot")
|
||||
.column("token")
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable("WhatsappBot").ifExists().execute();
|
||||
}
|
||||
77
apps/bridge-frontend/database/migrations/0004-add-voice.ts
Normal file
77
apps/bridge-frontend/database/migrations/0004-add-voice.ts
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import { Kysely, sql } from "kysely";
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable("VoiceProvider")
|
||||
.addColumn("id", "uuid", (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
||||
)
|
||||
.addColumn("kind", "text", (col) => col.notNull())
|
||||
.addColumn("name", "text", (col) => col.notNull())
|
||||
.addColumn("description", "text")
|
||||
.addColumn("credentials", "jsonb", (col) => col.notNull())
|
||||
.addColumn("created_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn("updated_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex("VoiceProviderName")
|
||||
.on("VoiceProvider")
|
||||
.column("name")
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createTable("VoiceLine")
|
||||
.addColumn("id", "uuid", (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
||||
)
|
||||
.addColumn("provider_id", "uuid", (col) =>
|
||||
col.notNull().references("VoiceProvider.id").onDelete("cascade"),
|
||||
)
|
||||
.addColumn("provider_line_sid", "text", (col) => col.notNull())
|
||||
.addColumn("number", "text", (col) => col.notNull())
|
||||
.addColumn("name", "text", (col) => col.notNull())
|
||||
.addColumn("description", "text")
|
||||
.addColumn("language", "text", (col) => col.notNull())
|
||||
.addColumn("voice", "text", (col) => col.notNull())
|
||||
.addColumn("prompt_text", "text")
|
||||
.addColumn("prompt_audio", "jsonb")
|
||||
.addColumn("audio_prompt_enabled", "boolean", (col) =>
|
||||
col.notNull().defaultTo(false),
|
||||
)
|
||||
.addColumn("audio_converted_at", "timestamptz")
|
||||
.addColumn("created_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn("updated_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex("VoiceLineProviderId")
|
||||
.on("VoiceLine")
|
||||
.column("provider_id")
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex("VoiceLineProviderLineSid")
|
||||
.on("VoiceLine")
|
||||
.column("provider_line_sid")
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex("VoiceLineNumber")
|
||||
.on("VoiceLine")
|
||||
.column("number")
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable("VoiceLine").ifExists().execute();
|
||||
await db.schema.dropTable("VoiceProvider").ifExists().execute();
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
import { Kysely, sql } from "kysely";
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable("FacebookBot")
|
||||
.addColumn("id", "uuid", (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
||||
)
|
||||
.addColumn("name", "text")
|
||||
.addColumn("description", "text")
|
||||
.addColumn("token", "text")
|
||||
.addColumn("page_access_token", "text")
|
||||
.addColumn("app_secret", "text")
|
||||
.addColumn("verify_token", "text")
|
||||
.addColumn("page_id", "text")
|
||||
.addColumn("app_id", "text")
|
||||
.addColumn("user_id", "uuid")
|
||||
.addColumn("verified", "boolean", (col) => col.notNull().defaultTo(false))
|
||||
.addColumn("created_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn("updated_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex("FacebookBotToken")
|
||||
.on("FacebookBot")
|
||||
.column("token")
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable("FacebookBot").ifExists().execute();
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import { Kysely, sql } from "kysely";
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable("Webhook")
|
||||
.addColumn("id", "uuid", (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
||||
)
|
||||
.addColumn("name", "text", (col) => col.notNull())
|
||||
.addColumn("description", "text")
|
||||
.addColumn("backend_type", "text", (col) => col.notNull())
|
||||
.addColumn("backend_id", "uuid", (col) => col.notNull())
|
||||
.addColumn("endpoint_url", "text", (col) =>
|
||||
col.notNull().check(sql`endpoint_url ~ '^https?://[^/]+'`),
|
||||
)
|
||||
.addColumn("http_method", "text", (col) =>
|
||||
col
|
||||
.notNull()
|
||||
.defaultTo("post")
|
||||
.check(sql`http_method in ('post', 'put')`),
|
||||
)
|
||||
.addColumn("headers", "jsonb")
|
||||
.addColumn("created_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn("updated_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex("WebhookBackendTypeBackendId")
|
||||
.on("Webhook")
|
||||
.column("backend_type")
|
||||
.column("backend_id")
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable("Webhook").ifExists().execute();
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
import { Kysely, sql } from "kysely";
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable("Setting")
|
||||
.addColumn("id", "uuid", (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_random_uuid()`),
|
||||
)
|
||||
.addColumn("name", "text")
|
||||
.addColumn("value", "jsonb")
|
||||
.addColumn("created_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn("updated_at", "timestamptz", (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex("SettingName")
|
||||
.on("Setting")
|
||||
.column("name")
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema.dropTable("Setting").ifExists().execute();
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
echo "running migrations"
|
||||
npm run migrate:up:all
|
||||
echo "starting bridge-frontend"
|
||||
exec dumb-init npm run start
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@
|
|||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
"lint": "next lint",
|
||||
"migrate:up:all": "tsx database/migrate.ts up:all",
|
||||
"migrate:up:one": "tsx database/migrate.ts up:one",
|
||||
"migrate:down:all": "tsx database/migrate.ts down:all",
|
||||
"migrate:down:one": "tsx database/migrate.ts down:one"
|
||||
},
|
||||
"dependencies": {
|
||||
"@auth/kysely-adapter": "^1.1.0",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
FROM node:18-alpine as base
|
||||
FROM node:20-bookworm AS base
|
||||
|
||||
FROM base AS builder
|
||||
ARG APP_DIR=/opt/bridge-worker
|
||||
|
|
@ -11,22 +11,26 @@ RUN turbo prune --scope=bridge-worker --docker
|
|||
FROM base AS installer
|
||||
ARG APP_DIR=/opt/bridge-worker
|
||||
WORKDIR ${APP_DIR}
|
||||
COPY --from=builder ${APP_DIR}/.gitignore .gitignore
|
||||
COPY --from=builder ${APP_DIR}/out/json/ .
|
||||
COPY --from=builder ${APP_DIR}/out/package-lock.json ./package-lock.json
|
||||
COPY --from=builder ${APP_DIR}/out/full/ .
|
||||
COPY --from=builder ${APP_DIR}/out/package-lock.json ./package-lock.json
|
||||
RUN npm ci
|
||||
RUN npm i -g turbo
|
||||
RUN turbo run build --filter=bridge-worker
|
||||
|
||||
FROM graphile/worker:0.16.5 as runner
|
||||
FROM base as runner
|
||||
ARG BUILD_DATE
|
||||
ARG VERSION
|
||||
ARG APP_DIR=/opt/bridge-worker
|
||||
RUN mkdir -p ${APP_DIR}/
|
||||
ARG BUILD_DIR=${APP_DIR}/apps/bridge-worker/build/main
|
||||
RUN mkdir -p ${APP_DIR}/
|
||||
WORKDIR /worker
|
||||
COPY --from=installer ${BUILD_DIR}/lib ${APP_DIR}/lib
|
||||
COPY --from=installer ${BUILD_DIR}/tasks ${APP_DIR}/tasks
|
||||
COPY --from=installer ${APP_DIR}/apps/bridge-worker/graphile.config.prod.js ./graphile.config.js
|
||||
COPY --from=installer ${APP_DIR}/node_modules ${APP_DIR}/node_modules
|
||||
COPY --from=installer ${APP_DIR}/package.json ${APP_DIR}/package.json
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
dumb-init
|
||||
WORKDIR ${APP_DIR}
|
||||
COPY --from=installer ${APP_DIR} ./
|
||||
RUN chown -R node:node ${APP_DIR}
|
||||
WORKDIR ${APP_DIR}/apps/bridge-worker/
|
||||
RUN chmod +x docker-entrypoint.sh
|
||||
USER node
|
||||
ENV NODE_ENV production
|
||||
ENTRYPOINT ["/opt/bridge-worker/apps/bridge-worker/docker-entrypoint.sh"]
|
||||
|
|
|
|||
5
apps/bridge-worker/docker-entrypoint.sh
Normal file
5
apps/bridge-worker/docker-entrypoint.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
echo "starting bridge-worker"
|
||||
exec dumb-init npm run start
|
||||
|
|
@ -4,7 +4,7 @@ module.exports = {
|
|||
maxPoolSize: 10,
|
||||
pollInterval: 2000,
|
||||
concurrentJobs: 3,
|
||||
taskDirectory: "/opt/bridge/tasks",
|
||||
taskDirectory: "/opt/bridge-worker/apps/bridge-worker/build/main/tasks",
|
||||
fileExtensions: [".js", ".cjs", ".mjs"],
|
||||
},
|
||||
};
|
||||
|
|
|
|||
26
apps/bridge-worker/index.ts
Normal file
26
apps/bridge-worker/index.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { run } from "graphile-worker";
|
||||
import * as path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const startWorker = async () => {
|
||||
await run({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
concurrency: 10,
|
||||
noHandleSignals: false,
|
||||
pollInterval: 1000,
|
||||
taskDirectory: `${__dirname}/tasks`,
|
||||
// crontabFile: `${__dirname}/crontab`,
|
||||
});
|
||||
};
|
||||
|
||||
const main = async () => {
|
||||
await startWorker();
|
||||
};
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// import { SavedVoiceProvider } from "@digiresilience/bridge-db";
|
||||
import Twilio from "twilio";
|
||||
import { CallInstance } from "twilio/lib/rest/api/v2010/account/call";
|
||||
import { Zammad, getOrCreateUser } from "./zammad";
|
||||
import { Zammad, getOrCreateUser } from "./zammad.js";
|
||||
|
||||
type SavedVoiceProvider = any;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@
|
|||
"name": "bridge-worker",
|
||||
"version": "0.2.0",
|
||||
"type": "module",
|
||||
"main": "build/main/index.js",
|
||||
"author": "Darren Clarke <darren@redaranj.com>",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"dev": "dotenv -- graphile-worker"
|
||||
"dev": "dotenv -- graphile-worker",
|
||||
"start": "node build/main/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hapi/wreck": "^18.1.0",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
/* eslint-disable camelcase */
|
||||
import { convert } from "html-to-text";
|
||||
import { URLSearchParams } from "url";
|
||||
import { withDb, AppDatabase } from "../../lib/db";
|
||||
import { withDb, AppDatabase } from "../../lib/db.js";
|
||||
// import { loadConfig } from "@digiresilience/bridge-config";
|
||||
import { tagMap } from "../../lib/tag-map";
|
||||
import { tagMap } from "../../lib/tag-map.js";
|
||||
|
||||
const config: any = {};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable camelcase */
|
||||
import { URLSearchParams } from "url";
|
||||
import { withDb, AppDatabase } from "../../lib/db";
|
||||
import { withDb, AppDatabase } from "../../lib/db.js";
|
||||
// import { loadConfig } from "@digiresilience/bridge-config";
|
||||
|
||||
const config: any = {};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { db, getWorkerUtils } from "bridge-common";
|
||||
// import { db, getWorkerUtils } from "bridge-common";
|
||||
|
||||
interface ReceiveSignalMessageTaskOptions {
|
||||
message: any;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { db, getWorkerUtils } from "bridge-common";
|
||||
// import { db, getWorkerUtils } from "bridge-common";
|
||||
|
||||
interface SendSignalMessageTaskOptions {
|
||||
message: any;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/* eslint-disable camelcase */
|
||||
// import logger from "../logger";
|
||||
// import { IncomingMessagev1 } from "@digiresilience/node-signald/build/main/generated";
|
||||
import { withDb, AppDatabase } from "../../lib/db";
|
||||
import workerUtils from "../../lib/utils";
|
||||
import { withDb, AppDatabase } from "../../lib/db.js";
|
||||
import workerUtils from "../../lib/utils.js";
|
||||
|
||||
type IncomingMessagev1 = any;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { db, getWorkerUtils } from "bridge-common";
|
||||
// import { db, getWorkerUtils } from "bridge-common";
|
||||
|
||||
interface ReceiveVoiceMessageTaskOptions {
|
||||
message: any;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { db, getWorkerUtils } from "bridge-common";
|
||||
// import { db, getWorkerUtils } from "bridge-common";
|
||||
|
||||
interface SendVoiceMessageTaskOptions {
|
||||
message: any;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import Wreck from "@hapi/wreck";
|
||||
import { withDb, AppDatabase } from "../../lib/db";
|
||||
import { twilioClientFor } from "../../lib/common";
|
||||
import { withDb, AppDatabase } from "../../lib/db.js";
|
||||
import { twilioClientFor } from "../../lib/common.js";
|
||||
import { CallInstance } from "twilio/lib/rest/api/v2010/account/call";
|
||||
import workerUtils from "../../lib/utils";
|
||||
import workerUtils from "../../lib/utils.js";
|
||||
|
||||
interface WebhookPayload {
|
||||
startTime: string;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { createHash } from "crypto";
|
||||
import { withDb, AppDatabase } from "../../lib/db";
|
||||
import { convert } from "../../lib/media-convert";
|
||||
import { withDb, AppDatabase } from "../../lib/db.js";
|
||||
import { convert } from "../../lib/media-convert.js";
|
||||
|
||||
interface VoiceLineAudioUpdateTaskOptions {
|
||||
voiceLineId: string;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import Twilio from "twilio";
|
||||
// import config from "@digiresilience/bridge-config";
|
||||
import { withDb, AppDatabase } from "../../lib/db";
|
||||
import { withDb, AppDatabase } from "../../lib/db.js";
|
||||
|
||||
const config: any = {};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import Twilio from "twilio";
|
||||
// import config from "@digiresilience/bridge-config";
|
||||
import { withDb, AppDatabase } from "../../lib/db";
|
||||
import { withDb, AppDatabase } from "../../lib/db.js";
|
||||
|
||||
const config: any = {};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { db, getWorkerUtils } from "bridge-common";
|
||||
// import { db, getWorkerUtils } from "bridge-common";
|
||||
|
||||
interface ReceiveWhatsappMessageTaskOptions {
|
||||
message: any;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { db, getWorkerUtils } from "bridge-common";
|
||||
// import { db, getWorkerUtils } from "bridge-common";
|
||||
|
||||
interface SendWhatsappMessageTaskOptions {
|
||||
message: any;
|
||||
|
|
|
|||
|
|
@ -2,17 +2,19 @@
|
|||
"extends": "ts-config",
|
||||
"compilerOptions": {
|
||||
"outDir": "build/main",
|
||||
"module": "CommonJS",
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"ts-node": {
|
||||
"esm": true,
|
||||
"experimentalSpecifierResolution": "node",
|
||||
"transpileOnly": true,
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "ESNext",
|
||||
"module": "esNext",
|
||||
"target": "esNext",
|
||||
"moduleResolution": "node"
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
FROM node:20-bookworm AS base
|
||||
|
||||
FROM base AS builder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue