From df95f48f3e76a997a6c424e3055bd8439095552e Mon Sep 17 00:00:00 2001 From: Spencer Elliott Date: Sun, 1 Nov 2020 16:19:48 -0500 Subject: [PATCH 1/5] Support Node.js 12 --- .travis.yml | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2ea650dc..46d38f6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ env: - YARN_GPG=no node_js: - 'node' + - '12' - '14' os: - windows diff --git a/package.json b/package.json index 9e5ff9a9..c8e1943f 100644 --- a/package.json +++ b/package.json @@ -115,6 +115,6 @@ } }, "engines": { - "node": ">= 14" + "node": ">= 12" } } From f4ed5e93316d73e66beaeb91b38fd57ca2ff1780 Mon Sep 17 00:00:00 2001 From: Spencer Elliott Date: Sun, 1 Nov 2020 16:30:51 -0500 Subject: [PATCH 2/5] Move netlify handler to 'src/serverless.js' --- functions/api.js => src/serverless.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename functions/api.js => src/serverless.js (77%) diff --git a/functions/api.js b/src/serverless.js similarity index 77% rename from functions/api.js rename to src/serverless.js index 7187fc24..7ee0b4bf 100644 --- a/functions/api.js +++ b/src/serverless.js @@ -3,10 +3,10 @@ const { ApolloServer } = require('apollo-server-lambda') const { UnsignedIntResolver, UnsignedIntTypeDefinition, DateTimeResolver, DateTimeTypeDefinition } = require('graphql-scalars') -const connect = require('../src/utils/connect') -const isDemoMode = require('../src/utils/isDemoMode') -const isDevelopmentMode = require('../src/utils/isDevelopmentMode') -const { createServerlessContext } = require('../src/utils/createContext') +const connect = require('./utils/connect') +const isDemoMode = require('./utils/isDemoMode') +const isDevelopmentMode = require('./utils/isDevelopmentMode') +const { createServerlessContext } = require('./utils/createContext') const allowOrigin = process.env.ACKEE_ALLOW_ORIGIN || '' const dbUrl = process.env.ACKEE_MONGODB || process.env.MONGODB_URI @@ -24,12 +24,12 @@ const apolloServer = new ApolloServer({ typeDefs: [ UnsignedIntTypeDefinition, DateTimeTypeDefinition, - require('../src/types') + require('./types') ], resolvers: { UnsignedInt: UnsignedIntResolver, DateTime: DateTimeResolver, - ...require('../src/resolvers') + ...require('./resolvers') }, context: createServerlessContext }) From 3afc0ec48a528ed92ba365ff053c125351111945 Mon Sep 17 00:00:00 2001 From: Spencer Elliott Date: Sun, 1 Nov 2020 16:31:14 -0500 Subject: [PATCH 3/5] Vercel + Netlify serverless functions --- api/index.js | 12 ++++++++++++ functions/api.js | 9 +++++++++ vercel.json | 7 +++++++ 3 files changed, 28 insertions(+) create mode 100644 api/index.js create mode 100644 functions/api.js create mode 100644 vercel.json diff --git a/api/index.js b/api/index.js new file mode 100644 index 00000000..1f442cd8 --- /dev/null +++ b/api/index.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * A serverless function handler for the '/api' route, for use with Vercel. + * This handler follows the AWS Lambda API; Vercel deployments are opted-in + * using the "NODEJS_AWS_HANDLER_NAME" environment variable defined in vercel.json. + * + * See: + * - https://vercel.com/docs/serverless-functions/supported-languages#node.js + * - https://vercel.com/docs/runtimes#advanced-usage/advanced-node-js-usage/aws-lambda-api + */ +exports.handler = require('../src/serverless').handler \ No newline at end of file diff --git a/functions/api.js b/functions/api.js new file mode 100644 index 00000000..ea43d588 --- /dev/null +++ b/functions/api.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * A serverless function handler for the '/api' route, for use with Netlify. + * + * See: + * - https://docs.netlify.com/functions/overview/ + */ +exports.handler = require('../src/serverless').handler \ No newline at end of file diff --git a/vercel.json b/vercel.json new file mode 100644 index 00000000..0489c923 --- /dev/null +++ b/vercel.json @@ -0,0 +1,7 @@ +{ + "build": { + "env": { + "NODEJS_AWS_HANDLER_NAME": "handler" + } + } +} From e8dffb7e41de6359bb83166b260652d847792a7b Mon Sep 17 00:00:00 2001 From: Spencer Elliott Date: Sun, 1 Nov 2020 16:43:27 -0500 Subject: [PATCH 4/5] Ignore Vercel-generated files --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fec11ac0..9639f3e9 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,7 @@ node_modules # Dist folder dist/* -!dist/.gitkeep \ No newline at end of file +!dist/.gitkeep + +# Vercel +.vercel From 2b3c601eaab0f99c0639bfee83f452728a19f1cc Mon Sep 17 00:00:00 2001 From: Spencer Elliott Date: Sun, 1 Nov 2020 16:57:05 -0500 Subject: [PATCH 5/5] Add docs for Vercel --- README.md | 1 + docs/Get started.md | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 8052aa85..b5479f32 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Get Ackee up and running… - […with Helm](docs/Get%20started.md#with-helm) - […without Docker](docs/Get%20started.md#without-docker) - […with Netlify](docs/Get%20started.md#with-netlify) +- […with Vercel](docs/Get%20started.md#with-vercel) - […with Heroku](docs/Get%20started.md#with-heroku) - […with Render](docs/Get%20started.md#with-render) diff --git a/docs/Get started.md b/docs/Get started.md index 5b1c18eb..e984d9e3 100644 --- a/docs/Get started.md +++ b/docs/Get started.md @@ -177,6 +177,24 @@ Ackee now runs on port `3000` and is only accessible from you local network. It' Netlify adds a forked version of Ackee to your GitHub repositories. You can always [pull the newest code](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/syncing-a-fork) from the original project. Pushing those changes to your repository will automatically deploy the new version of Ackee on Netlify. +## With Vercel + +### 1. Deploy to Vercel + +[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https%3A%2F%2Fgithub.com%2Felecterious%2FAckee&env=ACKEE_USERNAME,ACKEE_PASSWORD,ACKEE_MONGODB,ACKEE_ALLOW_ORIGIN&envDescription=Environment%20variables%20needed%20to%20configure%20the%20user%20and%20database%20connection&envLink=https%3A%2F%2Fgithub.com%2Felecterious%2FAckee%2Fblob%2Fmaster%2Fdocs%2FOptions.md) + +When prompted to select a directory, select the root directory. + +### 2. Configure Ackee + +* Set the build command: `yarn build` +* Set the output directory: `dist` +* Set environment variables `ACKEE_USERNAME`, `ACKEE_PASSWORD`, `ACKEE_MONGODB`, and `ACKEE_ALLOW_ORIGIN`. + +### 3. Updating Ackee + +Vercel adds a forked version of Ackee to your GitHub repositories. You can always [pull the newest code](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/syncing-a-fork) from the original project. Pushing those changes to your repository will automatically deploy the new version of Ackee on Vercel. + ## With Heroku ### 1. Deploy to Heroku