Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as admin from 'firebase-admin';
import { storage } from 'firebase-functions';
import { ObjectMetadata } from 'firebase-functions/lib/providers/storage';
import { Runnable, TriggerAnnotated } from 'firebase-functions/lib/cloud-functions';
import { UploadType } from './upload-type';
export const bucketChange = storage.object().onFinalize((data, context) => {
if (
!data ||
parseInt(data.metageneration, 10) > 1 ||
!data.metadata ||
data.metadata['type'] !== UploadType.ExecutionOutput
) {
return Promise.resolve(true);
}
const { execution_id, user_id, name } = data.metadata;
const id = admin
.database()
.ref()
.push().key;