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

@chadfawcett/probot-serverless-now

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chadfawcett/probot-serverless-now - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

5

index.js

@@ -12,6 +12,7 @@ const { createProbot } = require('probot')

module.exports.serverless = (app, options = defaultOptions) => {
module.exports.serverless = (apps, options = defaultOptions) => {
const probot = createProbot(options)
probot.load(app)
apps = [].concat(apps) // Coerce to array
apps.forEach(a => probot.load(a))
return probot.server
}

28

index.test.js

@@ -8,7 +8,29 @@ const nock = require('nock')

const createApp = name => {
const route = `/${name}`
return [
route,
app =>
app.route(route).get('/', (_, res) => res.send(`Hello from ${route}`))
]
}
test('exports regular NodeJS listener usable by servers', () => {
const defaultApp = require('probot/lib/apps/default')
return request(serverless(defaultApp, { githubToken: 'faketoken' }))
.get('/probot')
const [route, app] = createApp('app1')
return request(serverless(app, { githubToken: 'faketoken' }))
.get(route)
.expect(200)
})
test('accepts an array of apps', async () => {
const [route1, app1] = createApp('app1')
const [route2, app2] = createApp('app2')
const bot = serverless([app1, app2], { githubToken: 'faketoken' })
await request(bot)
.get(route1)
.expect(200, `Hello from ${route1}`)
await request(bot)
.get(route2)
.expect(200, `Hello from ${route2}`)
})
The MIT License (MIT)
Copyright (c) 2018 Chad Fawcett
Copyright (c) Chad Fawcett

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "@chadfawcett/probot-serverless-now",
"version": "0.0.1",
"version": "0.1.0",
"description": "A Probot extension to make it easier to run your Probot Apps on Zeit Now v2",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -0,1 +1,4 @@

[![npm Version](https://badgen.net/npm/v/@chadfawcett/probot-serverless-now)](https://npmjs.com/package/@chadfawcett/probot-serverless-now)
[![Build Status](https://semaphoreci.com/api/v1/chadfawcett/probot-serverless-now/branches/master/shields_badge.svg)](https://semaphoreci.com/chadfawcett/probot-serverless-now)
# Zeit Now v2 Extension for Probot

@@ -51,11 +54,51 @@

## Using Routes
Zeit Now [encourages multiple granular
endpoints](https://github.com/zeit/docs/blob/b20b65e0aad632f9a27f82fab9148f51a70c3fd6/pages/docs/v2/deployments/concepts/lambdas.mdx#L111-L121)
instead of one monolithic app, so whenever possible you should separate custom
routing. That being said, there may be cases for wanting to have custom routes
inside of your app using `app.route()`. To enable this, simply change the `src`
path in your `now.json` to have a wildcard ending (`"src": "/*"`).
```json
{
...
"routes": [{ "src": "/*", "dest": "/now.js" }]
}
```
## Multiple Apps
As mentioned in [using routes](#using-routes), monolithic apps are discouraged.
That being said, there may be a use case for running multiple Probot Apps
together (ie logging, stats, etc). For this reason the `serverless` function
also accepts an array of app functions.
```js
var { serverless } = require('@chadfawcett/probot-serverless-now')
const statsApp = require('probot/lib/apps/stats')
const myApp = require('./')
module.exports = serverless([statsApp, myApp])
```
## API
### `serverless(appFn, [options])`
### `serverless(appFn[, options])`
Create a new instance of Probot and load the supplied App.
Create a new instance of Probot and load the supplied App\[s\].
**Options**
#### Parameters
<!-- prettier-ignore-start -->
Name | Type | Required | Description
--- | --- | --- | ---
appFn | function \| array | true | Single or array of of Probot App functions
options | [object](#options) | false | Probot config options
<!-- prettier-ignore-end -->
#### Options
<!-- prettier-ignore-start -->
Name | Type | Default | Description

@@ -116,2 +159,2 @@ --- | --- | --- | ---

[MIT](https://github.com/chadfawcett/probot-serverless-now/blob/master/LICENSE.md) Copyright 2018 Chad Fawcett
[MIT](https://github.com/chadfawcett/probot-serverless-now/blob/master/LICENSE.md) Copyright Chad Fawcett
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