From 0d0454b05d93d575af42f58712aacbf6145d5591 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 27 Nov 2020 10:05:10 -0500 Subject: [PATCH 1/2] Serverless deploy --- .gitignore | 4 + components/shared/Footer/index.js | 6 +- components/shared/landing/Navbar/index.js | 6 +- next.config.js | 3 - package-lock.json | 153 ++++++++++++++++++++++ package.json | 1 + pages/api/hello.js | 6 - public/logo.svg | 2 + serverless.yml | 9 ++ utils/api.js | 2 +- 10 files changed, 178 insertions(+), 14 deletions(-) delete mode 100644 next.config.js delete mode 100644 pages/api/hello.js create mode 100644 public/logo.svg create mode 100644 serverless.yml diff --git a/.gitignore b/.gitignore index ae2a1ed..42248c1 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ yarn-error.log* # vercel .vercel + +# deploy +.serverless +.serverless_nextjs \ No newline at end of file diff --git a/components/shared/Footer/index.js b/components/shared/Footer/index.js index fccb980..4a36d81 100644 --- a/components/shared/Footer/index.js +++ b/components/shared/Footer/index.js @@ -1,7 +1,8 @@ import { Grid, makeStyles, Container, Typography, Link, } from '@material-ui/core'; -import logo from '../../../src/images/logo.svg'; +// import logo from '../../../src/images/logo.svg'; +import Image from 'next/image'; const useStyles = makeStyles((theme) => ({ root: { @@ -26,7 +27,8 @@ function Footer() { - BridgeAPI logo depicting an arch bridge + {/* BridgeAPI logo depicting an arch bridge */} + me diff --git a/components/shared/landing/Navbar/index.js b/components/shared/landing/Navbar/index.js index 9c8f236..8bc5995 100644 --- a/components/shared/landing/Navbar/index.js +++ b/components/shared/landing/Navbar/index.js @@ -3,7 +3,8 @@ import Link from 'next/link'; import { AppBar, Toolbar, Typography, makeStyles, Grid, } from '@material-ui/core'; -import logo from '../../../../src/images/logo.svg'; +// import logo from '../../../../src/images/logo.svg'; +import Image from 'next/image'; const useStyles = makeStyles((theme) => ({ root: { @@ -49,7 +50,8 @@ export default function Navbar() { - BridgeAPI logo depicting an arch bridge + {/* BridgeAPI logo depicting an arch bridge */} + me diff --git a/next.config.js b/next.config.js deleted file mode 100644 index 811e02c..0000000 --- a/next.config.js +++ /dev/null @@ -1,3 +0,0 @@ -const withImages = require('next-images'); - -module.exports = withImages(); diff --git a/package-lock.json b/package-lock.json index 2df5cda..a49b67b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2726,6 +2726,70 @@ "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==" }, + "aws-sdk": { + "version": "2.799.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.799.0.tgz", + "integrity": "sha512-NYAoiNU+bJXhlJsC0rFqrmD5t5ho7/VxldmziP6HLPYHfOCI9Uvk6UVjfPmhLWPm0mHnIxhsHqmsNGyjhHNYmw==", + "dev": true, + "requires": { + "buffer": "4.9.2", + "events": "1.1.1", + "ieee754": "1.1.13", + "jmespath": "0.15.0", + "querystring": "0.2.0", + "sax": "1.2.1", + "url": "0.10.3", + "uuid": "3.3.2", + "xml2js": "0.4.19" + }, + "dependencies": { + "buffer": { + "version": "4.9.2", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", + "integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, + "events": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", + "dev": true + }, + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", + "dev": true + }, + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + }, + "url": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", + "dev": true, + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + } + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "dev": true + } + } + }, "aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -7222,6 +7286,12 @@ "supports-color": "^6.1.0" } }, + "jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=", + "dev": true + }, "joi": { "version": "17.3.0", "resolved": "https://registry.npmjs.org/joi/-/joi-17.3.0.tgz", @@ -10427,6 +10497,12 @@ } } }, + "sax": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=", + "dev": true + }, "scheduler": { "version": "0.20.1", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.1.tgz", @@ -10459,6 +10535,67 @@ "randombytes": "^2.1.0" } }, + "serverless-domain-manager": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/serverless-domain-manager/-/serverless-domain-manager-5.1.0.tgz", + "integrity": "sha512-uGLGr9nWTupimWxVwz/2S/fK+YULsg8hQ0ZddS1DNerzctIVQBXVbLMGUJv34a9a5HV0YPvVqCA/JBNI7VOSvA==", + "dev": true, + "requires": { + "aws-sdk": "^2.756.0", + "chalk": "^4.1.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", @@ -12818,6 +12955,22 @@ "typedarray-to-buffer": "^3.1.5" } }, + "xml2js": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", + "dev": true, + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~9.0.1" + } + }, + "xmlbuilder": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", + "dev": true + }, "xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index 96240b0..a60a127 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "istanbul-lib-coverage": "^3.0.0", "msw": "^0.22.3", "nyc": "^15.1.0", + "serverless-domain-manager": "^5.1.0", "start-server-and-test": "^1.11.6" } } diff --git a/pages/api/hello.js b/pages/api/hello.js deleted file mode 100644 index 07d9d9b..0000000 --- a/pages/api/hello.js +++ /dev/null @@ -1,6 +0,0 @@ -// Next.js API route support: https://nextjs.org/docs/api-routes/introduction - -export default (req, res) => { - res.statusCode = 200; - res.json({ name: 'John Doe' }); -}; diff --git a/public/logo.svg b/public/logo.svg new file mode 100644 index 0000000..6c1c42c --- /dev/null +++ b/public/logo.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/serverless.yml b/serverless.yml new file mode 100644 index 0000000..6870702 --- /dev/null +++ b/serverless.yml @@ -0,0 +1,9 @@ +service: bridgeapi-frontend + +myNextApplication: + component: "@sls-next/serverless-component@1.19.0-alpha.12" + inputs: + domain: ["bridgeapi.dev"] + publicDirectoryCache: + value: public, max-age=604800 + test: /\.(gif|jpe?g|png|txt|xml)$/i \ No newline at end of file diff --git a/utils/api.js b/utils/api.js index e463eb2..4b1232b 100644 --- a/utils/api.js +++ b/utils/api.js @@ -2,7 +2,7 @@ import Axios from 'axios'; const urls = { development: 'http://localhost:3001/', - production: 'http://localhost:3004/', + production: 'https://api.bridgeapi.dev', }; // Tests require the application to be built and From 4506ff05ce53a8cc84ac3dafbea9fbe6e66705b9 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 27 Nov 2020 13:14:28 -0500 Subject: [PATCH 2/2] Update readme --- README.md | 187 ++++++++++-------------------------------------------- 1 file changed, 34 insertions(+), 153 deletions(-) diff --git a/README.md b/README.md index 06adfe9..2a29236 100644 --- a/README.md +++ b/README.md @@ -1,165 +1,46 @@ -This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). +

