Skip to content

πŸ”₯✨ Este Γ© meu boilerplate do Google Cloud Functions para aplicaçáes Firebase dentro do Emulators usando TypeScript

Notifications You must be signed in to change notification settings

holasoycael/boilerplate-firebase-functions

Repository files navigation

🌟 Getting Started

In your project folder use this to install:

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:

firebase emulators:start --import=./data --export-on-exit=./data

To listen for changes inside the VSCode use the command:

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

{
  "__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

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

About

πŸ”₯✨ Este Γ© meu boilerplate do Google Cloud Functions para aplicaçáes Firebase dentro do Emulators usando TypeScript

Topics

Resources

Stars

Watchers

Forks