UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

44 lines (37 loc) 1.23 kB
// tslint:disable:no-console import * as mongoose from 'mongoose'; import { chevre } from '../../../lib/index'; // const project = { id: String(process.env.PROJECT_ID) }; async function main() { await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false }); const sendGridCredentials = await chevre.credentials.SendGrid.createInstance({ apiKey: <string>process.env.SENDGRID_API_KEY, alert: { sender: { name: 'sample', email: String(process.env.SENDGRID_ALERT_SENDER_EMAIL) }, toRecipient: [ { email: String(process.env.SENDGRID_ALERT_RECIPIENT_EMAIL) } ] } }); const result = await (await chevre.service.notification.createService()).notifyByEmail({ subject: 'sample', content: 'sample', logLevel: 'error' })( {}, { sendGrid: sendGridCredentials } ); // tslint:disable-next-line:no-null-keyword console.dir(result, { depth: null }); } main() .then(console.log) .catch((error) => { // tslint:disable-next-line:no-null-keyword console.dir(error, { depth: null }); });