+ +

-## Deploy on Vercel +(BridgeAPI)[https://bridgeapi.dev] is a serverless integration platform that +empowers users to connect apps through event-driven workflows. -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/import?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. +This is the frontend codebase. The backend is made with Ruby on Rails and can be found (here)[https://github.com/angeljruiz/BridgeAPI.rb]. -Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. +## About +TODO +- Made with nextjs +- Tested with cypress +- Mocked & stubbed with cypress & msw -## API Requests -Account: - title: Get user into - url: '/users/account' - method: GET - returns: - status: 200 Ok - user: { - email: 'myemail@gmail.com' - notifications: { - emailOnEvents: true - } - } +## Installation - title: Update user info - url: '/users/:id' - method: PATCH/PUT - sends: - user: { - email: 'myNEWemail@gmail.com' - currentPassword: '...' - newPassword: '...' - confirmPassword: '...' - notifications: { - emailOnEvents: true - } - } - returns: - status: 202 Accepted - message: 'Success' +```sh +git clone https://github.com/williampj/bridgeapi.js +cd bridgeapi.js +npm i +npm run dev +``` -BridgesMenu: - title: Get bridge titles - url: '/bridge_titles' - method: GET - returns: - status: 200 Ok - bridges: [ - 'bridge 1' - 'bridge 2' - 'bridge 3' - ] +## Testing -Editor/New: - title: Create Bridge - url: '/bridges' - method: POST - sends: - bridge: { - outboundURL: 'https://slack.com/new_message/934782' - method: 'POST' - retries: '3' - delay: '0' - headers: [ - { key: 'X-API-KEY', value: '$env.API_KEY' } - ] - envVars: [ - { key: 'API_KEY', value: '1234567890APIKEY' } - ] - } - returns: - status: 201 Created - message: 'Success' +Follow the installation guide and then run: -Editor/[slug]: - title: Get Page Inputs - url: '/bridges/:slug' - method: GET - returns: - status: 200 Ok - bridge: { - outboundURL: 'https://slack.com/new_message/934782' - method: 'POST' - retries: '3' - delay: '0' - headers: [ - { key: 'X-API-KEY', value: '$env.API_KEY' } - ] - envVars: [ - { key: 'API_KEY', value: 'XXXXXXXXXXXXXXX' } - ] - } +```sh +# Fully automated +NEXT_PUBLIC_TEST_ENV=test npm run test - title: Update Bridge - url: '/bridges' - method: PATCH/PUT - sends: - bridge: { - outboundURL: 'https://slack.com/new_message/934782' - method: 'POST' - retries: '3' - delay: '0' - headers: [ - { key: 'X-API-KEY', value: '$env.API_KEY' } - ] - envVars: [ - { key: 'API_KEY', value: '1234567890APIKEY' } - ] - } - returns: - status: 202 Accepted - Message: 'Updated' - +# Run individual tests +# Terminal 1 +NEXT_PUBLIC_TEST_ENV=test npm run build +NEXT_PUBLIC_TEST_ENV=test npm run start -CodeMirror: - title: Get Editor Code - urls: [ - '/bridges/:slug/code' - '/bridges/:slug/test_code' - '/bridges/:slug/lastest_request' - ] - method: GET - returns: - status: 200 Ok - code: "I am a json payload of the code" +# Terminal 2 +npm run cypress:open +``` -Dashboard: - title: Get bridge data - url: '/bridges' - method: GET - returns: - status: 200 - bridges: [ - { - title: 'test title 1' - updatedAt: Date.now() - lastRequest: Date.now() - requests: 10 - } - ] +## Contributors -Login: - title: Log in user - url: '/users/login' - method: POST - sends: - user: { - email: 'myemail@email.com' - password: '...' - } - returns: - status: 200 Ok - session: '10982-ah34ads7098-u212437' (JWT) - -Signup: - title: Sign up user - url: '/users/signup' - method: POST - sends: - user: { - email: 'myemail@email.com' - password: '...' - passwordConfirm: '...' - } - returns: - status: 201 - message: 'Success - Please check email' \ No newline at end of file +- (andrewc910)[https://github.com/andrewc910] - creator and maintainer +- (angeljruiz)[https://github.com/angeljruiz] - creator and maintainer +- (williampj)[https://github.com/williampj] - creator and maintainer \ No newline at end of file