An exploration into serverless
This is the main repo for @tomfa, @andrroy and @rix1's serverless adventure
Currently, the API only supports GET
requests.
-
GET /api/email/[email protected]
👉 Send email using Mailgun as provider to [email protected].Specify subject and body using query parameters. Example
GET /api/mailgun/send/[email protected]?title=Hello&text=how%20is%20it%20going?
This project defines a series of serverless functions to be hosted by ZEIT Now.
You will need to have Node and now
installedd globally:
Node >=8.x
npm install -g now
To get started, clone the repo and install dependencies:
git clone https://github.com/rix1/auth-now.git
cd auth-now/
yarn install
Before building, you need to copy dev-template.env
to .env
cp dev-template.env .env
You need to create API keys for the email providers you wish to support. Currently only Mailgun is supported.
You also need to generate a private JWT key to sign the JWT payload. Just create a random passphrase 1Password or OpenSSL:
openssl rand -base64 32
ZEIT Now provides an additional command with Now CLI to help you develop serverless functions locally by replicating the production environment on Now with your localhost.
now dev
This supports hot reloading.
To deploy serverless functions you just have to run
now
from the root directory of the project. This will upload the repository to ZEIT's servers, build the project and serve the serverless API functions at https://auth-now.rix1.now.sh/api/.
Before deploying, you need to set secrets in your production environment:
now secrets add <secret-name> <secret-value>
See Now's docs and their troubleshooting guide for more information.
You can configure the build and deployment settings in now.json
. See
ZEIT docs for API reference
and more info.
You can easily alias you deployment to different domains. See custom domains for more info.
Todo
MIT