Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inpassor/ts-firebase-application
Firebase application
https://github.com/inpassor/ts-firebase-application
application firebase node
Last synced: 7 days ago
JSON representation
Firebase application
- Host: GitHub
- URL: https://github.com/inpassor/ts-firebase-application
- Owner: Inpassor
- License: mit
- Created: 2020-02-01T11:28:10.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T12:10:53.000Z (about 2 years ago)
- Last Synced: 2024-12-15T19:48:28.720Z (about 1 month ago)
- Topics: application, firebase, node
- Language: TypeScript
- Homepage:
- Size: 277 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Firebase application
[![](https://img.shields.io/npm/v/@inpassor/firebase-application.svg?style=flat)](https://www.npmjs.com/package/@inpassor/firebase-application)
[![](https://img.shields.io/github/license/Inpassor/ts-firebase-application.svg?style=flat-square)](https://github.com/Inpassor/ts-firebase-application/blob/master/LICENSE)
![](https://img.shields.io/npm/dt/@inpassor/firebase-application.svg?style=flat-square)This library is a handy wrapper for [@inpassor/node-server](https://github.com/Inpassor/ts-node-server).
It provides a single function **firebaseApplication** creating a Firebase Cloud function:
```
firebaseApplication: (
getConfig: ServerConfig | Promise,
runtimeOptions?: RuntimeOptions,
) => HttpsFunction
```## Installation
```bash
npm install @inpassor/firebase-application --save
```## Usage
```typescript
import { firebaseApplication, Component, ServerConfig } from '@inpassor/firebase-application';class DemoComponent extends Component {
public get(): void {
console.log(this.request.params);
// You can use here:
// this.app.firebaseApp
// this.app.firestore
this.send(200, 'This is the DemoComponent GET action');
}
}const config: ServerConfig = {
headers: {
'Access-Control-Allow-Methods': 'OPTIONS, GET',
'Access-Control-Allow-Credentials': 'true',
'Access-Control-Allow-Headers': 'content-type, authorization',
},
sameOrigin: true,
routes: [
{
path: 'demo',
component: DemoComponent,
},
],
};export const firebaseFunction = firebaseApplication(config, {
timeoutSeconds: 10,
memory: '128MB',
});
```## Asynchronous Server config
```typescript
import { firebaseApplication, ServerConfig } from '@inpassor/firebase-application';// Some asynchronous get config function
const getConfig = (): Promise => {
const config: ServerConfig = {}; // define your own ServerConfig here
return Promise.resolve(config);
};export const firebaseFunction = firebaseApplication(getConfig(), {
timeoutSeconds: 10,
memory: '128MB',
});
```