Tips and Helpers
This is the best way to get env and also env.isProd or env.isTest
import { const env: EnvType
env } from 'green_dot'
const env: EnvType
env.isProd: boolean
isProd // booleanconst env: EnvType
env.isTest: boolean
isTest // booleanconst env: EnvType
env.env: Env
env // 'production' | 'development' | 'test'
Get Model Type
Section titled “Get Model Type”Get model type safely like:
import { type ModelTypes = { [x: string]: Record<string, any>;}
ModelTypes, type MainDbName = string
MainDbName } from 'green_dot'
type type User = { [x: string]: any;}
User = type ModelTypes = { [x: string]: Record<string, any>;}
ModelTypes['user']type type UserWrite = { [x: string]: any;}
UserWrite = type ModelTypes = { [x: string]: Record<string, any>;}
ModelTypes['userWrite']type type MyModelWrite = { [x: string]: any;}
MyModelWrite = type ModelTypes = { [x: string]: Record<string, any>;}
ModelTypes['myModelWrite']
// You also have a type for the default db name: MainDbName
sendEmail
Section titled “sendEmail”Send an email with the configured smtp config
import { function sendEmail(ctx: any, subject: any, content: any, recipients?: string | string[], { useTestAccount, smtpConfig, fromAddress, attachments, vars, useAwsSmtp }?: SendEmailConfig): Promise<any>
sendEmail } from 'green_dot'
function sendEmail(ctx: any, subject: any, content: any, recipients?: string | string[], { useTestAccount, smtpConfig, fromAddress, attachments, vars, useAwsSmtp }?: SendEmailConfig): Promise<any>
sendEmail()