How to use the typescript-monads.reader function in typescript-monads

To help you get started, we’ve selected a few typescript-monads 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 patrickmichalina / fusing-angular / src / electron / protocol.ts View on Github external
import { protocol } from 'electron'
import { join, normalize } from 'path'
import { reader } from 'typescript-monads'
import { IElectronConfig } from './config'

export const initInterceptFileProtocol = reader(cfg => {
  const log = cfg.LOGGER.child({ function: 'initInterceptFileProtocol' })
  log.trace('Entered function')

  const PROTOCOL = 'file';

  log.trace('setting interceptFileProtocol')
  protocol.interceptFileProtocol(PROTOCOL, (request, callback) => {
    // strip protocol
    let url = request.url.substr(PROTOCOL.length + 1);

    if (request.url.includes('/assets/') || request.url.includes('index.html')) {
      // build complete path for node require function
      url = join(cfg.PATH_TO_PUBLIC_FOLDER, url);
    }

    // replace backslashes by forward slashes (windows)
github patrickmichalina / fusing-angular / src / server / cluster.ts View on Github external
import { createExpressApplication } from "./app"
import * as throng from 'throng'

const serverListen = () => () => console.info('Angular Universal server listening for requests...')

const createApplicationServer =
  (app: Application) =>
    reader(config =>
      createServer(app).listen(config.PORT, serverListen()))

const spawnServer = (config: IConfig) =>
  createExpressApplication
    .flatMap(createApplicationServer)
    .run(config)

export const spawnServerCluster = reader(config =>
  config.NODE_DEBUG
    ? spawnServer(config)
    : throng(config.CLUSTERED_WORKERS, () => spawnServer(config)))
github patrickmichalina / fusing-angular / src / server / app.ts View on Github external
import 'zone.js/dist/zone-node'
import 'core-js/proposals/reflect-metadata'
import * as express from 'express'
import * as cookies from 'cookie-parser'
import * as compression from 'compression'
import { json, urlencoded } from 'body-parser'
import { ngExpressEngine } from '@nguniversal/express-engine'
import { registerApi } from './api'
import { reader } from 'typescript-monads'
import { IConfig } from './config'
import { resolve } from 'path'
import { AppServerModule } from './angular/server.angular.module'
import { sslRedirect } from './ssl'

export const createExpressApplication = reader(config => {
  const app = express()
  const publicDir = resolve(config.DIST_FOLDER, config.WWW_ROOT)
  const expressStaticGzip = require('express-static-gzip')
  const pino = require('express-pino-logger')

  if (config.HTTP_LOGS_ENABLED) app.use(pino())

  app.use(sslRedirect)
  app.use(urlencoded({ extended: true }))
  app.use(json())
  app.use(cookies())
  app.disable('x-powered-by')
  app.set('view engine', 'html')
  app.set('views', publicDir)
  app.engine('html', ngExpressEngine({ bootstrap: AppServerModule }) as any)

typescript-monads

Write cleaner TypeScript

MIT
Latest version published 10 months ago

Package Health Score

56 / 100
Full package analysis

Popular typescript-monads functions