Giter Site home page Giter Site logo

nostalcade / formup-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 133 KB

API to validate contact form entries and reCAPTCHA response, all contact information received and verified will be sent via email.

License: MIT License

JavaScript 100.00%
cors nodejs dotenv express nodemailer nodemon rest-api form axios recaptcha

formup-api's Introduction


FormUp API allows you to verify the entries of a contact form and also the user response token provided by reCAPTCHA client-side integration into your site. Once verified, the contact information will be sent via email.

Features

  • Validations

    • Form Entries

      • Name

      • Lastname

      • Email

      • Number/t.me

      • Message

    • reCAPTCHA Token

  • CORS

  • Routers

  • Controllers

  • Email Sending

Tech Stack

Environment Variables

โš ๏ธ Before running it, you must obtain the following values to initialize the required variables.

Variable Value Description
CLIENT_URL String Required. Add to list of domains allowed by CORS
RECAPTCHA_PRIVATE_KEY Private/Public Site Key Required. Private Site Key for verifying client response and Public Site Key for reCAPTCHA client-side integration
EMAIL_HOST EMAIL_PORT EMAIL_USER EMAIL_PASS SMTP Server Required. You can use Mailtrap for testing or your own SMTP Server
TO_EMAIL String Required. Email address to which contact information will be sent

Run

Install required

Locally

Clone the repository

  • HTTPS

    git clone https://github.com/nostalcade/formup-api.git
  • SSH

    git clone [email protected]:nostalcade/formup-api.git

Go to the repository directory

cd formup-api/

Install dev/Dependencies

npm i

Add Environment Variables to .env file

  • You must replace "somevalue" with your own values.
echo $'CLIENT_URL=somevalue\n\nRECAPTCHA_PRIVATE_KEY=somevalue\n\nEMAIL_HOST=somevalue\nEMAIL_PORT=somevalue\nEMAIL_USER=somevalue\nEMAIL_PASS=somevalue\n\nTO_EMAIL=somevalue' >> .env

Clear Bash History

history -cw

Start dev server

npm run dev

API base path URL on Server

http://localhost:5172/api/v1

All-In-One

  • HTTPS

    git clone https://github.com/nostalcade/formup-api.git; cd formup-api/; npm i; echo $'CLIENT_URL=somevalue\n\nRECAPTCHA_PRIVATE_KEY=somevalue\n\nEMAIL_HOST=somevalue\nEMAIL_PORT=somevalue\nEMAIL_USER=somevalue\nEMAIL_PASS=somevalue\n\nTO_EMAIL=somevalue' >> .env; history -cw; npm run dev;
  • SSH

    git clone [email protected]:nostalcade/formup-api.git; cd formup-api/; npm i; echo $'CLIENT_URL=somevalue\n\nRECAPTCHA_PRIVATE_KEY=somevalue\n\nEMAIL_HOST=somevalue\nEMAIL_PORT=somevalue\nEMAIL_USER=somevalue\nEMAIL_PASS=somevalue\n\nTO_EMAIL=somevalue' >> .env; history -cw; npm run dev;

API Reference

Index

Form Up

  • POST

    /form/up
    • Request

      • Body

        {
        	"name": "Sebastian",
        	"lastname": "Lacoste",
        	"email": "[email protected]",
        	"number": "+1234567890",
        	"message": "Example Message",
        	"recaptchaToken": "00ANYoXqvI03P_WO1qXOHYrThd-ltX3jQ8HfQhDd5XT3jaSUe38ra9m9QF6yV8Example-"
        }
    • Response

Invalid Route

  • ALL

    /all-undefined
    • Response

      • Body

        • Errors

          • (404)

            {
            	"msg": "Invalid Route"
            }

Verify Data

  • Response

    • Body

      • Errors

        • (400)

          {
          	"msg": "Empty Object"
          }
          {
          	"msg": "Invalid Properties"
          }
          {
          	"msg": "Missing Properties"
          }
          {
          	"msg": "Invalid reCAPTCHA"
          }
          {
          	"msg": "Values length max. 200 characters"
          }
          {
          	"msg": "Invalid Characters"
          }
          {
          	"msg": "Invalid Email"
          }

reCAPTCHA

  • Response

    • Body

      • Errors

        • (403)

          {
          	"msg": "Unsuccessfully reCAPTCHA"
          }

Nodemailer

  • Response

    • Body

      • Errors

        • (500)

          {
          	"msg": "Unsuccessfully. Please try again"
          }

License

formup-api's People

Contributors

nostalcade avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.