Skip to content

Commit

Permalink
Merge pull request #12 from ciatph/dev
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
ciatph authored Apr 7, 2022
2 parents e951b9a + e3ef2bd commit f7dbaa2
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 20 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/others.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Lint Files

on:
push:
branches-ignore:
- master
on: [push]

jobs:
lint-client:
Expand Down
29 changes: 20 additions & 9 deletions .github/workflows/dev.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Deploy to Development Environment

# This workflow will trigger on any tag/release created on *any* branch
# Make sure to create tags/releases only from the "master" branch for consistency
on:
push:
branches:
- master
release:
types: [published]

jobs:
lint-client:
Expand Down Expand Up @@ -79,12 +80,22 @@ jobs:
name: Deploy Server to Heroku
needs: lint-server
runs-on: ubuntu-latest
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }}
HEROKU_APP: ${{ secrets.HEROKU_APP }}
steps:
- name: Checkout the repository
uses: actions/checkout@v1
- name: Use NodeJS ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Deploy to Heroku
run: git push -f https://heroku:${{ secrets.HEROKU_API_TOKEN }}@git.heroku.com/${{ secrets.HEROKU_APP }}.git origin/master:master
- run: |
cat >~/.netrc <<EOF
machine api.heroku.com
login $HEROKU_EMAIL
password $HEROKU_API_KEY
machine git.heroku.com
login $HEROKU_EMAIL
password $HEROKU_API_KEY
EOF
- run: heroku git:remote -a $HEROKU_APP
- run: git push heroku HEAD:refs/heads/master
- run: rm -r -f .netrc
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ A basic web app client in the **/client** directory will show basic API usage an
**Project Settings** -> **Service accounts** -> **Generate new private key**
- `FIREBASE_PRIVATE_KEY`
- The `private_key` entry from the service account JSON file
- Take note to make sure that the value starts and ends with a double-quote
- > **NOTE:** Take note to make sure that the value starts and ends with a double-quote on WINDOWS OS localhost. Some systems may or may not require the double-quotes (i.e., Ubuntu running on heroku).
- `ALLOWED_ORIGINS`
- IP/domain origins in comma-separated values that are allowed to access the API

Expand Down
21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "firebase-users-admin",
"version": "1.0.0",
"description": "API for Firebase Authentication users management using the firebase-admin SDK.",
"main": "index.js",
"scripts": {
"install": "cd server && npm install",
"build": "cd server && npm run build",
"start": "cd server && npm start"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ciatph/firebase-users-admin.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/ciatph/firebase-users-admin/issues"
},
"homepage": "https://github.com/ciatph/firebase-users-admin#readme"
}
5 changes: 3 additions & 2 deletions server/apidoc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "Firebase Auth Users CRUD API",
"version": "1.0.0",
"description": "Documentation for the CRUD API of a Firebase Auth users management app",
"description": "REST API Documentation",
"title": "Firebase Auth Users CRUD API",
"url": "http://localhost:3001/api",
"sampleUrl": "http://localhost:3001/api",
"header": {
"title": "Firebase Auth Users CRUD API"
"title": "Firebase Auth Users CRUD API",
"filename": "src/utils/templates/header.md"
},
"template": {
"withCompare": false,
Expand Down
2 changes: 1 addition & 1 deletion server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "firebase-users-admin",
"name": "firebase-users-admin-server",
"version": "1.0.0",
"description": "API for Firebase Authentication users management using the firebase-admin SDK.",
"main": "index.js",
Expand Down
4 changes: 4 additions & 0 deletions server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ app.use(cors({

app.use('/api', controllers)

app.get('/', (req, res) => {
res.status(200).send('OK!')
})

app.listen(PORT, () => {
console.log(`listening on http://localhost:${PORT}`)
})
4 changes: 2 additions & 2 deletions server/src/utils/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ if (process.env.FIREBASE_SERVICE_ACC === undefined || process.env.FIREBASE_PRIVA
} else {
const serviceAccount = JSON.parse(process.env.FIREBASE_SERVICE_ACC)

// Add double-quotes around the "private_key" JSON
serviceAccount.private_key = process.env.FIREBASE_PRIVATE_KEY
// Escape the "private_key" read by dotenv
serviceAccount.private_key = process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n')

initializeApp({
credential: credential.cert(serviceAccount)
Expand Down
22 changes: 22 additions & 0 deletions server/src/utils/templates/header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### Introduction

CRUD API for Firebase Authentication users management using the firebase-admin SDK

### Demo

<p>Login using the default user credentials:</p>

```
username: superamin@gmail.com
password: 123456789
```

- **live client app:** [https://fire-auth-users.web.app/](https://fire-auth-users.web.app/)
- **localhost app:** [http://localhost:3000](http://localhost:3000)
- Read more about the localhost environment set-up instructions on [firebase-auth-users](https://github.com/ciatph/firebase-users-admin)

### References

- [firebase-auth-users](https://github.com/ciatph/firebase-users-admin) (GitHub repo)
- [Firebase Authentication](https://firebase.google.com/docs/auth)
- [Firebase Admin](https://firebase.google.com/docs/admin/setup)

0 comments on commit f7dbaa2

Please sign in to comment.