Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ story/ # The stories/blogs while doing this project (AI
cmd/ # Go services (entrypoint only: main.go + wire)
note/ # Note service (nx: note)
authorization/ # Authorization service (nx: authorization)
authorizationseed/ # Authorization seed: Casbin policy matrix (nx: authorizationseed)
authorizationfixtures/ # Authorization dev fixtures: memberships (nx: authorizationfixtures)
billing/ # Billing service, Stripe (nx: billing)
notefixturegen/ # Dev fixture generator (fake notes from Obsidian vault)
billingseed/ # Billing seed: Stripe prices + portal config (nx: billingseed)
billingfixtures/ # Billing dev fixtures (nx: billingfixtures)
internal/ # Internal Go packages (the actual service code)
note/
authorization/
authorizationseed/
authorizationfixtures/
billing/
notefixturegen/
billingseed/
Expand Down
2 changes: 1 addition & 1 deletion cmd/authorization/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions cmd/authorizationfixtures/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NOTOPIA_AUTHORIZATIONFIXTURES_GENERAL_APP_ENV="development"

NOTOPIA_AUTHORIZATIONFIXTURES_LOG_LEVEL=debug
NOTOPIA_AUTHORIZATIONFIXTURES_LOG_PRETTY=true

NOTOPIA_AUTHORIZATIONFIXTURES_DATABASE_URL=postgres://notopiauit:notopiauit@localhost:5439/authorization?sslmode=disable

OTEL_SERVICE_NAME="authorizationfixtures"
1 change: 1 addition & 0 deletions cmd/authorizationfixtures/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
authorizationfixtures
34 changes: 34 additions & 0 deletions cmd/authorizationfixtures/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package main

import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"

"github.com/notopia-uit/notopia/pkg/logging"
)

func main() {
if err := logging.FirstStart("NOTOPIA_AUTHORIZATIONFIXTURES_LOG_LEVEL"); err != nil {
slog.Error("failed to set up logger", slog.Any("error", err))
os.Exit(1)
}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
if err := run(ctx); err != nil {
slog.Error("authorization fixtures failed", slog.Any("error", err))
os.Exit(1)
}
slog.Info("authorization fixtures done")
}

func run(ctx context.Context) error {
fixtures, cleanup, err := InitializeFixtures(ctx)
if err != nil {
return err
}
defer cleanup()
return fixtures.Run(ctx)
}
8 changes: 8 additions & 0 deletions cmd/authorizationfixtures/metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package main

import "github.com/notopia-uit/notopia/pkg/metadata"

const (
ServiceName metadata.ServiceName = "notopia-authorizationfixtures"
ServiceVersion metadata.ServiceVersion = "v0.0.0"
)
56 changes: 56 additions & 0 deletions cmd/authorizationfixtures/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"name": "authorizationfixtures",
"projectType": "application",
"tags": ["type:go"],
"namedInputs": {
"default": [
"goPkgFiles",
"goFiles",
"{workspaceRoot}/internal/authorization/**/*.go",
"{workspaceRoot}/internal/authorizationfixtures/**/*.go"
]
},
"targets": {
"gen:wire": {
"executor": "nx:run-commands",
"outputs": ["{projectRoot}/wire_gen.go"],
"options": {
"command": "wire",
"cwd": "{projectRoot}"
},
"cache": false
},
"gen": {
"dependsOn": ["gen:wire"]
},
"run": {
"executor": "nx:run-commands",
"options": {
"command": "go run ./cmd/authorizationfixtures/",
"cwd": "{workspaceRoot}",
"tty": true
},
"dependsOn": ["gen"],
"continuous": false
},
"build": {
"executor": "nx:run-commands",
"options": {
"command": "go build -o ./cmd/authorizationfixtures/authorizationfixtures ./cmd/authorizationfixtures/",
"cwd": "{workspaceRoot}"
},
"dependsOn": ["gen"]
},
"lint": {
"executor": "nx:run-commands",
"inputs": ["default", "goLint"],
"options": {
"command": "golangci-lint run ./cmd/authorizationfixtures/... ./internal/authorizationfixtures/...",
"cwd": "{workspaceRoot}"
},
"parallelism": false
}
},
"implicitDependencies": ["pkg", "internal/authorization"]
}
20 changes: 20 additions & 0 deletions cmd/authorizationfixtures/wire.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//go:build wireinject

