How to use serverful - 3 common examples

To help you get started, we’ve selected a few serverful 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 hfreire / browser-as-a-service / test / routes / open.js View on Github external
beforeEach(() => {
    const { Route } = require('serverful')
    jest.mock('serverful')
    Route.BASE_PATH = '/'

    Browser = require('../../src/browser')
    jest.mock('../../src/browser')
  })
github hfreire / watch-rtp-play / test / routes / playlist.js View on Github external
beforeEach(() => {
    const { Route } = require('serverful')
    jest.mock('serverful')
    Route.BASE_PATH = '/'

    Request = require('../../src/rtp-play-request')
    jest.mock('../../src/rtp-play-request')

    jest.mock('modern-logger')
  })
github hfreire / watch-rtp-play / src / routes / playlist.js View on Github external
async handler ({ query, headers, server, info }, h) {
    const { channel, proxy = false } = query

    if (!channels[ channel ]) {
      throw Boom.badRequest(`Invalid channel ${channel}`)
    }

    const host = _.get(headers, 'x-forwarded-host', info.host)
    const proto = _.get(headers, 'cloudfront-forwarded-proto', _.get(headers, 'x-forwarded-proto', server.info.protocol))

    const baseUrl = `${proto}://${host}${Route.BASE_PATH === '/' ? '' : Route.BASE_PATH}`
    let url
    if (channels[ channel ].is_tv) {
      url = `https://streaming-live.rtp.pt/liverepeater/smil:${channel}.smil/playlist.m3u`
    } else {
      url = `http://streaming-live.rtp.pt/liveradio/${channels[ channel ].name}/playlist.m3u8?DVR`
    }

    const _headers = { 'Referer': `http://www.rtp.pt/play/direto/${channel}` }

    const options = { url, headers: _headers, tor: proxy }

    let { body } = await Request.get(options)

    if (channels[ channel ].is_tv) {
      body = body.replace(/chunklist_b(\d+)_slpt.m3u8/g, `${baseUrl}/chunklist.m3u8?channel=${channel}&bandwidth=$1&proxy=${proxy}`)
    } else {

serverful

A kickass web server with all the bells and whistles

MIT
Latest version published 3 years ago

Package Health Score

39 / 100
Full package analysis

Popular serverful functions