-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 99fb567
Showing
206 changed files
with
49,958 additions
and
0 deletions.
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,12 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "daily" | ||
open-pull-requests-limit: 20 |
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: Backend CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.17.0] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn stocker:install | ||
|
||
- name: Lint | ||
run: yarn stocker:lint | ||
|
||
- name: Test | ||
run: yarn stocker:test |
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: Frontend CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.17.0] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn | ||
|
||
- name: Build # includes lint | ||
run: yarn maffin:build | ||
|
||
- name: Test | ||
run: yarn maffin:test --coverage |
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,49 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
**/coverage | ||
|
||
# next | ||
.next | ||
.vscode | ||
|
||
# production | ||
/build | ||
|
||
account.gz* | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
#amplify-do-not-edit-begin | ||
amplify/\#current-cloud-backend | ||
amplify/.config/local-* | ||
amplify/logs | ||
amplify/mock-data | ||
amplify/backend/amplify-meta.json | ||
amplify/backend/.temp | ||
build/ | ||
dist/ | ||
node_modules/ | ||
awsconfiguration.json | ||
amplifyconfiguration.json | ||
amplifyconfiguration.dart | ||
amplify-build-config.json | ||
amplify-gradle-config.json | ||
amplifytools.xcconfig | ||
.secret-* | ||
**.sample | ||
#amplify-do-not-edit-end |
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 @@ | ||
v16.17.0 |
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,50 @@ | ||
# maffin.io | ||
|
||
# Developing | ||
|
||
If you want to add a new user, before starting with the installation you will need few steps: | ||
|
||
1. [new maintainers only] Ask a maintainer for the AWS keys and credentials so you can interact with local amplify cli and access AWS console respectively | ||
2. Add the user gmail account to the google console as a test user (for now) | ||
|
||
|
||
## Installation | ||
|
||
Run `nvm use` to set the correct node version. | ||
|
||
``` | ||
yarn # Install frontend dependencies | ||
yarn stocker:install # Install backend dependencies | ||
``` | ||
|
||
If not installed yet, install amplify cli with `npm install -g @aws-amplify/cli`. Then if it's your first time, you'll have to pull the amplify project: | ||
|
||
> Make sure to select your AWS profile credentials with `export AWS_PROFILE=maffin` | ||
``` | ||
10:56 $ amplify pull | ||
? Select the authentication method you want to use: AWS access keys | ||
? accessKeyId: ******************** # credentials from maffin account | ||
? secretAccessKey: **************************************** | ||
? region: eu-central-1 | ||
? Which app are you working on? dkycpktllbi8x | ||
Backend environment 'master' found. Initializing... | ||
? Choose your default editor: Vim (via Terminal, macOS only) | ||
? Choose the type of app that you're building javascript | ||
Please tell us about your project | ||
? What javascript framework are you using react | ||
? Source Directory Path: src | ||
? Distribution Directory Path: build | ||
? Build Command: yarn build | ||
? Start Command: yarn start | ||
✖ Failed to sync UI components | ||
? Do you plan on modifying this backend? Yes | ||
``` | ||
|
||
## Running | ||
|
||
Run stocker with `yarn stocker:start` and then the frontend with `yarn maffin:start:`. | ||
|
||
## Deploying | ||
|
||
The project is deployed automatically everytime there is a merge to master using Amplify pipeline. |
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,23 @@ | ||
version: 1 | ||
backend: | ||
phases: | ||
build: | ||
commands: | ||
- '# Execute Amplify CLI with the helper script' | ||
- amplifyPush --simple | ||
frontend: | ||
phases: | ||
preBuild: | ||
commands: | ||
- yarn install | ||
build: | ||
commands: | ||
- rm -rf .next/ | ||
- yarn maffin:build | ||
artifacts: | ||
baseDirectory: .next | ||
files: | ||
- '**/*' | ||
cache: | ||
paths: | ||
- node_modules/**/* |
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 @@ | ||
{ | ||
"providers": [ | ||
"awscloudformation" | ||
], | ||
"projectName": "maffinapp", | ||
"version": "3.1", | ||
"frontend": "javascript", | ||
"javascript": { | ||
"framework": "react", | ||
"config": { | ||
"SourceDir": "src", | ||
"DistributionDir": "build", | ||
"BuildCommand": "yarn build", | ||
"StartCommand": "yarn maffin:start" | ||
} | ||
} | ||
} |
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 @@ | ||
{ | ||
"version": 1, | ||
"paths": { | ||
"/api/prices/live": { | ||
"name": "/api/prices/live", | ||
"lambdaFunction": "stockerlambda", | ||
"permissions": { | ||
"setting": "open" | ||
} | ||
}, | ||
"/api/funds/{isin}": { | ||
"name": "/api/funds/{isin}", | ||
"lambdaFunction": "stockerlambda", | ||
"permissions": { | ||
"setting": "open" | ||
} | ||
} | ||
} | ||
} |
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,44 @@ | ||
{ | ||
"api": { | ||
"stocker": { | ||
"dependsOn": [ | ||
{ | ||
"attributes": [ | ||
"Name", | ||
"Arn" | ||
], | ||
"category": "function", | ||
"resourceName": "stockerlambda" | ||
} | ||
], | ||
"providerPlugin": "awscloudformation", | ||
"service": "API Gateway" | ||
} | ||
}, | ||
"auth": {}, | ||
"function": { | ||
"stockerlambda": { | ||
"build": true, | ||
"providerPlugin": "awscloudformation", | ||
"service": "Lambda" | ||
} | ||
}, | ||
"parameters": { | ||
"AMPLIFY_function_stockerlambda_deploymentBucketName": { | ||
"usedBy": [ | ||
{ | ||
"category": "function", | ||
"resourceName": "stockerlambda" | ||
} | ||
] | ||
}, | ||
"AMPLIFY_function_stockerlambda_s3Key": { | ||
"usedBy": [ | ||
{ | ||
"category": "function", | ||
"resourceName": "stockerlambda" | ||
} | ||
] | ||
} | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"pluginId": "amplify-nodejs-function-runtime-provider", | ||
"functionRuntime": "nodejs", | ||
"useLegacyBuild": true, | ||
"defaultEditorFile": "src/app.js" | ||
} |
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,6 @@ | ||
[ | ||
{ | ||
"Action": [], | ||
"Resource": [] | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
amplify/backend/function/stockerlambda/function-parameters.json
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,3 @@ | ||
{ | ||
"lambdaLayers": [] | ||
} |
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,67 @@ | ||
const cors = require('cors'); | ||
const express = require('express'); | ||
const bodyParser = require('body-parser'); | ||
const awsServerlessExpressMiddleware = require('aws-serverless-express/middleware'); | ||
|
||
const yahoo = require('./yahoo'); | ||
const helpers = require('./helpers'); | ||
|
||
const app = express() | ||
app.use(bodyParser.json()) | ||
app.use(awsServerlessExpressMiddleware.eventContext()) | ||
|
||
|
||
const ALLOWED_ORIGINS = [ | ||
'http://localhost:3000', | ||
'https://app.maffin.io', | ||
]; | ||
|
||
app.use(cors({ | ||
origin: (origin, callback) => { | ||
if ( | ||
ALLOWED_ORIGINS.indexOf(origin) !== -1 | ||
|| origin.match(/https:\/\/.*d199ayutgsrlxn\.amplifyapp\.com/g) | ||
) { | ||
callback(null, true); | ||
} else { | ||
callback(new Error('Not allowed by CORS')); | ||
} | ||
} | ||
})); | ||
|
||
app.get('/api/prices/live', async (req, res) => { | ||
let tickers = req.query.ids; | ||
if (!tickers) { | ||
res.status(400).json({ | ||
error: 'IDS_REQUIRED', | ||
description: 'You need to pass \'ids\' queryparam to select specific quotes', | ||
}); | ||
return; | ||
} | ||
|
||
tickers = tickers.split(','); | ||
|
||
const result = {}; | ||
const promises = []; | ||
|
||
async function callAndSave(ticker) { | ||
price = await yahoo.getLiveSummary(ticker); | ||
result[ticker] = price; | ||
} | ||
|
||
try { | ||
tickers.forEach(ticker => promises.push(callAndSave(ticker))); | ||
await Promise.all(promises); | ||
} catch (error) { | ||
console.log(error); | ||
res.status(500).json({ | ||
error: 'UNKNOWN_ERROR', | ||
description: 'Failed to retrieve prices', | ||
}); | ||
return; | ||
} | ||
|
||
res.json(result); | ||
}); | ||
|
||
module.exports = app; |
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,12 @@ | ||
class HTTPError extends Error { | ||
constructor(message, status, code) { | ||
super(message); | ||
this.message = message; | ||
this.status = status; | ||
this.code = code; | ||
} | ||
} | ||
|
||
module.exports = { | ||
HTTPError, | ||
}; |
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,7 @@ | ||
{ | ||
"httpMethod": "GET", | ||
"path": "/api/prices/live", | ||
"queryStringParameters": { | ||
"ids": "IAG.MC,AIR.PA" | ||
} | ||
} |
Oops, something went wrong.