-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
5dff5c3
commit f2d35ee
Showing
19 changed files
with
13,628 additions
and
61 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,62 @@ | ||
version: 2 | ||
|
||
aliases: | ||
- &set-working-directory | ||
working_directory: /home/circleci/project | ||
|
||
- &attach-workspace | ||
attach_workspace: | ||
at: /home/circleci/project | ||
|
||
jobs: | ||
build: | ||
<<: *set-working-directory | ||
docker: | ||
- image: circleci/node:8.4.0 | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
name: Restore NPM Package Cache | ||
key: npm-packages-{{ .Branch }}-{{ checksum "package.json" }} | ||
- run: | ||
name: Install Dependencies | ||
command: npm install | ||
- save_cache: | ||
name: Save NPM Package Cache | ||
key: npm-packages-{{ .Branch }}-{{ checksum "package.json" }} | ||
paths: | ||
- node_modules/ | ||
- run: | ||
name: Run Tests | ||
command: npm run test | ||
- persist_to_workspace: | ||
root: /home/circleci/project | ||
paths: | ||
- ./* | ||
deploy: | ||
<<: *set-working-directory | ||
docker: | ||
- image: circleci/python:2.7 | ||
steps: | ||
- *attach-workspace | ||
- run: | ||
name: Install awsebcli | ||
command: sudo pip install awsebcli | ||
- run: | ||
name: Install awscli | ||
command: sudo pip install awscli | ||
- run: | ||
name: Deploy to EB | ||
command: .circleci/scripts/deploy_backend.sh $BACKEND_BUCKET_ID $FIREBASE_BUCKET_ID $TEAM_NAME | ||
workflows: | ||
version: 2 | ||
test_deploy: | ||
jobs: | ||
- build | ||
- deploy: | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
requires: | ||
- build |
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,13 @@ | ||
#!/bin/sh -ex | ||
|
||
set -ex | ||
|
||
BUCKET=$1 | ||
FIREBASE_BUCKET=$2 | ||
TEAM_NAME=$3 | ||
aws s3 cp s3://"${FIREBASE_BUCKET}/${TEAM_NAME}-firebase.json" "firebase-credentials.json" | ||
|
||
git archive -v -o artifact.zip --format=zip HEAD | ||
zip -rv artifact.zip firebase-credentials.json | ||
|
||
aws s3 cp artifact.zip s3://"${BUCKET}" |
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 @@ | ||
/node_modules |
Empty file.
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,61 +1,4 @@ | ||
# Logs | ||
logs | ||
node_modules | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# next.js build output | ||
.next | ||
firebase-credentials.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,2 @@ | ||
# Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm@5 | ||
unsafe-perm=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 |
---|---|---|
@@ -0,0 +1 @@ | ||
This project starter by [bridge-school](https://github.com/bridge-school) is licensed under a [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.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 |
---|---|---|
@@ -1,2 +1,96 @@ | ||
# bridge-slackbot-8-backend | ||
bridge-slackbot-8 backend! | ||
## Installation | ||
|
||
```sh | ||
$ npm install | ||
``` | ||
|
||
## Setup the app for local development | ||
|
||
We are using Firebase [cloud fire store](https://firebase.google.com/docs/firestore/quickstart) for our database. | ||
|
||
To setup a connection to the database: | ||
|
||
1. Have a look in your project slack channel for a pinned JSON file called `firebase-credentials.json`. | ||
2. Create a `firebase-credentials.json` file in the root directory of this repository and copy the contents from the file in the slack channel | ||
3. Run `yarn start:local` and if everything is running smoothly you should see no errors | ||
4. To test your server is running correctly, go to `http://localhost:8081/health` in your browser. If you see `{ ok: 'OK' }` then everything is running as expected. If you're not seeing this, reach out to your tech lead or mentor over slack to help you debug! | ||
|
||
To query the database you will need to `require` the `db` instance that is exported from `db/index.js`. You can use the [firebase docs](https://firebase.google.com/docs/firestore/query-data/get-data) and have a look under the node.js tab for examples. | ||
|
||
## Run the app for local development | ||
|
||
```sh | ||
$ npm run start:local | ||
``` | ||
|
||
## Run the app in production | ||
|
||
``` | ||
$ npm start | ||
``` | ||
|
||
## Folder Structure | ||
|
||
``` | ||
|-api | ||
|-db | ||
|-middleware | ||
|-routes | ||
|---health | ||
|-utils | ||
``` | ||
|
||
### `api` | ||
|
||
This is where you add new routes, see the example `health` route. | ||
|
||
### `db` | ||
|
||
This is where the Firebase connection is configured. To query the database you will need to `require` the `db` instance that is exported from `db/index.js`. | ||
|
||
### `middleware` | ||
|
||
Middleware functions are functions that have access to the request object (`req`), the response object (`res`), and the next middleware function in the application’s request-response cycle. | ||
|
||
Middleware can be at the application level or at the router level. You won't be interacting with this folder much. | ||
|
||
### `routes` | ||
|
||
This is where all the logic for your endpoints will live. You should make a new folder under `routes` for each set of endpoints you will write, similar to the `health` folder that exists as an example. | ||
|
||
### `utils` | ||
|
||
This is a multi-purpose folder for any extra utility functions that you might want to reuse throughout your app. | ||
|
||
## Project Workflow | ||
|
||
### Setting up | ||
|
||
- Clone your git repos directly (do not fork!) | ||
- Follow the setup instructions for each repo in the respective READMEs | ||
- Run the app | ||
|
||
### Development Workflow | ||
|
||
- Pick a feature / part of a feature from your project board and assign it to yourself. Move the ticket into in progress and make sure your whole team knows you are working on it. | ||
- Pull the most recent version of master and create a branch off it | ||
- For a feature: `feat/<name of your feature>` | ||
- For a bug: `bug/<name of bug>` | ||
- For a chore: `chore/<name of chore>` | ||
- Work on your ticket | ||
- Once you are ready to get some feedback on your code, push your branch | ||
- `git push origin <name of your branch>` | ||
- Go to GitHub and create a Pull Request | ||
- The title should be formatted as `[Feature/Bug/Chore][Ticket #] Title of what you did` | ||
- In the description make sure to link to the ticket and include any relevant screenshots | ||
- Describe all the changes you have made | ||
- Assign your team members for review, once you have one approval you can merge your code | ||
- Your code will be automatically deployed to the development environment | ||
|
||
### General Tips | ||
|
||
- Break your features into small chunks of work | ||
- Try to keep PRs as small and single purpose as possible | ||
- Use your class time to break up work, review PRs and make sure everyone leaves with an idea of what they are working on | ||
- Bug people to review your PRs! | ||
- If you have many PRs open, prioritize getting them reviewed and merged over starting new work |
Oops, something went wrong.