Skip to main content
Go to Latest
File

utilities

encrypt

Encrypt a message using AES-GCM algorithm.

import { encrypt } from 'darkflare/x'

const hash = await encrypt(message, secret)

decrypt

Decrypt a message using AES-GCM algorithm.

import { decrypt } from 'darkflare/x'

const message = await decrypt(hash, secret)

error

Get a json object or text based on the accept header of the incoming request for a error message or code.

import { Get } from 'darkflare'
import { error } from 'darkflare/x'

Get({}, c => {
  return error(c, 'BAD_REQUEST') // { code: 400, message: 'Bad Request' } | 'Bad Request'

  // alternatively, you can specify a error code:
  return error(c, 400)
})

parseUserAgent

Parse the user agent from the fetch context.

import { parseUserAgent } from 'darkflare/x'

const userAgent = parseUserAgent(c)

sendMail

Send a email using mailchannels.

import { sendMail } from 'darkflare/x'

sendMail(c, {
  subject: 'Hello',
  message: 'Hello',
  from: {
    name: 'John Doe',
    email: 'john@doma.in',
  },
  to: 'jane@doma.in',
  wait: true // wait until it's sent - disabled by default
})