serverless

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package serverless orchestrates serverless deployments across cloud providers.

Index

Constants

View Source
const (
	PlanCreate         = cloudflare.PlanCreate
	PlanUpdate         = cloudflare.PlanUpdate
	PlanNoOp           = cloudflare.PlanNoOp
	PlanImmutableDrift = cloudflare.PlanImmutableDrift
)

PlanAction constants.

Variables

View Source
var DNSProviderRules = map[string]ProviderRules{
	"namecheap": {
		Name:       "Namecheap",
		Icon:       "🧢",
		RootFormat: "@",
		WwwFormat:  "www",
		SSLFormat: func(record dns.ValidationRecord) string {
			if strings.Contains(record.Name, ".www") {
				return record.Name
			}
			return strings.Split(record.Name, ".")[0]
		},
		Warning: "⚠️ CRITICAL: NEVER include your domain name in the Host field! Use only the hash or '@'.",
		ProTip:  "For www SSL records, the Host must include '.www' (e.g., '_5ab8c33b39a.www')",
	},
	"cloudflare": {
		Name:       "Cloudflare",
		Icon:       "☁️",
		RootFormat: "@",
		WwwFormat:  "www",
		SSLFormat: func(record dns.ValidationRecord) string {
			return strings.TrimSuffix(record.Name, ".")
		},
		Warning:      "⚠️ IMPORTANT: Set proxy status to DNS only (gray cloud) for SSL validation records!",
		ProTip:       "After SSL is issued, you can enable the orange cloud (proxied) for better performance.",
		ProxyWarning: "🔴 SSL validation WILL FAIL if the cloud is orange! Keep it gray until certificate is issued.",
	},
	"godaddy": {
		Name:       "GoDaddy",
		Icon:       "🇬",
		RootFormat: "@",
		WwwFormat:  "www",
		SSLFormat: func(record dns.ValidationRecord) string {
			return strings.TrimSuffix(record.Name, ".")
		},
		Warning: "⚠️ Do not include trailing dots in the 'Points to' field.",
		ProTip:  "Use '@' for root domain, leave TTL as 1 hour.",
	},
	"route53": {
		Name:       "Route 53",
		Icon:       "📡",
		RootFormat: "@",
		WwwFormat:  "www",
		SSLFormat: func(record dns.ValidationRecord) string {
			return record.Name
		},
		Warning: "✅ Use Alias records (A type) for better performance!",
		ProTip:  "Route 53 handles validation automatically if domain is hosted here.",
	},
	"other": {
		Name:       "Other Provider",
		Icon:       "🌐",
		RootFormat: "@",
		WwwFormat:  "www",
		SSLFormat: func(record dns.ValidationRecord) string {
			return strings.TrimSuffix(record.Name, ".")
		},
		Warning: "⚠️ Check your provider's documentation for exact field names.",
		ProTip:  "Common field names: Host, Name, Alias, Points to.",
	},
}

DNSProviderRules maps provider names to their specific instructions.

Functions

func BuildWorkerBundle

func BuildWorkerBundle(
	ctx context.Context,
	standaloneDir string,
	meta *nextcore.NextCorePayload,
	cfg *config.NextDeployConfig,
	log *shared.Logger,
) (string, error)

BuildWorkerBundle adapts a Next.js standalone build into a single Cloudflare Worker module bundle.

func CloudflareAssetBucketName added in v0.16.0

func CloudflareAssetBucketName(appName, environment string) string

CloudflareAssetBucketName computes the R2 asset bucket name for an app and environment.

func CloudflareWorkerName added in v0.16.0

func CloudflareWorkerName(appName, environment string) string

CloudflareWorkerName computes the Worker script name for an app and environment.

func Deploy

func Deploy(ctx context.Context, cfg *config.NextDeployConfig, meta *nextcore.NextCorePayload, verbose, provision, verify bool) error

Deploy orchestrates the full serverless deployment pipeline:

  1. Discovers the build artifact (app.tar.gz)
  2. Fetches local secrets via SecretManager and pushes them to the cloud secret store
  3. Uploads static assets to CDN/Storage
  4. Deploys the compute layer (Lambda, Workers, etc.)
  5. Invalidates the CDN cache

func GenerateQuickReference

func GenerateQuickReference(resMap ServerlessResourceMap) string

GenerateQuickReference creates a markdown quick reference.

func GenerateResourceView

func GenerateResourceView(appCfg *config.AppConfig, resMap ServerlessResourceMap) (string, error)

GenerateResourceView creates a premium HTML report of the provisioned resources.

func LoadLocalSecrets

func LoadLocalSecrets(cfg *config.NextDeployConfig) (map[string]string, error)

LoadLocalSecrets is the exported alias for core.LoadLocalSecrets, used by CLI commands outside this package (e.g. `nextdeploy secrets prune`) that need to compute the canonical local secret set.

func Rollback

func Rollback(ctx context.Context, cfg *config.NextDeployConfig, opts RollbackOptions) error

Rollback orchestrates the serverless rollback process. Opts forwards --steps / --to <commit> from the CLI down to the provider implementation.

Types

type AWSProvider

type AWSProvider = aws.AWSProvider

AWS provider types.

func NewAWSProvider

func NewAWSProvider(verbose bool) *AWSProvider

