Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Commit

Permalink
Add firebase functions API
Browse files Browse the repository at this point in the history
  • Loading branch information
Ta0uf19 committed Jun 20, 2020
1 parent 8d885fc commit 20d85cf
Show file tree
Hide file tree
Showing 14 changed files with 2,656 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mycoach-api/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "mycoach-77f86"
}
}
68 changes: 68 additions & 0 deletions mycoach-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#idea
.idea/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*

# Firebase cache
.firebase/

# Firebase config

# Uncomment this if you'd like others to create their own Firebase project.
# For a team working on the same Firebase project(s), it is recommended to leave
# it commented so all members can deploy to the same project(s) in .firebaserc.
# .firebaserc

# 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 (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# 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
39 changes: 39 additions & 0 deletions mycoach-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

# API for MyCoash
Using Firebase Functions, Firestore and Dialogflow

### POST /dialogflowGateway
- Talk with chatbot

Query
```
{
"sessionId": "50",
"queryInput": {
"text": {
"text": "Salut!",
"languageCode": "fr-FR"
}
}
}
```
### POST /detectIntent

- Detect intention and update workout data

### POST /workouts
- Get workouts of a user in a specfic date
```
{
"userId": "50",
"date": "2020-06-18"
}
```

## Firestore db structure



## License

Copyright © 2020, [Taoufik Tribki](https://github.com/ta0uf19). Released under the [MIT License](https://github.com/jonschlinkert/update-copyright/blob/master/LICENSE).
12 changes: 12 additions & 0 deletions mycoach-api/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
}
4 changes: 4 additions & 0 deletions mycoach-api/firestore.indexes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"indexes": [],
"fieldOverrides": []
}
17 changes: 17 additions & 0 deletions mycoach-api/firestore.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {

// This rule allows anyone on the internet to view, edit, and delete
// all data in your Firestore database. It is useful for getting
// started, but it is configured to expire after 30 days because it
// leaves your app open to attackers. At that time, all client
// requests to your Firestore database will be denied.
//
// Make sure to write security rules for your app before that time, or else
// your app will lose access to your Firestore database
match /{document=**} {
allow read, write: if request.time < timestamp.date(2020, 7, 15);
}
}
}
8 changes: 8 additions & 0 deletions mycoach-api/functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Compiled JavaScript files
**/*.js
**/*.js.map

# Typescript v1 declaration files
typings/

node_modules/
12 changes: 12 additions & 0 deletions mycoach-api/functions/lib/service-account-key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "service_account",
"project_id": "mycoach-77f86",
"private_key_id": "703b003656ea2a7efd0584e53479f592edfe89c4",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDk5nMIwgvsKoHq\ntTRuLIyQTUSGbYNTm/+1SK5X9JOg1L8AdluzK7kGJZ2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b5LNXBxdMx\nHqiG/lTHGpLVodfA4Bo+eXpMJBQWK9hP3Lb/RTybCeEFYU2bwlhr7qDlWVVf3h9c\n7yXNgbsny8WtO0pHP6FHV6eg0lQ0O0xQaK6z52eDFw8/YksvD6pdxGMJAoGBAMbm\njhHMNOdy3VFJ8gYqSSqJHhh2btuZ0kfooMJcMmcEJzhWA7IN+5kqYkiKtHL3EwB3\n79DkjkkD4adKmlD9XYFDwQUgNqw6cZQQ5cjfar6nqfsnXyfAQwZY4NVZf8/actIQ\nBZptR+iUalBn9p27XtSXZMe2MxaciOHxtXtaJPK9AoGAAyNHy8hOhe192IfJr6OK\naQmaGFOtdSe7Xha8iImPSrbLTCwUEdmLfXIT/8bE6s9ZhE+szUwso8056WM/tldn\njFMc1IeXhT7Pq23thsLjNTSA+/m9xMq0Jab4644pKljryiAMXSca2yE5YJ1FXd8z\n1M8HIfUMgojVSlmmkylJemU=\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-mycoach@mycoach-77f86.iam.gserviceaccount.com",
"client_id": "110064585400738855058",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-mycoach%40mycoach-77f86.iam.gserviceaccount.com"
}
Loading

0 comments on commit 20d85cf

Please sign in to comment.