https://github.com/holasoycael/boilerplate-firebase-functions
π₯β¨ Este Γ© meu boilerplate do Google Cloud Functions para aplicaΓ§Γ΅es Firebase dentro do Emulators usando TypeScript
https://github.com/holasoycael/boilerplate-firebase-functions
backend-api boilerplate firebase firebase-functions gcp gcp-cloud-functions typescript
Last synced: 10 months ago
JSON representation
π₯β¨ Este Γ© meu boilerplate do Google Cloud Functions para aplicaΓ§Γ΅es Firebase dentro do Emulators usando TypeScript
- Host: GitHub
- URL: https://github.com/holasoycael/boilerplate-firebase-functions
- Owner: holasoycael
- Created: 2022-05-26T21:08:37.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-04T01:52:04.000Z (over 3 years ago)
- Last Synced: 2025-01-05T21:08:59.945Z (12 months ago)
- Topics: backend-api, boilerplate, firebase, firebase-functions, gcp, gcp-cloud-functions, typescript
- Language: TypeScript
- Homepage:
- Size: 85 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## π Getting Started
In your project folder use this to install:
```sh
git clone https://github.com/holasoycael/boilerplate-firebase-functions.git . && rm -rf ./.git && git init && git branch -M main && git add . && git commit -m "Initial commit"
```
Now just add your remote repository β¨
In the folder above functions use the command below to start the emulators:
```sh
firebase emulators:start --import=./data --export-on-exit=./data
```
To listen for changes inside the VSCode use the command:
```sh
yarn build --watch
```
## Using Path Mapping
To use `path alias` in your project ensure it is seen by both TypeScript and Babel. This will ensure that we have them in our text editor and the transpiler will know where they are.
Follow the examples below example:
`tsconfig.json`
```json
{
"__comment_above__": "code above for example...",
"baseUrl": ".",
"paths": {
"@controllers/*": ["./src/controllers/*"],
"@routes/*": ["./src/routes/*"],
"@configs/*": ["./src/configs/*"],
"@middlewares/*": ["./src/middlewares/*"],
"@modules/*": ["./src/modules/*"],
"@models/*": ["./src/models/*"],
"@typings/*": ["./src/typings/*"],
"@utils/*": ["./src/utils/*"]
},
"__comment_below__": "code below for example...",
}
```
`babel.config.js`
```js
module.exports = {
// code ...
plugins: [
['module-resolver', {
alias: {
'@controllers': './src/controllers',
'@utils': './src/utils',
'@configs': './src/configs',
'@middlewares': './src/middlewares',
'@modules': './src/modules',
'@models': './src/models',
'@typings': './src/typings',
'@routes': './src/routes'
}
}]
],
// code ...
}
```
Now the project is ready to use π₯
#
### `Design architecture`
```
functions
βββ .vscode
β βββ settings.json
βββ node_modules
βββ src
β βββ configs
β β βββ firebase.ts
β β βββ serviceAccount.json
β βββ controllers
β β βββ HelloController.ts
β βββ middlewares
β β βββ Default
β β β βββ handle.ts
β β β βββ store.ts
β β βββ `PascalCase`
β β βββ handle.ts
β β βββ store.ts
β βββ models
β β βββ `PascalCase`
β β βββ index.ts
β βββ modules
β β βββ auth.ts
β β βββ firestore.ts
β β βββ realtime.ts
β βββ routes
β β βββ `PascalCase`
β β βββ index.tsx
β βββ tests
β βββ typing
β β βββ Default.ts
β β βββ Hello.ts
β β βββ User.ts
β βββ utils
β β βββ jwt.ts
β βββ index.ts
βββ .editorconfig
βββ .eslintignore
βββ .eslintrc.js
βββ .gitignore
βββ .prettierignore
βββ .prettierrc
βββ babel.config.js
βββ package.json
βββ README.md
βββ tsconfig.dev.json
βββ tsconfig.json
βββ yarn.lock
```