1.1.4 • Published 2 years ago

@talaikis/contact-us v1.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Contact Us API Microservice

Features

  • Contact us microservice (on Mailgun)
  • Checks if email (really) exists
  • Internationalized

Install

npm i -S @talaikis/contact-us

Usage

import { start, config } from '@talaikis/contact-us'
// config(email, mailgunDomain, mailgunKey, recipient, serviceKey)
// for example:
const conf = config('test@test.com', 'talaikis.com', 'key-XXXXX', 'test2@test.com', 'blahblah')
start(3000, conf) // <- port

That's it, you can go to http://localhost:3000/ping

Sample request

import { post } from 'axios'

const contactApi = (name, email, message, done) => {
  const locale = 'en'
  const CONTACT_API_KEY = ''
  const CONTACT_API_URL = ''

  post(CONTACT_API_URL, {
    method: 'POST',
    msg: message,
    key: CONTACT_API_KEY,
    locale,
    name,
    email,
    headers: {
      'Content-Type': 'application/json'
    }
  })
    .then((data) => {
      done(null, data.data)
    })
    .catch((err) => {
      done({ error: err.message })
    })
}

API Responses

{ "status": "sent" } // if email is sent successfully
{ "status": "<some error>" } // if some error occurs

TODO

  • translate strings to x languages
  • more providers

Licence

MIT

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago