FilledStacks / FilledStacks/firebase-backend

Dashes in folder names cause initialization crash

Open
#280 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
61
Forks
14
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
If you name a folder with dashes in it, the dash is converted to a dot (.) by the `FunctionParser` class. This was while testing a reactive function not a restful endpoint.

**To Reproduce**
Bad structure:
Screenshot 2023-04-13 at 1 37 50 PM

Good Structure:
Screenshot 2023-04-13 at 1 36 09 PM

In order to see the difference in the generated `exports`, I modified my `index.ts` file. If you run the firebase emulator and do something to invoke a reactive function, you'll see the difference. Make one function's folder have a dash in the name and another without to compare logs.

```typescript
// index.ts

import * as admin from 'firebase-admin';
import { FunctionParser } from 'firebase-backend';

admin.initializeApp();

const exportsTmp = new FunctionParser({
rootPath: __dirname,
exports: exports,
verbose: true,
}).exports;

console.log('exportsTmp', exportsTmp);

exports = exportsTmp;

const backendVersion = 'v1';
const separator = '_';

for (const key in exports) {
if (Object.prototype.hasOwnProperty.call(exports, key)) {
const newKey = `${backendVersion}${separator}${key}`;
console.log('key', key);
console.log('newKey', newKey);
exports[newKey] = exports[key];
delete exports[key];
}
}

```

**Expected behavior**
Dashes should be converted to camel-case.

**Screenshots**
See above.

**Additional context**
Keep it up @FilledStacks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.