MVPStudio / mvp-studio-web-cms

the repo for the static site.
https://mvpstudio.github.io/mvp-studio-web-cms/
MIT License
4 stars 0 forks source link

server.js creates dependencies depending on env vars #39

Open slively opened 5 years ago

slively commented 5 years ago
// create an express server
let airtableClient;
let recaptchaClient;

if (mockEnvironment) {
    airtableClient = new MockAirtableClient()
    recaptchaClient = new MockRecaptchaClient()
} else {
   airtableClient = new AirtableClient()
   recaptchaClient = new RecaptchaClient()
}

const formHandler = new FormHanlder(airtableClient, recaptchaClient);

// create an express server, bind the route to call formHandler.submit(...)
slively commented 5 years ago

also the method should be a post:

app.post('/api/airtable', (req, res, next) => {
  formHandler(req.body)
    .then(response => res.send(response))
    .catch(e => next(e));
});