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

@irrelon/appworks-server

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@irrelon/appworks-server

AppWorks Component Server

  • 0.0.16
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Irrelon AppWorks Component Server

This project's goal is to allow disparate UI components and layouts of components to be server and client-rendered into host pages. The SDK provides a common shared and namespaced state so that components can react to state changes between components, and an event listener to listen for events from other components.

Quick Start

npm install
npm run dev

Render a Component

http://localhost:3011/api/v1/components/Tabs/1.0.0/bundle?createTargetElement=true&clean=false

Render a Layout of Components

http://localhost:3011/api/v1/layouts/Example1/1.0.0/bundle?createTargetElement=true&clean=false

How it Works

HTML Generation

The system uses ReactDOM to render components to HTML.

JS / Hydration Code Generation

Webpack is used inside the utils/generateBootstrapFile.ts to generate the hydration code for all components / layouts.

CSS

Each component can describe a bundle of assets it requires. CSS is bundled with the HTML as required.

Modifying the API

API is using Express.

There are two key files:

  1. server/routes.ts - This references the implementation of all the routes. Routes are express route functions.
  2. server/common/api.yaml - This file contains the OpenAPI spec. Routes go through the spec in order to function so if you make a change to a route, you must update the spec otherwise it will fail to function correctly.

Next Steps

  • Add support for loading data via getStaticProps (now called "props") when exported from a component file.
  • Add support for page routes using the new app/routes.ts file
  • Support running the server with a routes config so custom applications can use the server properly
  • Define a logic process of functions so we can rationalise the rendering a bit
    • Request for component / layout
      • Check component exists
      • Get component
        • Figure out which query params belong to the component and pass them in as props
        • Check if getServerSideProps exists
          • Call getServerSideProps with the request object (with the query params easily accessible) and expect it to return data async
          • Spread the props returned with the layout's props?
      • Render the component based on the layout and the props we calculated

Notes

Scaffold Generator

I used a generator app to scaffold the project: https://github.com/cdimascio/generator-express-no-stress-typescript

FAQs

Package last updated on 03 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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