Skip to content

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
// boolean
const env: EnvType
env
.
isTest: boolean
isTest
// boolean
const env: EnvType
env
.
env: Env
env
// 'production' | 'development' | 'test'

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

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
()