@fronrich/perspective
v1.0.6
Published
An Elysia plugin that allows Elysia servers to host multiple static, client-side applications.
Maintainers
Readme
Perspective
An Elysia plugin that allows Elysia servers to host multiple static, client-side web applications.
Table of Contents
Why Perspective
Made For Monorepo Ecosystems
Perspective is specifically designed for software ecosystems where data is shared internally across applications. For example, Perspective makes it easy to create a suite of apps with a common user pool, or a suite of online storefronts with a common backend.
Framework Agnostic
Use any frontend web framework you'd like to build out your applications. As long as they build statically, Perspective can host them. This allows development teams to tailor frameworks to apps, as opposed to tailoring apps to frameworks.
Installation
This package is an Elyisa plugin, and therefore requires both Elysia and the Bun runtime. Follow installation instructions for those packages using the provided links. Then, add perspective to your repo using the following command:
bun add @fronrich/perspectiveUsage
import { Elysia } from "elysia";
import { usePerspectives } from "@fronrich/perspective"
// mount perspectives to the entry file
const { perspective } = usePerspectives(__dirname);
new Elysia()
.use(perspective({
// http://localhost:3000/<base>
base: '/journal'
staticClientDir: 'views/journal'
}))
.use(perspective({
base: '/store'
staticClientDir: 'views/store'
}))
// the rest of your server ..
.listen(3000, () => {
console.log(`Server is running on http://localhost:3000`);
});
