Home

Awesome

Test codecov

<!-- TOC --> <!-- TOC -->

Overview

This plugin allow expose local Pocketbase with ngrok

This plugin can be used for development purposes, when you need to expose your local Pocketbase instance to the internet. For example, you can use it to test your Pocketbase app on mobile device.

Requirements

Installation

go get github.com/iamelevich/pocketbase-plugin-ngrok

Example

You can check examples in examples folder

package main

import (
	"context"
	ngrokPlugin "github.com/iamelevich/pocketbase-plugin-ngrok"
	"log"

	"github.com/pocketbase/pocketbase"
)

func main() {
	app := pocketbase.New()

	// Setup ngrok
	ngrokPlugin.MustRegister(app, &ngrokPlugin.Options{
		Ctx:       context.Background(),
		Enabled:   true,
		AuthToken: "YOUR_NGROK_AUTH_TOKEN", // Better to use ENV variable for that
	})

	if err := app.Start(); err != nil {
		log.Fatal(err)
	}
}
<!-- gomarkdoc:embed:start --> <!-- Code generated by gomarkdoc. DO NOT EDIT -->

pocketbase_plugin_ngrok

import "github.com/iamelevich/pocketbase-plugin-ngrok"

Index

type Options

Options defines optional struct to customize the default plugin behavior.

type Options struct {
    // Ctx is a context that will be used to start ngrok tunnel.
    Ctx context.Context

    // Enabled defines if ngrok tunnel should be started.
    Enabled bool

    // AuthToken is your ngrok auth token. You can get it from https://dashboard.ngrok.com/auth
    AuthToken string

    // AfterSetup is a callback function that will be called after ngrok tunnel is started.
    AfterSetup func(url string) error
}

type Plugin

type Plugin struct {
    // contains filtered or unexported fields
}

func MustRegister

func MustRegister(app core.App, options *Options) *Plugin

MustRegister is a helper function that registers plugin and panics if error occurred.

func Register

func Register(app core.App, options *Options) (*Plugin, error)

Register registers plugin.

func (*Plugin) Validate

func (p *Plugin) Validate() error

Validate plugin options. Return error if some option is invalid.

Generated by gomarkdoc

<!-- gomarkdoc:embed:end -->

Contributing

This pocketbase plugin is free and open source project licensed under the MIT License. You are free to do whatever you want with it, even offering it as a paid service.

Process

Development setup

Testing

Linting

Docs update in README