package main

import (
"context"

"github.com/goforj/wire"
"github.com/notopia-uit/notopia/internal/authorizationfixtures"
)

var ProviderSet = wire.NewSet(
authorizationfixtures.ProviderSet,
wire.Value(ServiceName),
wire.Value(ServiceVersion),
)

func InitializeFixtures(ctx context.Context) (*authorizationfixtures.Fixtures, func(), error) {
panic(wire.Build(ProviderSet))
}
97 changes: 97 additions & 0 deletions cmd/authorizationfixtures/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions cmd/authorizationseed/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NOTOPIA_AUTHORIZATIONSEED_GENERAL_APP_ENV="development"

NOTOPIA_AUTHORIZATIONSEED_LOG_LEVEL=debug
NOTOPIA_AUTHORIZATIONSEED_LOG_PRETTY=true

NOTOPIA_AUTHORIZATIONSEED_DATABASE_URL=postgres://notopiauit:notopiauit@localhost:5439/authorization?sslmode=disable

OTEL_SERVICE_NAME="authorizationseed"
1 change: 1 addition & 0 deletions cmd/authorizationseed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
authorizationseed
34 changes: 34 additions & 0 deletions cmd/authorizationseed/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package main

import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"

"github.com/notopia-uit/notopia/pkg/logging"
)

func main() {
if err := logging.FirstStart("NOTOPIA_AUTHORIZATIONSEED_LOG_LEVEL"); err != nil {
slog.Error("failed to set up logger", slog.Any("error", err))
os.Exit(1)
}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
if err := run(ctx); err != nil {
slog.Error("authorization seed failed", slog.Any("error", err))
os.Exit(1)
}
slog.Info("authorization seed done")
}

func run(ctx context.Context) error {
seeder, cleanup, err := InitializeSeeder(ctx)
if err != nil {
return err
}
defer cleanup()
return seeder.Run(ctx)
}
8 changes: 8 additions & 0 deletions cmd/authorizationseed/metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package main

import "github.com/notopia-uit/notopia/pkg/metadata"

const (
ServiceName metadata.ServiceName = "notopia-authorizationseed"
ServiceVersion metadata.ServiceVersion = "v0.0.0"
)
56 changes: 56 additions & 0 deletions cmd/authorizationseed/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"name": "authorizationseed",
"projectType": "application",
"tags": ["type:go"],
"namedInputs": {
"default": [
"goPkgFiles",
"goFiles",
"{workspaceRoot}/internal/authorization/**/*.go",
"{workspaceRoot}/internal/authorizationseed/**/*.go"
]
},
"targets": {
"gen:wire": {
"executor": "nx:run-commands",
"outputs": ["{projectRoot}/wire_gen.go"],
"options": {
"command": "wire",
"cwd": "{projectRoot}"
},
"cache": false
},
"gen": {
"dependsOn": ["gen:wire"]
},
"run": {
"executor": "nx:run-commands",
"options": {
"command": "go run ./cmd/authorizationseed/",
"cwd": "{workspaceRoot}",
"tty": true
},
"dependsOn": ["gen"],
"continuous": false
},
"build": {
"executor": "nx:run-commands",
"options": {
"command": "go build -o ./cmd/authorizationseed/authorizationseed ./cmd/authorizationseed/",
"cwd": "{workspaceRoot}"
},
"dependsOn": ["gen"]
},
"lint": {
"executor": "nx:run-commands",
"inputs": ["default", "goLint"],
"options": {
"command": "golangci-lint run ./cmd/authorizationseed/... ./internal/authorizationseed/...",
"cwd": "{workspaceRoot}"
},
"parallelism": false
}
},
"implicitDependencies": ["pkg", "internal/authorization"]
}
20 changes: 20 additions & 0 deletions cmd/authorizationseed/wire.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//go:build wireinject

package main

import (
"context"

"github.com/goforj/wire"
"github.com/notopia-uit/notopia/internal/authorizationseed"
)

var ProviderSet = wire.NewSet(
authorizationseed.ProviderSet,
wire.Value(ServiceName),
wire.Value(ServiceVersion),
)

func InitializeSeeder(ctx context.Context) (*authorizationseed.Seeder, func(), error) {
panic(wire.Build(ProviderSet))
}
Loading
Loading