npm run fmt
This commit is contained in:
parent
21fe35da05
commit
11c595619d
21 changed files with 155 additions and 137 deletions
|
|
@ -7,7 +7,8 @@ export const registerNextAuth = async (
|
|||
server: Hapi.Server,
|
||||
config: IAppConfig
|
||||
): Promise<void> => {
|
||||
const nextAuthAdapterFactory: any = (request: Hapi.Request) => new NextAuthAdapter(request.db());
|
||||
const nextAuthAdapterFactory: any = (request: Hapi.Request) =>
|
||||
new NextAuthAdapter(request.db());
|
||||
|
||||
await server.register({
|
||||
plugin: NextAuthPlugin,
|
||||
|
|
|
|||
|
|
@ -38,5 +38,5 @@ export const register = async (
|
|||
await registerSwagger(server);
|
||||
await registerCloudflareAccessJwt(server, config);
|
||||
await registerAuthBearer(server, config);
|
||||
await registerPostgraphile(server, config)
|
||||
await registerPostgraphile(server, config);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export const VoiceProviderRoutes = Helpers.withDefaults([
|
|||
},
|
||||
]);
|
||||
|
||||
class VoiceLineRecordController extends CrudControllerBase(VoiceLineRecord) { }
|
||||
class VoiceLineRecordController extends CrudControllerBase(VoiceLineRecord) {}
|
||||
|
||||
const validator = (): Record<string, Hapi.RouteOptionsValidate> => ({
|
||||
create: {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ export const TwilioRoutes = Helpers.noAuth([
|
|||
},
|
||||
async handler(request: Hapi.Request, _h: Hapi.ResponseToolkit) {
|
||||
const { voiceLineId } = request.params;
|
||||
const { To } = request.payload as { To: string; };
|
||||
const { To } = request.payload as { To: string };
|
||||
const voiceLine = await request.db().voiceLines.findBy({ number: To });
|
||||
if (!voiceLine) return Boom.notFound();
|
||||
if (voiceLine.id !== voiceLineId) return Boom.badRequest();
|
||||
|
|
@ -193,7 +193,7 @@ export const TwilioRoutes = Helpers.noAuth([
|
|||
},
|
||||
},
|
||||
async handler(request: Hapi.Request, h: Hapi.ResponseToolkit) {
|
||||
const { providerId } = request.params as { providerId: string; };
|
||||
const { providerId } = request.params as { providerId: string };
|
||||
const provider: SavedVoiceProvider = await request
|
||||
.db()
|
||||
.voiceProviders.findById({ id: providerId });
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
export * from "./server/index.js"
|
||||
export * from "./logger.js"
|
||||
|
||||
export * from "./server/index.js";
|
||||
export * from "./logger.js";
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
export {default as AppBar} from "./AppBar";
|
||||
export {default as Layout} from "./Layout";
|
||||
export {default as Menu} from "./Menu";
|
||||
export { default as AppBar } from "./AppBar";
|
||||
export { default as Layout } from "./Layout";
|
||||
export { default as Menu } from "./Menu";
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ export const theme = {
|
|||
background: {
|
||||
default: "#fff",
|
||||
},
|
||||
getContrastText(color: string) { return color === "#ffffff" ? "#000" : "#fff"; },
|
||||
getContrastText(color: string) {
|
||||
return color === "#ffffff" ? "#000" : "#fff";
|
||||
},
|
||||
},
|
||||
shape: {
|
||||
borderRadius: 5,
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ const customEnglishMessages: TranslationMessages = {
|
|||
signalBots: {
|
||||
name: "Signal Bot |||| Signal Bots",
|
||||
verifyDialog: {
|
||||
sms:
|
||||
"Please enter the verification code sent via SMS to %{phoneNumber}",
|
||||
sms: "Please enter the verification code sent via SMS to %{phoneNumber}",
|
||||
voice:
|
||||
"Please answer the call from Signal to %{phoneNumber} and enter the verification code",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -100,12 +100,14 @@ export const getIdentity = async (
|
|||
|
||||
const cloudflareAccountProvider = "cloudflare-access";
|
||||
|
||||
const cloudflareAuthorizeCallback = (
|
||||
const cloudflareAuthorizeCallback =
|
||||
(
|
||||
req: IncomingMessage,
|
||||
domain: string,
|
||||
verifier: VerifyFn,
|
||||
adapter: Adapter
|
||||
): (() => Promise<any>) => async () => {
|
||||
): (() => Promise<any>) =>
|
||||
async () => {
|
||||
/*
|
||||
|
||||
lots of little variables in here.
|
||||
|
|
@ -186,7 +188,7 @@ const cloudflareAuthorizeCallback = (
|
|||
);
|
||||
|
||||
return user;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param audience the cloudflare access audience id
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
/* eslint-disable unicorn/no-null */
|
||||
import type { Adapter, AdapterAccount, AdapterSession, AdapterUser } from "next-auth/adapters";
|
||||
import type {
|
||||
Adapter,
|
||||
AdapterAccount,
|
||||
AdapterSession,
|
||||
AdapterUser,
|
||||
} from "next-auth/adapters";
|
||||
import * as Wreck from "@hapi/wreck";
|
||||
import * as Boom from "@hapi/boom";
|
||||
|
||||
|
|
@ -15,7 +20,7 @@ export interface Profile {
|
|||
createdBy: string;
|
||||
}
|
||||
|
||||
export type User = Profile & { id: string; createdAt: Date; updatedAt: Date; };
|
||||
export type User = Profile & { id: string; createdAt: Date; updatedAt: Date };
|
||||
|
||||
export interface Session {
|
||||
userId: string;
|
||||
|
|
@ -103,7 +108,13 @@ export const MetamigoAdapter = (config: IAppConfig): Adapter => {
|
|||
}
|
||||
}
|
||||
|
||||
async function getUserByAccount({ providerAccountId, provider }: { providerAccountId: string, provider: string }) {
|
||||
async function getUserByAccount({
|
||||
providerAccountId,
|
||||
provider,
|
||||
}: {
|
||||
providerAccountId: string;
|
||||
provider: string;
|
||||
}) {
|
||||
try {
|
||||
const { payload } = await wreck.get(
|
||||
`getUserByAccount/${provider}/${providerAccountId}`
|
||||
|
|
@ -112,7 +123,7 @@ export const MetamigoAdapter = (config: IAppConfig): Adapter => {
|
|||
return payload;
|
||||
} catch (error) {
|
||||
if (Boom.isBoom(error, 404)) return null;
|
||||
console.log(error)
|
||||
console.log(error);
|
||||
throw new Error("GET_USER_BY_ACCOUNT");
|
||||
}
|
||||
}
|
||||
|
|
@ -129,12 +140,10 @@ export const MetamigoAdapter = (config: IAppConfig): Adapter => {
|
|||
}
|
||||
}
|
||||
|
||||
async function linkAccount(
|
||||
account: AdapterAccount
|
||||
) {
|
||||
async function linkAccount(account: AdapterAccount) {
|
||||
try {
|
||||
await wreck.put("linkAccount", {payload: account} as any );
|
||||
} catch(error) {
|
||||
await wreck.put("linkAccount", { payload: account } as any);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw new Error("LINK_ACCOUNT_ERROR");
|
||||
}
|
||||
|
|
@ -142,25 +151,33 @@ export const MetamigoAdapter = (config: IAppConfig): Adapter => {
|
|||
|
||||
async function createSession(user: User) {
|
||||
try {
|
||||
const { payload }: {payload: AdapterSession} = await wreck.post("createSession", {
|
||||
const { payload }: { payload: AdapterSession } = await wreck.post(
|
||||
"createSession",
|
||||
{
|
||||
payload: user,
|
||||
});
|
||||
payload.expires = new Date(payload.expires)
|
||||
}
|
||||
);
|
||||
payload.expires = new Date(payload.expires);
|
||||
return payload;
|
||||
} catch(error) {
|
||||
console.log(error)
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw new Error("CREATE_SESSION_ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
async function getSessionAndUser(sessionToken: string) {
|
||||
try {
|
||||
const {payload}: {payload: any} = await wreck.get(`getSessionAndUser/${sessionToken}`);
|
||||
const { session, user }: {session: AdapterSession, user: AdapterUser} = payload;
|
||||
session.expires = new Date(session.expires)
|
||||
return {session, user}
|
||||
const { payload }: { payload: any } = await wreck.get(
|
||||
`getSessionAndUser/${sessionToken}`
|
||||
);
|
||||
const {
|
||||
session,
|
||||
user,
|
||||
}: { session: AdapterSession; user: AdapterUser } = payload;
|
||||
session.expires = new Date(session.expires);
|
||||
return { session, user };
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
console.log(error);
|
||||
if (Boom.isBoom(error, 404)) return null;
|
||||
throw new Error("GET_SESSION_AND_USER_ERROR");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ export const E164Regex = /^\+[1-9]\d{1,14}$/;
|
|||
/**
|
||||
* Returns true if the number is a valid E164 number
|
||||
*/
|
||||
export const isValidE164Number = (phoneNumber: string) => E164Regex.test(phoneNumber);
|
||||
export const isValidE164Number = (phoneNumber: string) =>
|
||||
E164Regex.test(phoneNumber);
|
||||
|
||||
/**
|
||||
* Given a phone number approximation, will clean out whitespace and punctuation.
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
"test": "echo no tests",
|
||||
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.graphql && next lint && prettier --ignore-path .eslintignore \"**/*.{js,jsx,ts,tsx,graphql,md}\" --write",
|
||||
"fix:lint": "eslint --ext .js,.jsx,.ts,.tsx,.graphql --fix",
|
||||
"fmt": "prettier --ignore-path .eslintignore \"**/*.{js,jsx,ts,tsx,graphql,md}\" --list-different"
|
||||
"fmt": "prettier --ignore-path .eslintignore \"**/*.{js,jsx,ts,tsx,graphql,md}\" --write"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next/eslint-plugin-next": "^13.4.4",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
"dev": "dotenv -- turbo run dev --concurrency 30",
|
||||
"build": "turbo build --concurrency 30",
|
||||
"dev:metamigo": "make dev-metamigo && dotenv -- turbo run dev --concurrency 30 --filter=!link --filter=!leafcutter",
|
||||
"migrate": "dotenv -- npm run migrate --workspace=@digiresilience/metamigo-cli"
|
||||
"migrate": "dotenv -- npm run migrate --workspace=@digiresilience/metamigo-cli",
|
||||
"fmt": "turbo run fmt"
|
||||
},
|
||||
"packageManager": "npm@9.3.1",
|
||||
"workspaces": [
|
||||
|
|
|
|||
|
|
@ -62,8 +62,7 @@ const register = async (
|
|||
server: Hapi.Server,
|
||||
pluginOpts?: any
|
||||
): Promise<void> => {
|
||||
const options: any =
|
||||
Hoek.applyToDefaults(
|
||||
const options: any = Hoek.applyToDefaults(
|
||||
// a little type gymnastics here to workaround poor typing
|
||||
defaultOptions as any,
|
||||
pluginOpts
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ import type { Adapter } from "next-auth/adapters";
|
|||
import type { NumberSchema, StringSchema, ObjectSchema } from "joi";
|
||||
import type { Request } from "@hapi/hapi";
|
||||
|
||||
export type AdapterFactory = (
|
||||
request: Request
|
||||
) => Adapter;
|
||||
export type AdapterFactory = (request: Request) => Adapter;
|
||||
|
||||
export interface NextAuthPluginOptions {
|
||||
nextAuthAdapterFactory: Adapter;
|
||||
|
|
|
|||
|
|
@ -268,60 +268,60 @@ export const configSchema = {
|
|||
doc: "The full base zammad api url",
|
||||
format: String,
|
||||
default: undefined,
|
||||
env: "ZAMMAD_API_URL"
|
||||
env: "ZAMMAD_API_URL",
|
||||
},
|
||||
zammadApiKey: {
|
||||
doc: "The zammad api key",
|
||||
format: String,
|
||||
default: undefined,
|
||||
sensitive: true,
|
||||
env: "ZAMMAD_API_KEY"
|
||||
env: "ZAMMAD_API_KEY",
|
||||
},
|
||||
labelStudioApiUrl: {
|
||||
doc: "The full base label studio api url",
|
||||
format: String,
|
||||
default: undefined,
|
||||
env: "LABEL_STUDIO_API_URL"
|
||||
env: "LABEL_STUDIO_API_URL",
|
||||
},
|
||||
labelStudioApiKey: {
|
||||
doc: "The label studio api key",
|
||||
format: String,
|
||||
default: undefined,
|
||||
sensitive: true,
|
||||
env: "LABEL_STUDIO_API_KEY"
|
||||
env: "LABEL_STUDIO_API_KEY",
|
||||
},
|
||||
contributorId: {
|
||||
doc: "The leafcutter contributor id",
|
||||
format: String,
|
||||
default: undefined,
|
||||
env: "LEAFCUTTER_CONTRIBUTOR_ID"
|
||||
env: "LEAFCUTTER_CONTRIBUTOR_ID",
|
||||
},
|
||||
contributorName: {
|
||||
doc: "The leafcutter contributor name",
|
||||
format: String,
|
||||
default: undefined,
|
||||
env: "LEAFCUTTER_CONTRIBUTOR_NAME"
|
||||
env: "LEAFCUTTER_CONTRIBUTOR_NAME",
|
||||
},
|
||||
opensearchApiUrl: {
|
||||
doc: "The opensearch api url",
|
||||
format: String,
|
||||
default: undefined,
|
||||
env: "OPENSEARCH_API_URL"
|
||||
env: "OPENSEARCH_API_URL",
|
||||
},
|
||||
opensearchUsername: {
|
||||
doc: "The opensearch username",
|
||||
format: String,
|
||||
default: undefined,
|
||||
env: "OPENSEARCH_USERNAME"
|
||||
env: "OPENSEARCH_USERNAME",
|
||||
},
|
||||
opensearchPassword: {
|
||||
doc: "The opensearch password",
|
||||
format: String,
|
||||
default: undefined,
|
||||
sensative: true,
|
||||
env: "OPENSEARCH_PASSWORD"
|
||||
env: "OPENSEARCH_PASSWORD",
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
// define the interfaces for the concrete config objects
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ 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 { fileURLToPath } from "node:url";
|
||||
import type { IAppConfig } from "@digiresilience/metamigo-config";
|
||||
|
||||
/**
|
||||
|
|
@ -37,8 +37,8 @@ export const migrateWrapper = async (
|
|||
};
|
||||
const cmd = `npx --no-install graphile-migrate ${commands.join(" ")}`;
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const dbDir = path.resolve(__dirname, '../../');
|
||||
const gmrcPath = path.resolve(__dirname, '../../.gmrc');
|
||||
const dbDir = path.resolve(__dirname, "../../");
|
||||
const gmrcPath = path.resolve(__dirname, "../../.gmrc");
|
||||
if (!existsSync(gmrcPath)) {
|
||||
throw new Error(`graphile migrate config not found at ${gmrcPath}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,5 +50,4 @@ export class WhatsappBotRecordRepository extends RepositoryBase(
|
|||
[this.schemaTable, verified, bot.id]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue