Created
March 14, 2020 10:21
-
-
Save irfanandriansyah1997/9dcca2be3be238101970560133c14c3f to your computer and use it in GitHub Desktop.
Firebase Example IOT
This file contains hidden or 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
| # Created by https://www.gitignore.io/api/node,phpstorm+all,visualstudiocode | |
| # Edit at https://www.gitignore.io/?templates=node,phpstorm+all,visualstudiocode | |
| ### Node ### | |
| # Logs | |
| logs | |
| *.log | |
| npm-debug.log* | |
| yarn-debug.log* | |
| yarn-error.log* | |
| lerna-debug.log* | |
| # Diagnostic reports (https://nodejs.org/api/report.html) | |
| report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | |
| # 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 | |
| *.lcov | |
| # nyc test coverage | |
| .nyc_output | |
| # Grunt intermediate storage (https://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/ | |
| # TypeScript cache | |
| *.tsbuildinfo | |
| # 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 | |
| .env.test | |
| # parcel-bundler cache (https://parceljs.org/) | |
| .cache | |
| # next.js build output | |
| .next | |
| # nuxt.js build output | |
| .nuxt | |
| # vuepress build output | |
| .vuepress/dist | |
| # Serverless directories | |
| .serverless/ | |
| # FuseBox cache | |
| .fusebox/ | |
| # DynamoDB Local files | |
| .dynamodb/ | |
| ### PhpStorm+all ### | |
| # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | |
| # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | |
| # User-specific stuff | |
| .idea/**/workspace.xml | |
| .idea/**/tasks.xml | |
| .idea/**/usage.statistics.xml | |
| .idea/**/dictionaries | |
| .idea/**/shelf | |
| # Generated files | |
| .idea/**/contentModel.xml | |
| # Sensitive or high-churn files | |
| .idea/**/dataSources/ | |
| .idea/**/dataSources.ids | |
| .idea/**/dataSources.local.xml | |
| .idea/**/sqlDataSources.xml | |
| .idea/**/dynamic.xml | |
| .idea/**/uiDesigner.xml | |
| .idea/**/dbnavigator.xml | |
| # Gradle | |
| .idea/**/gradle.xml | |
| .idea/**/libraries | |
| # Gradle and Maven with auto-import | |
| # When using Gradle or Maven with auto-import, you should exclude module files, | |
| # since they will be recreated, and may cause churn. Uncomment if using | |
| # auto-import. | |
| # .idea/modules.xml | |
| # .idea/*.iml | |
| # .idea/modules | |
| # *.iml | |
| # *.ipr | |
| # CMake | |
| cmake-build-*/ | |
| # Mongo Explorer plugin | |
| .idea/**/mongoSettings.xml | |
| # File-based project format | |
| *.iws | |
| # IntelliJ | |
| out/ | |
| # mpeltonen/sbt-idea plugin | |
| .idea_modules/ | |
| # JIRA plugin | |
| atlassian-ide-plugin.xml | |
| # Cursive Clojure plugin | |
| .idea/replstate.xml | |
| # Crashlytics plugin (for Android Studio and IntelliJ) | |
| com_crashlytics_export_strings.xml | |
| crashlytics.properties | |
| crashlytics-build.properties | |
| fabric.properties | |
| # Editor-based Rest Client | |
| .idea/httpRequests | |
| # Android studio 3.1+ serialized cache file | |
| .idea/caches/build_file_checksums.ser | |
| ### PhpStorm+all Patch ### | |
| # Ignores the whole .idea folder and all .iml files | |
| # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 | |
| .idea/ | |
| # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 | |
| *.iml | |
| modules.xml | |
| .idea/misc.xml | |
| *.ipr | |
| # Sonarlint plugin | |
| .idea/sonarlint | |
| ### VisualStudioCode ### | |
| .vscode/* | |
| !.vscode/settings.json | |
| !.vscode/tasks.json | |
| !.vscode/launch.json | |
| !.vscode/extensions.json | |
| ### VisualStudioCode Patch ### | |
| # Ignore all local history of files | |
| .history | |
| # End of https://www.gitignore.io/api/node,phpstorm+all,visualstudiocode | |
| src/modules/firebase-admin/secret/dont-be-alone\.secret\.json |
This file contains hidden or 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
| import * as admin from 'firebase-admin'; | |
| const secret = require('./secret/dont-be-alone.secret.json'); | |
| export class FirebaseAdminModule { | |
| private conf: admin.app.App; | |
| private database: admin.database.Database; | |
| private ref: admin.database.Reference; | |
| constructor() { | |
| this.conf = admin.initializeApp({ | |
| credential: admin.credential.cert(secret), | |
| databaseURL: 'https://dont-be-alone-246305.firebaseio.com' | |
| }); | |
| this.database = this.conf.database(); | |
| this.ref = this.database.ref('database'); | |
| } | |
| public chat(event: string, message: string): void { | |
| const child = this.ref.child(event); | |
| child.push().set({ | |
| date: Date.now(), | |
| message, | |
| event | |
| }); | |
| } | |
| } |
This file contains hidden or 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
| import { FirebaseAdminModule } from "./firebase-admin.modules"; | |
| new FirebaseAdminModule().chat('testing', 'hello world'); |
This file contains hidden or 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
| { | |
| "name": "firebaseexample", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "index.js", | |
| "scripts": { | |
| "predev": "tsc ./index.ts", | |
| "dev": "node ./index.js" | |
| }, | |
| "author": "Irfan Andriansyah <irfanandriansyah10@gmail.com>", | |
| "license": "ISC", | |
| "dependencies": { | |
| "firebase-admin": "^8.10.0" | |
| }, | |
| "devDependencies": { | |
| "ts-node": "^8.6.2", | |
| "tsconfig-paths": "^3.9.0", | |
| "typescript": "^3.8.3" | |
| } | |
| } |
This file contains hidden or 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
Show hidden characters
| { | |
| "compilerOptions": { | |
| "sourceMap": true, | |
| "target": "esnext", | |
| "jsx": "react", | |
| "module": "CommonJS", | |
| "moduleResolution": "node", | |
| "esModuleInterop": true, | |
| "experimentalDecorators": true, | |
| "emitDecoratorMetadata": true, | |
| "declaration": false, | |
| "removeComments": true, | |
| "noUnusedLocals": true, | |
| "strict": true, | |
| "strictFunctionTypes": false, | |
| "outDir": "build", | |
| "lib": ["es6", "es7", "dom"], | |
| "baseUrl": "./", | |
| "paths": {} | |
| }, | |
| "exclude": ["build", "node_modules"] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment