-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added project ci #4
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f12e8ab
feat: added postman API test created with newman to CI
6893565
feat: updated postman tests suites
vickywane 49288ba
fix: removed lighthouse checks and updated readme
vickywane e7827dd
Merge branch 'main' into functions
vickywane 7656fa7
Merge pull request #1 from vickywane/functions
vickywane a8ef5db
fix: fix breaking CI setup
vickywane 9d6ec45
fix: fix breaking CI setup
vickywane 42f3999
feat: project CI
vickywane 6098713
Merge pull request #1 from vickywane/functions
vickywane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: [ambianic] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Smartphone (please complete the following information):** | ||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Ambianic Functions API CI Test | ||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master branch | ||
on: [pull_request] | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Node JS ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install Newman dependency | ||
run: npm install --prefix tests/postman/ | ||
|
||
- name: Run the API and Postman's tests | ||
run: | | ||
cd tests/postman/ && newman run * | ||
env: | ||
CI: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,4 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
# ambianic-subscriptions | ||
Repo for ambianic premium subscription management | ||
|
||
This repo hosts [Netlify functions](https://www.netlify.com/products/functions/) that handle Ambianic premium user subscriptions. This is code that cannot run in the browser PWA, because it needs access keys to subscription and payment gateway services (Stripe) shared between all app users. If the code runs in the PWA, users will be able to see and manipulate each other's premium subscription data. | ||
This repo hosts [Netlify functions](https://www.netlify.com/products/functions/) that handle Ambianic premium user subscriptions. This is code that cannot run in the browser PWA, because it needs access keys to subscription and payment gateway services (Stripe) shared between all app users. If the code runs in the PWA, users will be able to see and manipulate each other's premium subscription data | ||
|
||
A high level prototype of how these functions make up the ambianic serverless feature can be found [here](https://drive.google.com/file/d/181etJhBye0u1zvqzAnBY0VtCS0A3SlQ-/view?usp=sharing). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!doctype html> | ||
<html class="no-js" lang=""> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title></title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<!-- Place favicon.ico in the root directory --> | ||
<meta name="theme-color" content="#fafafa"> | ||
</head> | ||
|
||
<body> | ||
|
||
<!-- Add your site or application content here --> | ||
<p>Hello world! This is Ambianic functions</p> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[build] | ||
command = "npm build" | ||
functions = "netlify/functions" | ||
|
||
[[headers]] | ||
for = "/*" | ||
[headers.values] | ||
Access-Control-Allow-Origin = "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require('dotenv').config() | ||
const stripe = require('stripe')(process.env.STRIPE_TEST_KEY) | ||
|
||
exports.handler = (event, context, callback) => { | ||
const { stripeId } = event.queryStringParameters | ||
stripe.subscriptions.del(stripeId).then(() => { | ||
return callback(null, { | ||
statusCode: 200, | ||
body: JSON.stringify({ message: 'CUSTOMER HAS BEEN UNSUBSCRIBED' }) | ||
}) | ||
}) | ||
.catch(error => { | ||
callback(null, { | ||
statusCode: 422, | ||
body: JSON.stringify({ message: 'ERROR GETTING CUSTOMERS'}), | ||
error | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require('dotenv').config() | ||
const stripe = require('stripe')(process.env.STRIPE_TEST_KEY) | ||
|
||
const headers = { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Headers': 'Content-Type', | ||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE' | ||
} | ||
|
||
exports.handler = (event, context, callback) => { | ||
stripe.customers | ||
.list() | ||
.then(customers => { | ||
return callback(null, { | ||
statusCode: 200, | ||
headers, | ||
body: JSON.stringify({ customers }) | ||
}) | ||
}) | ||
.catch(error => callback(null, { | ||
statusCode: 422, | ||
headers, | ||
body: JSON.stringify({ message: 'ERROR GETTING CUSTOMERS', error }) | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require('dotenv').config() | ||
const stripe = require('stripe')(process.env.STRIPE_TEST_KEY) | ||
|
||
const headers = { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Headers': 'Content-Type', | ||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE' | ||
} | ||
|
||
// TODO: Refactor to use async await. | ||
exports.handler = (event, context, callback) => { | ||
const { email, card } = event.queryStringParameters | ||
|
||
// eslint-disable-next-line camelcase | ||
const { number, cvc, exp_month, exp_year } = JSON.parse(card) | ||
|
||
stripe.sources.create({ | ||
type: 'ach_credit_transfer', | ||
currency: 'usd', | ||
owner: { | ||
} | ||
}, (err, source) => { | ||
if (err) { | ||
console.log(err) | ||
} | ||
// Create a payment method for user using the Card Details | ||
stripe.paymentMethods.create({ | ||
type: 'card', | ||
card: { | ||
number, cvc, exp_year, exp_month | ||
} | ||
}).then(({ id: paymentID }) => { | ||
// Creates Customer ==> | ||
stripe.customers | ||
.create({ | ||
email, | ||
description: 'Ambianic customer using premium service', | ||
payment_method: paymentID, | ||
source: source.id | ||
}) | ||
.then(({ id: customerID }) => { | ||
stripe.paymentMethods.attach(paymentID, { customer: customerID }).then((data) => { | ||
stripe.subscriptions.create({ | ||
customer: customerID, | ||
items: [{ | ||
price: process.env.EMAIL_PRODUCT_ID | ||
}] | ||
}).then(() => callback(null, { | ||
statusCode: 200, | ||
headers, | ||
body: JSON.stringify({ message: 'EMAIl SUBSCRIPTION CREATED' }) | ||
})).catch(e => { | ||
console.log(`Err creating subscription : ${e}`) | ||
}) | ||
}).catch(e => { | ||
console.log(`Creating customer ${e}`) | ||
}) | ||
}) | ||
}).catch(error => callback(null, { | ||
statusCode: 422, | ||
headers, | ||
body: JSON.stringify({ message: 'ERROR CREATING USER', error }) | ||
})) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "functions", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "parcel build index.html", | ||
"dev": "parcel index.html", | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"newman": "^5.2.2", | ||
"stripe": "^8.135.0" | ||
}, | ||
"devDependencies": { | ||
"parcel-bundler": "^1.12.4" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vickywane in the diagram towards the bottom it shows Edge Calls Google API, I think the intention is to show that Edge calls Ambianic Notification Service APIs.