From 1e8dd543f353549afae7caa9030ab41fa5432be4 Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Wed, 24 Nov 2021 11:19:34 -0700 Subject: [PATCH] Added dotenv and hcaptcha --- index.js | 13 +++++++++++-- package-lock.json | 10 ++++++++++ package.json | 4 +++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index f21f65b..2ca6519 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,18 @@ 'use strict' +require('dotenv').config() const app = require('express')() +const {verify} = require('hcaptcha') + +app.post('/', async (req, res) => { + + // Check token + try { + const data = await verify(process.env.HCAPTCHA_SECRET, req.body['token']) + } catch (err) { console.error(err) } + if (data.success === true) + console.log('success!', data) -app.post('/', (req, res) => { - res.send('Hello World') }).listen(80, () => { console.log(`API started`) }) diff --git a/package-lock.json b/package-lock.json index 03f851f..01b4b8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -81,6 +81,11 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -162,6 +167,11 @@ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" }, + "hcaptcha": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/hcaptcha/-/hcaptcha-0.1.0.tgz", + "integrity": "sha512-mVRkhNcOuP7QJO50nYdu3vS+uaOg6Ku2HpMy50C2EckjB9DlnwX24iePi912IXuVIq5L8ukjISG4Ea6MimZ5+w==" + }, "http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", diff --git a/package.json b/package.json index ef7266c..ddbfe72 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,8 @@ "author": "Keith Irwin", "license": "MIT", "dependencies": { - "express": "^4.17.1" + "dotenv": "^10.0.0", + "express": "^4.17.1", + "hcaptcha": "^0.1.0" } }