Skip to content

Commit 56464ed

Browse files
Enhancement/create lambda functions (#1)
* got issue request working locally * lint * ci * working locally * working in AWS * repositories lambda * docs * github templates * update to reflect proxy integration * fix linting * clean up error handling
1 parent 20b3090 commit 56464ed

File tree

12 files changed

+1235
-18
lines changed

12 files changed

+1235
-18
lines changed

.circleci/config.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ jobs:
1010
- checkout
1111

1212
# Download and cache dependencies
13-
# - restore_cache:
14-
# keys:
15-
# - v1-dependencies-{{ checksum "package.json" }}
16-
# # fallback to using the latest cache if no exact match is found
17-
# - v1-dependencies-
13+
- restore_cache:
14+
keys:
15+
- v1-dependencies-{{ checksum "package.json" }}
16+
# fallback to using the latest cache if no exact match is found
17+
- v1-dependencies-
1818

19-
# - run:
20-
# name: Install Project Dependencies
21-
# command: yarn install
19+
- run:
20+
name: Install Project Dependencies
21+
command: yarn install
2222

23-
# - run:
24-
# name: Run Linter
25-
# command: yarn lint
23+
- run:
24+
name: Run Linter
25+
command: yarn lint
2626

27-
# - run:
28-
# name: Run Ingest Script
29-
# command: mkdir tmp && yarn ingest
27+
- run:
28+
name: Run Ingest Script
29+
command: mkdir tmp && yarn function:issues
3030

31-
# - run:
32-
# name: Run Read Script
33-
# command: rm -rf tmp/* && yarn read
31+
- run:
32+
name: Run Read Script
33+
command: yarn function:repositories

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = false

.eslintrc

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 2018,
4+
"sourceType": "module"
5+
},
6+
"env": {
7+
"browser": true,
8+
"node": false
9+
},
10+
"rules": {
11+
"comma-dangle": [2,"never"],
12+
"no-cond-assign": 2,
13+
"no-console": 1,
14+
"no-constant-condition": 2,
15+
"no-control-regex": 0,
16+
"no-debugger": 0,
17+
"no-dupe-args": 0,
18+
"no-dupe-keys": 0,
19+
"no-duplicate-case": 2,
20+
"no-empty-character-class": 0,
21+
"no-empty": 2,
22+
"no-ex-assign": 2,
23+
"no-extra-boolean-cast": 2,
24+
"no-extra-parens": [2, "all", {
25+
"conditionalAssign": false,
26+
"returnAssign": false,
27+
"nestedBinaryExpressions": false
28+
}],
29+
"no-extra-semi": 2,
30+
"no-func-assign": 2,
31+
"no-inner-declarations": 2,
32+
"no-invalid-regexp": 0,
33+
"no-irregular-whitespace": 2,
34+
"no-negated-in-lhs": 2,
35+
"no-obj-calls": 0,
36+
"no-regex-spaces": 0,
37+
"no-sparse-arrays": 2,
38+
"no-unreachable": 2,
39+
"use-isnan": 2,
40+
"valid-jsdoc": 0,
41+
"valid-typeof": 0,
42+
"no-unexpected-multiline": 0,
43+
"accessor-pairs": 2,
44+
"block-scoped-var": 2,
45+
"complexity": 2,
46+
"consistent-return": 0,
47+
"curly": 2,
48+
"default-case": 2,
49+
"dot-notation": 2,
50+
"dot-location": 0,
51+
"eqeqeq": [2,"allow-null"],
52+
"guard-for-in": 0,
53+
"no-alert": 0,
54+
"no-caller": 0,
55+
"no-div-regex": 0,
56+
"no-else-return": 0,
57+
"no-empty-label": 0,
58+
"no-eq-null": 0,
59+
"no-eval": 2,
60+
"no-extend-native": 0,
61+
"no-extra-bind": 2,
62+
"no-fallthrough": 2,
63+
"no-floating-decimal": 2,
64+
"no-implicit-coercion": [2,{"number":true,"string":true,"boolean":false}],
65+
"no-implied-eval": 2,
66+
"no-invalid-this": 0,
67+
"no-iterator": 2,
68+
"no-labels": 0,
69+
"no-lone-blocks": 0,
70+
"no-loop-func": 2,
71+
"no-multi-spaces": 2,
72+
"no-multi-str": 0,
73+
"no-native-reassign": 0,
74+
"no-new-func": 0,
75+
"no-new-wrappers": 2,
76+
"no-new": 2,
77+
"no-octal-escape": 0,
78+
"no-octal": 0,
79+
"no-param-reassign": 0,
80+
"no-process-env": 0,
81+
"no-proto": 0,
82+
"no-redeclare": 2,
83+
"no-return-assign": 0,
84+
"no-script-url": 0,
85+
"no-self-compare": 0,
86+
"no-sequences": 0,
87+
"no-throw-literal": 2,
88+
"no-unused-expressions": 0,
89+
"no-useless-call": 0,
90+
"no-void": 0,
91+
"no-warning-comments": [1,{"terms":["todo"," fixme"," TODO"," FIXME"],"location":"anywhere"}],
92+
"no-with": 0,
93+
"radix": 2,
94+
"vars-on-top": 2,
95+
"wrap-iife": [2,"inside"],
96+
"yoda": 0,
97+
"strict": [2,"global"],
98+
"init-declarations": 0,
99+
"no-catch-shadow": 2,
100+
"no-delete-var": 2,
101+
"no-label-var": 0,
102+
"no-shadow-restricted-names": 0,
103+
"no-shadow": 0,
104+
"no-undef-init": 0,
105+
"no-undef": 0,
106+
"no-undefined": 0,
107+
"no-unused-vars": 2,
108+
"no-use-before-define": 0,
109+
"callback-return": 0,
110+
"handle-callback-err": 2,
111+
"no-mixed-requires": 0,
112+
"no-new-require": 0,
113+
"no-path-concat": 2,
114+
"no-process-exit": 2,
115+
"no-restricted-modules": 0,
116+
"no-sync": 0,
117+
"array-bracket-spacing": 2,
118+
"brace-style": [2,"1tbs",{"allowSingleLine":true}],
119+
"camelcase": 2,
120+
"comma-spacing": 2,
121+
"comma-style": [2,"last"],
122+
"computed-property-spacing": 0,
123+
"consistent-this": [0, "self", "that"],
124+
"eol-last": 0,
125+
"func-names": 0,
126+
"func-style": 0,
127+
"id-length": 0,
128+
"indent": [2, 2, {
129+
"VariableDeclarator": 1,
130+
"SwitchCase": 1
131+
}],
132+
"key-spacing": [2,{"beforeColon":false,"afterColon":true}],
133+
"lines-around-comment": 0,
134+
"linebreak-style": 0,
135+
"max-nested-callbacks": [2, {"maximum":8}],
136+
"new-cap": 2,
137+
"new-parens": 2,
138+
"newline-after-var": 2,
139+
"no-array-constructor": 2,
140+
"no-continue": 0,
141+
"no-inline-comments": 0,
142+
"no-lonely-if": 0,
143+
"no-mixed-spaces-and-tabs": [2,"smart-tabs"],
144+
"no-multiple-empty-lines": [2,{"max":1}],
145+
"no-nested-ternary": 0,
146+
"no-new-object": 2,
147+
"no-spaced-func": 2,
148+
"no-ternary": 0,
149+
"no-trailing-spaces": 0,
150+
"no-underscore-dangle": [2, { "allowAfterThis": true }],
151+
"no-unneeded-ternary": 2,
152+
"object-curly-spacing": [2,"always",{}],
153+
"one-var": 0,
154+
"operator-assignment": 0,
155+
"operator-linebreak": 0,
156+
"padded-blocks": [2, {"switches":"always"}],
157+
"quote-props": [2, "consistent"],
158+
"quotes": [2,"single","avoid-escape"],
159+
"id-match": 0,
160+
"semi-spacing": [2,{"after":true}],
161+
"semi": [2,"always"],
162+
"sort-vars": 0,
163+
"keyword-spacing": 2,
164+
"space-before-blocks": 2,
165+
"space-before-function-paren": 0,
166+
"space-in-parens": 2,
167+
"space-infix-ops": 2,
168+
"space-return-throw-case": 0,
169+
"space-unary-ops": 0,
170+
"spaced-comment": [2, "always", {
171+
"line": {
172+
"markers": ["/"],
173+
"exceptions": ["-", "+"]
174+
},
175+
"block": {
176+
"markers": ["!"],
177+
"exceptions": ["*"]
178+
}
179+
}],
180+
"wrap-regex": 2,
181+
"arrow-parens": 0,
182+
"arrow-spacing": 0,
183+
"constructor-super": 0,
184+
"generator-star-spacing": 0,
185+
"no-class-assign": 0,
186+
"no-const-assign": 0,
187+
"no-this-before-super": 0,
188+
"no-var": 0,
189+
"object-shorthand": 0,
190+
"prefer-const": 0,
191+
"prefer-spread": 0,
192+
"prefer-reflect": 0,
193+
"require-yield": 0,
194+
"max-depth": [2,4],
195+
"max-len": [2,200,1,{"ignorePattern":"true"}],
196+
"max-params": 0,
197+
"max-statements": 0,
198+
"no-bitwise": [2, { "allow": ["~"] }],
199+
"no-plusplus": 2
200+
}
201+
}

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* text eol=lf
2+
3+
*.bat text eol=crlf
4+
*.sh text eol=lf
5+
6+
*.jpg binary
7+
*.png binary
8+
*.gif binary

