Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/nx-firebase-e2e/test-utils/test-utils-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function expectedFunctionProjectTargets(
dependenciesFieldType: 'dependencies',
format: ['esm'],
thirdParty: false,
target: 'node18',
target: 'node20',
esbuildOptions: {
logLevel: 'info',
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@nx/webpack": "21.6.10",
"@nx/workspace": "21.6.10",
"@types/jest": "30.0.0",
"@types/node": "18.19.99",
"@types/node": "20.19.0",
"@types/semver": "^7.3.13",
"eslint": "^9.8.0",
"eslint-config-prettier": "10.1.8",
Expand All @@ -41,7 +41,7 @@
"firebase-admin": "13.6.0",
"firebase-functions": "7.0.3",
"firebase-functions-test": "3.4.1",
"firebase-tools": "13.35.1",
"firebase-tools": "15.3.1",
"jest": "30.0.5",
"jest-environment-jsdom": "30.0.5",
"kill-port": "2.0.1",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
// Example:
// Example (Standard Edition):
//
// "indexes": [
// {
Expand All @@ -21,6 +21,31 @@
// },
// ]
// ]
//
// Example (Enterprise Edition):
//
// "indexes": [
// {
// "collectionGroup": "reviews",
// "queryScope": "COLLECTION_GROUP",
// "apiScope": "MONGODB_COMPATIBLE_API",
// "density": "DENSE",
// "multikey": false,
// "fields": [
// { "fieldPath": "baz", "mode": "ASCENDING" }
// ]
// },
// {
// "collectionGroup": "items",
// "queryScope": "COLLECTION_GROUP",
// "apiScope": "MONGODB_COMPATIBLE_API",
// "density": "SPARSE_ANY",
// "multikey": true,
// "fields": [
// { "fieldPath": "baz", "mode": "ASCENDING" }
// ]
// },
// ]
"indexes": [],
"fieldOverrides": []
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
rules_version='2'

service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@
* See a full list of supported triggers at https://firebase.google.com/docs/functions
*/

import {onRequest} from "firebase-functions/v2/https";
import {setGlobalOptions} from "firebase-functions";
import {onRequest} from "firebase-functions/https";
import * as logger from "firebase-functions/logger";

// Start writing functions
// https://firebase.google.com/docs/functions/typescript

// For cost control, you can set the maximum number of containers that can be
// running at the same time. This helps mitigate the impact of unexpected
// traffic spikes by instead downgrading performance. This limit is a
// per-function limit. You can override the limit for each function using the
// `maxInstances` option in the function's options, e.g.
// `onRequest({ maxInstances: 5 }, (req, res) => { ... })`.
// NOTE: setGlobalOptions does not apply to functions using the v1 API. V1
// functions should each use functions.runWith({ maxInstances: 10 }) instead.
// In the v1 API, each function can only serve one request per container, so
// this will be the maximum concurrent request count.
setGlobalOptions({ maxInstances: 10 });

// export const helloWorld = onRequest((request, response) => {
// logger.info("Hello logs!", {structuredData: true});
// response.send("Hello from Firebase!");
Expand Down
16 changes: 8 additions & 8 deletions packages/nx-firebase/src/generators/function/function.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('function generator', () => {
bundle: true,
thirdParty: false,
dependenciesFieldType: 'dependencies',
target: 'node18',
target: 'node20',
format: ['esm'],
esbuildOptions: {
logLevel: 'info',
Expand Down Expand Up @@ -195,7 +195,7 @@ describe('function generator', () => {
expect(firebaseConfig.functions[0]).toEqual({
codebase: 'myFirebaseFunction',
source: 'dist/myFirebaseFunction',
runtime: `nodejs18`,
runtime: `nodejs20`,
ignore: ['*.local'],
})
})
Expand All @@ -215,7 +215,7 @@ describe('function generator', () => {
expect(firebaseConfig.functions[0]).toEqual({
codebase: 'myFirebaseFunction',
source: 'dist/myFirebaseFunction',
runtime: `nodejs18`,
runtime: `nodejs20`,
ignore: ['*.local'],
})
})
Expand All @@ -225,7 +225,7 @@ describe('function generator', () => {
const testFunction = {
codebase: 'test',
source: 'dist/apps/test',
runtime: `nodejs18`,
runtime: `nodejs20`,
ignore: ['*.local'],
}
firebaseConfigInitial.functions = [testFunction]
Expand All @@ -241,7 +241,7 @@ describe('function generator', () => {
expect(firebaseConfig.functions).toContainEqual({
codebase: 'myFirebaseFunction',
source: 'dist/myFirebaseFunction',
runtime: `nodejs18`,
runtime: `nodejs20`,
ignore: ['*.local'],
})
})
Expand Down Expand Up @@ -302,7 +302,7 @@ describe('function generator', () => {
await functionGenerator(tree, {
name: 'myFirebaseFunction',
app: 'myFirebaseApp',
runTime: '18',
runTime: '22',
})
const project = readProjectConfiguration(tree, 'myFirebaseFunction')

Expand All @@ -311,11 +311,11 @@ describe('function generator', () => {
tree,
joinPathFragments(project.root, 'package.json'),
)
expect(packageJson.engines.node).toEqual('18')
expect(packageJson.engines.node).toEqual('22')

// check the function firebase config
const firebaseConfig = readJson(tree, 'firebase.json')
expect(firebaseConfig.functions[0].runtime).toEqual('nodejs18')
expect(firebaseConfig.functions[0].runtime).toEqual('nodejs22')
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/nx-firebase/src/generators/function/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface Schema {

// nx-firebase:function generator specific options
app: string
runTime?: '18' | '20' | '22'
runTime?: '20' | '22' | '24'
format?: 'esm' | 'cjs'
}

Expand Down
4 changes: 2 additions & 2 deletions packages/nx-firebase/src/generators/function/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"runTime": {
"description": "The node runtime target for this function.",
"type": "string",
"enum": ["18", "20", "22"],
"default": "18"
"enum": ["20", "22", "24"],
"default": "20"
}
},
"additionalProperties": false,
Expand Down
5 changes: 2 additions & 3 deletions packages/nx-firebase/src/utils/update-tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { packageVersions } from '../__generated__/nx-firebase-versions'
// https://stackoverflow.com/questions/59787574/typescript-tsconfig-settings-for-node-js-12

export const nodeEsVersion: Record<string, string> = {
'12': 'es2019',
'14': 'es2020',
'16': 'es2020', // es2020 seems more preferred with node 16 than es2021
'18': 'es2022',
'20': 'es2022',
'22': 'es2023',
'24': 'es2024',
}

/**
Expand Down
Loading