diff --git a/templates/ascent-react/api/controllers/waitlist/join-waitlist.js b/templates/ascent-react/api/controllers/waitlist/join-waitlist.js new file mode 100644 index 0000000..b645ab3 --- /dev/null +++ b/templates/ascent-react/api/controllers/waitlist/join-waitlist.js @@ -0,0 +1,30 @@ +module.exports = { + friendlyName: 'Join waitlist', + + description: '', + + inputs: { + email: { + type: 'string', + required: true, + isEmail: true, + maxLength: 200 + } + }, + + exits: { + success: { + responseType: 'redirect', + description: 'Successfully joined waitlist' + }, + badRequest: { + description: 'The provided email address is invalid.', + responseType: 'badRequest' + } + }, + + fn: async function ({ email }) { + await Waitlist.create({ email }).intercept('E_UNIQUE', 'badRequest') + return '/' + } +} diff --git a/templates/ascent-react/api/controllers/home/view-waitlist.js b/templates/ascent-react/api/controllers/waitlist/view-waitlist.js similarity index 100% rename from templates/ascent-react/api/controllers/home/view-waitlist.js rename to templates/ascent-react/api/controllers/waitlist/view-waitlist.js