.github/ISSUE_TEMPLATE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Type of Change
2+
- [ ] New Feature Request
3+
- [ ] Documentation
4+
- [ ] Improvement / Suggestion
5+
- [ ] Bug
6+
- [ ] Other (please clarify below)
7+
8+
## Summary
9+
<!-- Brief summary of the issue. -->
10+
11+
## Details
12+
<!-- code snippet, steps to reproduce, etc -->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!--
2+
## Submitting a Pull Request
3+
We love contributions and appreciate any help you can offer!
4+
-->
5+
6+
## Related Issue
7+
<!-- Include a link to the issue (e.g. Resolves #12) -->
8+
9+
## Summary of Changes
10+
<!-- Briefly summarize the changes made, lists are appreciated, ideally with checklists
11+
12+
1. [x] Thing I fixed
13+
1. [x] Other thing I updated
14+
1. [x] Docs I updated
15+
-->

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.vscode/
2+
credentials.*
3+
node_modules/
4+
tmp/

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
11
# lambda-github
2-
Lambda for (reverse) proxying GitHub API requests from the frontend
2+
[![GitHub release](https://img.shields.io/github/tag/ContributaryCommunity/lambda-topology.svg)](https://github.com/ContributaryCommunity/lambda-topology/tags)
3+
![CircleCI branch](https://img.shields.io/circleci/project/github/ContributaryCommunity/lambda-topology/master.svg?style=plastic)
4+
[![GitHub issues](https://img.shields.io/github/issues-raw/ContributaryCommunity/lambda-topology.svg)](https://github.com/ContributaryCommunity/lambda-topology/issues)
5+
[![GitHub issues](https://img.shields.io/github/issues-pr-raw/ContributaryCommunity/lambda-topology.svg)](https://github.com/ContributaryCommunity/lambda-topology/issues)
6+
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/ContributaryCommunity/lambda-topology/master/LICENSE.md)
7+
8+
## Overview
9+
Lambda for (reverse) proxying GitHub API requests from the frontend for getting live repositories and issues data.
10+
11+
## Workflow
12+
Changes submitted to _src/*.js_ are uploaded manually to the AWS Lambda function console. Currently there are two Lambdas used
13+
- _issues_ - Fetches issues from the GitHub API for a given project name and repository name
14+
- _repositories_ - Fetches repositories from the GitHub API for a given project name and repository type (_org_ or _user_)
15+
16+
## Development
17+
18+
For contributing to this project and testing the output locally, you will need
19+
1. [NodeJS](https://nodejs.org/) 8.x
20+
1. [Yarn](https://yarnpkg.com) 1.x
21+
1. Create _tmp/_ directory in the root of the project
22+
1. Set envrionment variable for devleopment: `export NODE_ENV=development`
23+
1. Export a [GitHub personal access token](https://blog.github.com/2013-05-16-personal-api-tokens/): `export ACCESS_TOKEN=XXX`
24+
25+
- `yarn lint` - Validatse all JS and JSON passes linting
26+
- `yarn function:issues` - Run _src/issues.js_ and by default output the file in _tmp/_
27+
- `yarn function:repositories` - Run _src/repositories.js_ and by default output the file in _tmp/_
28+
29+
## Release Procedure
30+
1. Merge all changes into master
31+
1. Bump _package.json_, `git tag` and push everything to master
32+
1. Upload the contents of _src/index.js_ to Lambda
33+
1. Create [Release Notes](https://github.com/ContributaryCommunity/lambda-topology/releases) in GitHub

package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "lambda-github",
3+
"version": "0.1.0",
4+
"description": "Lambda for (reverse) proxying GitHub API requests from the frontend",
5+
"main": "src/index.js",
6+
"repository": "git@github.com:ContributaryCommunity/lambda-github.git",
7+
"author": "Owen Buckley <owen@thegreenhouse.io>",
8+
"license": "MIT",
9+
"scripts": {
10+
"function:issues": "node ./src/issues.js",
11+
"function:repositories": "node ./src/repositories.js",
12+
"lint": "eslint src/*.js"
13+
},
14+
"devDependencies": {
15+
"eslint": "^5.8.0"
16+
}
17+
}

0 commit comments

Comments
 (0)