From 3e200e28798249bf5ba1a065503b6809deea4372 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Fri, 2 Jul 2021 22:56:12 +0800 Subject: [PATCH] refactor: use `conditional()` from essentials --- packages/core/src/oidc/adapter.ts | 2 +- packages/core/src/utils.ts | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/core/src/oidc/adapter.ts b/packages/core/src/oidc/adapter.ts index f41d439fd..645c6878b 100644 --- a/packages/core/src/oidc/adapter.ts +++ b/packages/core/src/oidc/adapter.ts @@ -1,10 +1,10 @@ import dayjs from 'dayjs'; import { AdapterFactory } from 'oidc-provider'; import { IdentifierSqlTokenType, sql, ValueExpressionType } from 'slonik'; +import { conditional } from '@logto/essentials'; import { OidcModelInstances, OidcModelInstanceDBEntry } from '@logto/schemas'; import pool from '@/database/pool'; import { convertToIdentifiers } from '@/database/utils'; -import { conditional } from '@/utils'; export default function postgresAdapter(modelName: string) { const { table, fields } = convertToIdentifiers(OidcModelInstances); diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index 2e4f689ca..901c183be 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -1,11 +1,5 @@ import assert from 'assert'; -export type Optional = T | undefined; -export type Falsy = 0 | undefined | null | false | ''; - -export const conditional = (value: T | Falsy): Optional => (value ? value : undefined); -export const conditionalString = (value: string | Falsy): string => (value ? value : ''); - export const getEnv = (key: string, fallback = ''): string => process.env[key] ?? fallback; export const assertEnv = (key: string): string => { const value = process.env[key];