From 55dfb68fef8470896ab51546ad458abbb6b3fc25 Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Wed, 24 Nov 2021 12:20:12 -0700 Subject: [PATCH] Added body parser, better hcaptcha code, env files --- index.js | 7 ++++--- package.json | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 2ca6519..8fbce9a 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,11 @@ 'use strict' require('dotenv').config() -const app = require('express')() +const express = require('express') const {verify} = require('hcaptcha') -app.post('/', async (req, res) => { +express().use(express.json()) +.post('/', async (req, res) => { // Check token try { @@ -13,6 +14,6 @@ app.post('/', async (req, res) => { if (data.success === true) console.log('success!', data) -}).listen(80, () => { +}).listen(process.env.PORT, () => { console.log(`API started`) }) diff --git a/package.json b/package.json index ddbfe72..82fd195 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "API to check hCaptcha and sendmail", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node index.js" }, "author": "Keith Irwin", "license": "MIT",