https://github.com/jcmdsbr/nest-cloud-function
Node Cloud Functions using Nest standalone application is a wrapper around the Nest IoC container
https://github.com/jcmdsbr/nest-cloud-function
Last synced: 5 months ago
JSON representation
Node Cloud Functions using Nest standalone application is a wrapper around the Nest IoC container
- Host: GitHub
- URL: https://github.com/jcmdsbr/nest-cloud-function
- Owner: jcmdsbr
- Created: 2021-05-31T20:08:41.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-23T22:00:05.000Z (about 5 years ago)
- Last Synced: 2025-05-31T15:31:23.170Z (about 1 year ago)
- Language: TypeScript
- Size: 196 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [GCP] Cloud functions using nodejs + nestjs :sunglasses:
- Node Cloud Functions using Nest standalone application is a wrapper around the Nest IoC container
## Standalone applications :star:
There are several ways of mounting a Nest application. You can create a web app, a microservice or just a bare Nest standalone application (without any network listeners). The Nest standalone application is a wrapper around the Nest IoC container, which holds all instantiated classes.
We can obtain a reference to any existing instance from within any imported module directly using the standalone application object.
Thus, you can take advantage of the Nest framework anywhere, including, for example, scripted CRON jobs. You can even build a CLI on top of it.
## Getting started :exclamation:
### Before :heavy_check_mark:
- Install firebase-tools
```sh
npm i -g firebase-tools
```
## Init firebase function strucure :heavy_check_mark:
```sh
firebase init functions
firebase init emulators
```
### Add Nest to the Functions Source :heavy_check_mark:
In functions folder
To create a Nest standalone application and Add , use the following construction:
```sh
npm i --save @nestjs/core @nestjs/common rxjs reflect-metadata
```
If HTTP function install
```sh
npm i --save express @nestjs/platform-express
```
- Create a nest-cli.json file
```json
{
"language": "ts",
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}
```
And add new configuration from tsconfig.json
```json
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": false,
"target": "es2017",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"declaration": true,
"removeComments": true,
"baseUrl": "./",
"incremental": true,
"esModuleInterop": true
},
"compileOnSave": true,
"include": [
"src"
]
}
```
## Deploy :heavy_check_mark:
```sh
firebase login
firebase deploy --only functions --project [YOUR PROJECT NAME] --region [YOUR PROJECT REGION]
```