Giter Site home page Giter Site logo

auth-now's Introduction

Auth Now

An exploration into serverless

This is the main repo for @tomfa, @andrroy and @rix1's serverless adventure

Api Reference

Currently, the API only supports GET requests.

Developing

Built With

This project defines a series of serverless functions to be hosted by ZEIT Now.

Prerequisites

You will need to have Node and now installedd globally:

  • Node >=8.x
  • npm install -g now

Setting up Dev

To get started, clone the repo and install dependencies:

git clone https://github.com/rix1/auth-now.git
cd auth-now/
yarn install

Building

Before building, you need to copy dev-template.env to .env

cp dev-template.env .env

API keys

You need to create API keys for the email providers you wish to support. Currently only Mailgun is supported.

Private JWT Key

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.

Deploying / Publishing

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/.

Secrets

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.

Configuration

You can configure the build and deployment settings in now.json. See ZEIT docs for API reference and more info.

Aliases

You can easily alias you deployment to different domains. See custom domains for more info.

Tests

Todo

Licensing

MIT

auth-now's People

Contributors

rix1 avatar tomfa avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

auth-now's Issues

Implement persistent storage

Storage is planned to be a simple, generic key-value storage that returns json. /api/data/<id> should return the (json) value from the key <id>.

Alternatives:

  • S3, where key = "filename" and value is its content
  • Firebase.

@andrroy and me talked briefly about it yesterday. We're both noobs in Firebase, and want to learn. So we're leaning towards that.

There's dummy storage code in api/data/[id].js.

Add tests

No testing library added yet.

  • Add test library
  • Add tests for auth.js
  • Add tests for email.js
  • Add tests for /api/data
  • Add tests for /api/auth (#5 will probably lead to extra endpoint here)

Merge /api/sendgrid and /api/mailgun

Endpoints /api/sendgrid/send/<mail> and /api/mailgun/send/<mail> have different behavior

  • sendgrid sends html, mailgun sends plain text. Send html with both?
  • sendgrid html mail does not contain the same text as its text version.
  • sendgrid allows for setting subject and text via GET param. Remove and use content that mailgun uses?
  • Extract sendgrid and mailgun code to a library, and replace api endpoints with /api/email/login/<email>?

Data versioning

Problem: You have an old session on your computer in an old tab. When opening it, and performing an action, you overwrite newer data.

Suggested solution: Reload your local data if your local version is older than the one stored at the server

Update Readme with secrets and JWT info

We're currently missing information on how to run the application with the new JWT setup. In addition we're missing info on how to set secrets in the production environment.

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.