-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modules for shared types and functions
- Loading branch information
Resul Avan
authored and
Resul Avan
committed
Jul 21, 2020
1 parent
553a0cc
commit a57a86a
Showing
37 changed files
with
216 additions
and
593 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
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 |
---|---|---|
|
@@ -103,7 +103,7 @@ node_modules | |
|
||
# modules | ||
lib | ||
**/*.tar.gz | ||
**/*.tgz | ||
|
||
# firebase | ||
functions/nuxt.config.ts | ||
|
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
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 |
---|---|---|
|
@@ -37,3 +37,6 @@ | |
|
||
### deploy sitemapApp | ||
firebase deploy --only functions:sitemapApp | ||
|
||
## install modules | ||
go to [modules](./modules) |
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,24 +1,14 @@ | ||
# modules | ||
The code has nuxt frontend application and firebase functions as backend. Additionally, nuxt application has `serverMiddleware`. That `serverMiddleware` has same functionality as `firebase-functions`. That means there are some shared types and functions. | ||
|
||
## build | ||
npm i | ||
npm run build | ||
|
||
## install local modules | ||
npm i <local-path-of-the-module> | ||
|
||
or | ||
npm i <tar.gz-path-of-the-module> | ||
|
||
|
||
sample | ||
The `modules` has been created to keep consistency, the code clean and reduce the maintenance duration. | ||
|
||
npm i ../modules/types-module | ||
npm i ../modules/types-module/types-module-1.0.0.tgz | ||
The modules: | ||
- [types-module](./types-module): has all shared types (enums, interfaces, constants) | ||
- [handlers-module](./handlers-module): has all express handlers. Also, has all backend services like firebase-admin and firestore | ||
|
||
## remove local modules | ||
npm remove <package-name-of-the-module> | ||
## npm install on all modules | ||
npm run install | ||
|
||
sample | ||
|
||
npm remove types-module | ||
## build all modules | ||
npm run 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 |
---|---|---|
@@ -1,11 +1,19 @@ | ||
# types module | ||
# handlers-module | ||
|
||
## build | ||
npm i | ||
npm run build | ||
|
||
## install | ||
npm i ../modules/types-module | ||
npm i <relative-path-from-target-package> | ||
|
||
`on function` | ||
|
||
npm i ../modules/handlers-module | ||
|
||
`on src (nuxt)` | ||
|
||
npm i ../functions/modules/handlers-module | ||
|
||
## remove local modules | ||
npm remove types-module | ||
npm remove handlers-module |
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
import admin from 'firebase-admin' | ||
|
||
export class HandlerConfig { | ||
|
||
private static credentials = '' | ||
|
||
private static readonly defaultInitializer = () => { | ||
admin.initializeApp({ | ||
credential: admin.credential.applicationDefault() | ||
}) | ||
console.log('firebase admin is initialized by default credentials') | ||
return admin | ||
} | ||
|
||
private static readonly credentialsInitializer = () => { | ||
const serviceAccount = HandlerConfig.credentials | ||
// const serviceAccount = require(HandlerConfig.credentials) | ||
admin.initializeApp({ | ||
credential: admin.credential.cert(serviceAccount) | ||
}) | ||
console.log('firebase admin is initialized by custom credentials') | ||
} | ||
|
||
static setCredentials = (credentials: string) => { | ||
HandlerConfig.credentials = credentials | ||
} | ||
|
||
static getAdmin () { | ||
if (admin.apps.length === 0) { | ||
this.credentials ? this.credentialsInitializer() : this.defaultInitializer() | ||
} | ||
return admin; | ||
} | ||
|
||
} |
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,5 @@ | ||
export * from './handler-config' | ||
export * from './api' | ||
export * from './sitemap-handler' | ||
export * from './service/request-handler-service' | ||
export * from './service/global-service' |
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
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
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
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,9 @@ | ||
{ | ||
"scripts": { | ||
"build": "npm --prefix types-module run build && npm --prefix handlers-module run build", | ||
"install": "npm --prefix types-module install && npm --prefix handlers-module install", | ||
"re-install": "npm run clear-all && npm run install", | ||
"clear": "rm -rf */lib", | ||
"clear-all": "rm -rf */node_modules */lib */package-lock.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 |
---|---|---|
@@ -1,11 +1,19 @@ | ||
# types module | ||
# types-module | ||
|
||
## build | ||
npm i | ||
npm run build | ||
|
||
## install | ||
npm i <relative-path-from-target-package> | ||
|
||
`on function` | ||
|
||
npm i ../modules/types-module | ||
|
||
`on src (nuxt)` | ||
|
||
npm i ../functions/modules/types-module | ||
|
||
## remove local modules | ||
npm remove types-module |
Oops, something went wrong.