Plugin based service and ui

What would be the current recommendation/template to package api and ui within a servicestack plugin?

Is sharp apps the way to go and is there a particular template that showcases this well?

ServiceStack can’t rely on SharpPagesFeature being enabled so plugins that contain UIs like AdminFeature.cs, OpenApiFeature.cs, SvgFeature.cs just use static HTML with embedded resources & custom handlers that rewrites the static html if necessary.

The ServiceStack/Admin is the plugin containing the most UI which is a React SPA App compiled with Webpack.

But #Script would likely be easiest which should just involve registering a class in the base assembly namespace as the embedded resources:

Where it would be registered in the list of VirtualFileSources where it’s *.html files are then accessible by the registered SharpPagesFeature plugin.

Using mix .cs + .html

Note an alternative to shipping a UI in a plugin, is to capture it in a gist so they can mix it in as done with the example-validation, feature-mq and feature-authrepo which mixes in code + #Script UI, the benefit with this approach is that they’re able to easily customize the UI that’s added to their host project.

If you’re interested in this approach, the original sources + scripts to publish to a gist is maintained in the ServiceStack/mix project at:

Which use a script like to publish to a gist, which effectively just populates a dictionary with all the files you want to publish and uses vfsGist.writeTextFiles with your GitHub Token to overwrite the files in the existing gist with it.

var gistId = ...

var textFiles = {}

var fs = vfsFileSystem(`features/${id}`)
#each file in fs.allFiles()
    var key = file.VirtualPath.replace('/','\\')
    key = optional.contains(key) ? `${key}?` : key
    textFiles.putItem(key, file.textContents()) |> end

`Writing to ${textFiles.count()} files to ${id} ${gistId} ...`
var gist = vfsGist(gistId, 'GISTLYN_TOKEN'.envVariable())
1 Like

Great summary, thanks @mythz :+1:

1 Like