NewAWSProvider creates a new AWS serverless provider.

type CFTailEventDetail added in v0.20.0

type CFTailEventDetail = cloudflare.CFTailEventDetail

Cloudflare provider & plan/tail types.

type CFTailException added in v0.20.0

type CFTailException = cloudflare.CFTailException

Cloudflare provider & plan/tail types.

type CFTailLogEntry added in v0.20.0

type CFTailLogEntry = cloudflare.CFTailLogEntry

Cloudflare provider & plan/tail types.

type CFTailMessage added in v0.20.0

type CFTailMessage = cloudflare.CFTailMessage

Cloudflare provider & plan/tail types.

type CFTailRequest added in v0.20.0

type CFTailRequest = cloudflare.CFTailRequest

Cloudflare provider & plan/tail types.

type CFTailResponse added in v0.20.0

type CFTailResponse = cloudflare.CFTailResponse

Cloudflare provider & plan/tail types.

type CloudflareProvider

type CloudflareProvider = cloudflare.CloudflareProvider

Cloudflare provider & plan/tail types.

func NewCloudflareProvider

func NewCloudflareProvider() *CloudflareProvider

NewCloudflareProvider creates a new Cloudflare serverless provider.

type DeploymentEntry

type DeploymentEntry = aws.DeploymentEntry

AWS provider types.

type ImageOptConfig

type ImageOptConfig = aws.ImageOptConfig

AWS provider types.

type PlanAction

type PlanAction = cloudflare.PlanAction

Cloudflare provider & plan/tail types.

type PlanItem

type PlanItem = cloudflare.PlanItem

Cloudflare provider & plan/tail types.

type PlanResult

type PlanResult = cloudflare.PlanResult

Cloudflare provider & plan/tail types.

type ProbeOutcome

type ProbeOutcome struct {
	URL        string
	StatusCode int
	Duration   time.Duration
	Attempts   int
	Err        string
}

type Provider

type Provider = core.Provider

Core provider contract & shared report types.

func New

func New(providerName string, verbose bool) (Provider, error)

New returns a new serverless provider based on the provider name.

type ProviderRules

type ProviderRules struct {
	Name         string
	Icon         string
	RootFormat   string
	WwwFormat    string
	SSLFormat    func(record dns.ValidationRecord) string
	Warning      string
	ProTip       string
	ProxyWarning string
}

ProviderRules holds DNS provider-specific display instructions.

type RollbackOptions

type RollbackOptions = core.RollbackOptions

Core provider contract & shared report types.

type ServerlessResourceMap

type ServerlessResourceMap = core.ServerlessResourceMap

Core provider contract & shared report types.

type SmokeOpts

type SmokeOpts struct {
	// MaxAttempts per URL. DNS + CF cache propagation can take a few
	// seconds; 3 attempts spaced by Delay covers cold paths.
	MaxAttempts int
	// Delay between attempts for a single URL.
	Delay time.Duration
	// Timeout per individual HTTP request.
	Timeout time.Duration
	// FailOnError makes the smoke check fail the deploy on any non-2xx.
	// Default false (warn-only) — deploys sometimes race with CF caching.
	FailOnError bool
}

SmokeOpts tunes the post-deploy smoke check. Defaults are correct for typical deploys; tighten via the caller when fronting a CI workflow.

type SmokeResult

type SmokeResult struct {
	Probed []ProbeOutcome
	Passed int
	Failed int
}

SmokeResult is the summary a caller logs or surfaces in CI output.

func SmokeVerify

func SmokeVerify(
	ctx context.Context,
	log *shared.Logger,
	cfg *config.NextDeployConfig,
	meta *nextcore.NextCorePayload,
	opts SmokeOpts,
) (*SmokeResult, error)

SmokeVerify probes a set of URLs derived from the app config + route manifest after a deploy completes. It's load-bearing for "did the deploy actually work" — the rest of the pipeline only proves the upload succeeded, not that the Worker responds.

Non-fatal by default. Operators opting into FailOnError make the deploy gate on this check.

type UnmanagedResource added in v0.16.0

type UnmanagedResource = cloudflare.UnmanagedResource

Cloudflare provider & plan/tail types.

Directories

Path Synopsis
Package aws implements the AWS Lambda, S3, and CloudFront serverless provider.
Package aws implements the AWS Lambda, S3, and CloudFront serverless provider.
Package cloudflare implements the Cloudflare Workers and R2 serverless provider.
Package cloudflare implements the Cloudflare Workers and R2 serverless provider.
adapter
Package adapter compiles and bundles Next.js standalone builds for Cloudflare Workers.
Package adapter compiles and bundles Next.js standalone builds for Cloudflare Workers.
cfstate
Package cfstate is the persistent, encrypted record of the Cloudflare resources NextDeploy has provisioned (D1, KV, Hyperdrive, Queues, Vectorize, …) keyed by kind+name → real CF ID.
Package cfstate is the persistent, encrypted record of the Cloudflare resources NextDeploy has provisioned (D1, KV, Hyperdrive, Queues, Vectorize, …) keyed by kind+name → real CF ID.
Package core defines the shared serverless provider contract, types, and local secret loading.
Package core defines the shared serverless provider contract, types, and local secret loading.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL