How to use @nguniversal/socket-engine - 4 common examples

To help you get started, we’ve selected a few @nguniversal/socket-engine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / universal / modules / socket-engine / spec / index.spec.ts View on Github external
it('should return an error if it cant render', async (done) => {
    const server = await startSocketEngine(ErrorServerModuleNgFactory);

    const client = net.createConnection(9090, 'localhost', () => {
      const renderOptions = {id: 1, url: '/path',
                             document: ''} as SocketEngineRenderOptions;
      client.write(JSON.stringify(renderOptions));
    });

    client.on('data', (data: Buffer) => {
      const res = JSON.parse(data.toString()) as SocketEngineResponse;
      server.close();
      expect(res.error).not.toBeNull();
      done();
    });
  });
github angular / universal / modules / socket-engine / spec / index.spec.ts View on Github external
it('should be able to inject some token', async (done) => {
    const someValue = {message: 'value' + new Date()};
    const server =
      await startSocketEngine(
        TokenServerModuleNgFactory, [{provide: SOME_TOKEN, useValue: someValue}]);

    const client = net.createConnection(9090, 'localhost', () => {
      const renderOptions = {id: 1, url: '/path',
                             document: ''} as SocketEngineRenderOptions;
      client.write(JSON.stringify(renderOptions));
    });

    client.on('data', (data: Buffer) => {
      const res = JSON.parse(data.toString()) as SocketEngineResponse;
      server.close();
      expect(res.html).toContain(someValue.message);
      done();
    });
  });
});
github swaechter / angularj-universal / angularj-universal-application / src / main / angular / server.ts View on Github external
require('zone.js/dist/zone-node');

const socketEngine = require('@nguniversal/socket-engine');
const {AppServerModuleNgFactory} = require('./dist/angular-server/main');

const port: Number = parseInt(process.env.NODEPORT) || 9090;

console.log('Going to start the server on port: ' + port);
socketEngine.startSocketEngine(AppServerModuleNgFactory, [], 'localhost', port);
github angular / universal / modules / socket-engine / spec / index.spec.ts View on Github external
return new Promise(async(resolve, _reject) => {

    const server = await startSocketEngine(MockServerModuleNgFactory);

    const client = net.createConnection(9090, 'localhost', () => {
      client.write(JSON.stringify(renderOptions));
    });

    client.on('data', (data: Buffer) => {
      const res = JSON.parse(data.toString()) as SocketEngineResponse;
      server.close();
      resolve(res);
    });
  });
}

@nguniversal/socket-engine

Socket Engine for running Server Angular Apps

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis

Popular @nguniversal/socket-engine functions