Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@podium/layout

Package Overview
Dependencies
Maintainers
4
Versions
252
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@podium/layout - npm Package Compare versions

Comparing version 3.0.0-beta.9 to 3.0.0-beta.10

4

package.json
{
"name": "@podium/layout",
"version": "3.0.0-beta.9",
"version": "3.0.0-beta.10",
"description": "Module for composing full page layouts out of page fragments in a micro frontend architecture.",

@@ -35,3 +35,3 @@ "main": "lib/layout.js",

"@metrics/client": "2.3.1",
"@podium/client": "3.0.0-beta.3",
"@podium/client": "3.0.0-beta.4",
"@podium/context": "3.0.0-beta.6",

@@ -38,0 +38,0 @@ "@podium/proxy": "3.0.0-beta.5",

@@ -18,5 +18,10 @@ # @podium/layout

A Layout can be used together with any connect middleware compatible HTTP framework (eg. Express.js)
and any templating language of your choosing (or none if you prefer).
A Layout can be used together with a plain node.js http server or any http framework and any templating
language of your choosing (or none if you prefer). Though; Connect compatible middleware based frameworks
(such as express.js) is first class in Podium so this module comes with a `.middleware()` method for convenience.
For writing layout servers with other http frameworks the following modules exist:
- [Hapi Layout Plugin](https://github.com/podium-lib/hapi-layout)
## Installation

@@ -30,3 +35,3 @@

Build a simple Layout server with a single podlet using Express js
Build a simple Layout server with a single podlet using Express.js:

@@ -117,3 +122,3 @@ ```js

If the layout is mouned at `/foo`, set pathname to `/foo` and mount middleware and routes at or under `/foo`
If the layout is mouned at `/foo`, set pathname to `/foo`:

@@ -224,14 +229,51 @@ ```js

### .middleware()
### .process(HttpIncoming)
A connect compatible middleware which takes care of multiple operations needed for
a Layout to fully work.
Metod for processing a incomming http request. This method is intended to be used
to implement support for multiple http frameworks and should not really be used
directly in a layout server.
What it does:
- Runs [context parsers](https://github.com/podium-lib/context) on incomming requests and creates an object on the response at `res.locals.podium.context` which can be passed on to the client when requesting content from podlets.
- Mounts the [proxy](https://github.com/podium-lib/proxy) so that each podlet can do transparent proxy requests if needed.
- Runs [context parsers](https://github.com/podium-lib/context) on the incomming request and sets an object with the context at `HttpIncoming.context` which can be passed on to the client when requesting content from podlets.
- Mounts the [proxy](https://github.com/podium-lib/proxy) so each podlet can do transparent proxy requests if needed.
This middleware should be mounted before defining any routes.
Returns a Promise. If the inbound request does match a proxy endpoint the returned Promise will resolve with
`undefined`. If the inbound request does not match a proxy endpoint the returned Promise will resolve with the
passed in `HttpIncoming` object.
The method take the following arguments:
#### HttpIncoming (required)
An instance of a [HttpIncoming object](https://github.com/podium-lib/utils/blob/master/lib/http-incoming.js).
```js
const { HttpIncoming } = require('@podium/utils');
const Layout = require('@podium/layout');
const layout = new Layout({
name: 'myLayout',
pathname: '/',
});
app.use(async (req, res, next) => {
const incoming = new HttpIncoming(req, res, res.locals);
try {
const result = await layout.process(incoming);
if (result) {
res.locals.podium = result;
next();
}
} catch (error) {
next(error);
}
});
```
### .middleware()
A Connect compatible middleware which takes care of the operations needed for
a Layout to fully work. It is more or less a wrapper for the `.process()` method.
Example

@@ -244,2 +286,4 @@

The context generated by the middleware will be stored at `res.locals.podium.context`.
Returns an Array of internal middleware performing the tasks described above.

@@ -246,0 +290,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc