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

@nguniversal/socket-engine

Package Overview
Dependencies
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nguniversal/socket-engine

Socket Engine for running Server Angular Apps

  • 13.1.1
  • latest
  • v13-lts
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by166.67%
Maintainers
2
Weekly downloads
 
Created
Source

Angular Universal Socket Engine

Framework and Platform agnostic Angular Universal rendering.

Deprecated

This package has been deprecated. Please use @nguniversal/common instead.

Usage Server

npm install @nguniversal/socket-engine @nguniversal/common --save

const socketEngine = require('@nguniversal/socket-engine');

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main');

socketEngine.startSocketEngine(AppServerModuleNgFactory);

This will the socket engine which internally hosts a TCP Socket server.
The default port is 9090 and host of localhost You may want to leave this as a plain .js file since it is so simple and to make deploying it easier, but it can be easily transpiled from Typescript.

Usage Client

Your client can be whatever language, framework or platform you like.
As long as it can connect to a TCP Socket (which all frameworks can) then you're good to go.

This example will use JS for simplicity

import * as net from 'net';

const client = net.createConnection(9090, 'localhost', () => {
  console.log('connected to SSR server');
});

client.on('data', (data) => {
  const res = JSON.parse(data.toString()) as SocketEngineResponse;
  expect(res.id).toEqual(1);
  expect(res.html).toEqual(template);
  server.close();
  done();
});

const renderOptions = {
  id: 1,
  url: '/path',
  document: '<app-root></app-root>',
} as SocketEngineRenderOptions;
client.write(JSON.stringify(renderOptions));

Keywords

FAQs

Package last updated on 04 May 2022

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