0.1.16 • Published 4 years ago

@inpassor/firebase-application v0.1.16

Weekly downloads
17
License
MIT
Repository
github
Last release
4 years ago

Firebase application

npm.io npm.io npm.io

This library is a handy wrapper for @inpassor/node-server.

It provides a single function firebaseApplication creating a Firebase Cloud function:

firebaseApplication: (
   getConfig: ServerConfig | Promise<ServerConfig>,
   runtimeOptions?: RuntimeOptions,
) => HttpsFunction

Installation

npm install @inpassor/firebase-application --save

Usage

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</arg|?>',
            component: DemoComponent,
        },
    ],
};

export const firebaseFunction = firebaseApplication(config, {
    timeoutSeconds: 10,
    memory: '128MB',
});

Asynchronous Server config

import { firebaseApplication, ServerConfig } from '@inpassor/firebase-application';

// Some asynchronous get config function
const getConfig = (): Promise<ServerConfig> => {
    const config: ServerConfig = {}; // define your own ServerConfig here
    return Promise.resolve(config);
};

export const firebaseFunction = firebaseApplication(getConfig(), {
    timeoutSeconds: 10,
    memory: '128MB',
});
0.1.16

4 years ago

0.1.15

4 years ago

0.1.13

4 years ago

0.1.14

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago