Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@talaikis/contact-us

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@talaikis/contact-us - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

test.js

73

api.js

@@ -6,34 +6,38 @@ import { join } from 'path'

import { sendEmail } from './email'
import { config } from './config'
import { t, setLocale } from './translations'
const app = express()
app.use(require('compression')())
app.use(require('body-parser').json())
app.use(require('cors')())
const appStart = (conf) => {
if (typeof conf !== 'object') {
throw 'Configuration is not an object'
}
app.get('/favicon.ico', (req, res) => {
res.sendFile(join(__dirname, 'static', 'favicon.ico'))
})
app.use(require('compression')())
app.use(require('body-parser').json())
app.use(require('cors')())
app.get('/', (req, res) => {
res.sendFile(join(__dirname, 'static', 'index.html'))
})
app.get('/favicon.ico', (req, res) => {
res.sendFile(join(__dirname, 'static', 'favicon.ico'))
})
app.post('/contactus', (req, res) => {
const email = typeof req.body.email === 'string' ? req.body.email : false
const msg = typeof req.body.msg === 'string' ? req.body.msg : false
const name = typeof req.body.name === 'string' ? req.body.name : false
const locale = typeof req.body.locale === 'string' ? req.body.locale : 'en'
const validKey = req.body.key ? req.body.key === config.clientKey : false
if (validKey) {
if (locale !== 'en') {
setLocale(locale)
}
app.get('/', (req, res) => {
res.sendFile(join(__dirname, 'static', 'index.html'))
})
if (email && msg && name) {
legit(email).then((response) => {
app.post('/contactus', (req, res) => {
const email = typeof req.body.email === 'string' ? req.body.email : false
const msg = typeof req.body.msg === 'string' ? req.body.msg : false
const name = typeof req.body.name === 'string' ? req.body.name : false
const locale = typeof req.body.locale === 'string' ? req.body.locale : 'en'
const validKey = req.body.key ? req.body.key === conf.clientKey : false
if (validKey) {
if (locale !== 'en') {
setLocale(locale)
}
if (email && msg && name) {
legit(email).then((response) => {
if (response.isValid) {
const subject = `Message from: ${name}`
sendEmail(email, subject, msg, (err) => {
sendEmail(email, subject, msg, conf, (err) => {
res.setHeader('Content-Type', 'application/json')

@@ -52,18 +56,21 @@ if (!err.error) {

})
} else {
res.end(JSON.stringify({ status: t('error_required') }))
}
} else {
res.end(JSON.stringify({ status: t('error_required') }))
res.end(JSON.stringify({ status: t('unauthorized') }))
}
} else {
res.end(JSON.stringify({ status: t('unauthorized') }))
}
})
})
app.get('/ping', (req, res) => {
res.send('OK')
})
app.get('/ping', (req, res) => {
res.send('OK')
})
return app
}
/*
process.on('uncaughtException', (err) => {
console.log(`Caught exception: ${err.message}`)
})
export default app
*/
export default appStart

@@ -1,10 +0,2 @@

const { strictEqual } = require('assert')
module.exports.config = (email, domain, mailgunKey, to, serviceKey) => {
strictEqual(typeof email, 'string')
strictEqual(typeof mailgunKey, 'string')
strictEqual(typeof to, 'string')
strictEqual(typeof domain, 'string')
strictEqual(typeof serviceKey, 'string')
module.exports = (email, domain, mailgunKey, to, serviceKey) => {
return {

@@ -11,0 +3,0 @@ tlsEmail: email,

import { sendMailgunEmail } from './mailgun'
import { config } from '../config'
import config from '../config'
const sendEmail = config.emailProvider === 'mailgun' ? sendMailgunEmail : {}
const sendEmail = config().emailProvider === 'mailgun' ? sendMailgunEmail : {}

@@ -6,0 +6,0 @@ export {

@@ -1,11 +0,4 @@

import { strictEqual } from 'assert'
import { config } from '../config'
import { request } from '../utils'
strictEqual(typeof config().domainName, 'string')
strictEqual(typeof config().apiKey, 'string')
strictEqual(typeof config().emailTo, 'string')
const sendMailgunEmail = (email, subject, msg, callback) => {
const sendMailgunEmail = (email, subject, msg, conf, callback) => {
const validemail = typeof email === 'string' && email.indexOf('@') > -1 ? email : false

@@ -21,7 +14,7 @@ const validMsg = typeof msg === 'string' && msg.trim().length > 0 ? msg.trim() : false

method: 'POST',
path: `/v3/${config.domainName}/messages`,
auth: `api:${config.apiKey}`,
path: `/v3/${conf.domainName}/messages`,
auth: `api:${conf.apiKey}`,
data: {
from: email,
to: config.emailTo,
to: conf.emailTo,
subject: subject,

@@ -28,0 +21,0 @@ text: msg,

@@ -8,10 +8,10 @@ require('core-js/stable')

const app = require('./api')
const appStart = require('./api').default
module.exports.start = (port) => {
app.listen(port, '0.0.0.0', (err) => {
module.exports.start = (port, conf) => {
appStart(conf).listen(port, '0.0.0.0', (err) => {
if (err) {
console.log(err)
}
console.info(`==> listening on http://localhost:${PORT}.`)
console.info(`==> listening on http://localhost:${port}.`)
})

@@ -18,0 +18,0 @@ }

{
"name": "@talaikis/contact-us",
"version": "1.1.2",
"version": "1.1.3",
"description": "Contact us API service.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc