Kaynağa Gözat

Remove Serverless example

Because it doesn't work well. and we don't have the resources to make it work well. Community PRs welcome to patch this up! Until then, let's not confuse any more users.

https://github.com/transloadit/uppy/issues/1306#issuecomment-510811306

https://github.com/transloadit/uppy/issues/2149

https://community.transloadit.com/t/websockets-with-companion-and-serverless-on-aws/15233
Kevin van Zonneveld 5 yıl önce
ebeveyn
işleme
71fa8397ad

+ 1 - 0
CHANGELOG.md

@@ -97,6 +97,7 @@ PRs are welcome! Please do open an issue to discuss first if it's a big feature,
 
 ## 1.11
 
+- [x] @uppy/companion: Fix serverless example (@kvz)
 - [ ] plugins: Transformations, cropping, filters for images, study https://github.com/MattKetmo/darkroomjs/, https://github.com/fengyuanchen/cropperjs #151 #53 (@arturi)
 - [x] google-drive: Google Drive - Google Docs https://github.com/transloadit/uppy/issues/1554#issuecomment-554904049 (@ife)
 - [ ] core: add maxTotalFileSize restriction #514 (@arturi)

+ 0 - 20
packages/@uppy/companion/README.md

@@ -77,26 +77,6 @@ directory
 npm start
 ```
 
-### Run as a serverless function
-
-Companion can be deployed as a serverless function to AWS Lambda or other cloud providers through `serverless`. Check [this guide](https://serverless.com/framework/docs/getting-started/) to get started.
-
-After you have cloned the repo go inside `examples/serverless`:
-```
-cd examples/serverless
-```
- 
-You can enter your API Keys inside the `serverless.yml` file:
-```
-INSTAGRAM_KEY: <YOUR_INSTAGRAM_KEY>
-INSTAGRAM_SECRET: <YOUR_INSTAGRAM_SECRET>
-```
-
-When you are all set install the dependencies and deploy your function:
-```
-npm install && sls deploy
-```
-
 ### Deploy to heroku
 
 Companion can also be deployed to [Heroku](https://www.heroku.com)

+ 0 - 66
packages/@uppy/companion/examples/serverless/index.js

@@ -1,66 +0,0 @@
-'use strict'
-
-const express = require('express')
-const bodyParser = require('body-parser')
-const cors = require('cors')
-const session = require('express-session')
-const compression = require('compression')
-const awsServerlessExpress = require('aws-serverless-express')
-const awsServerlessExpressMiddleware = require('aws-serverless-express/middleware')
-const companion = require('@uppy/companion')
-
-const app = express()
-
-app.use(compression())
-app.use(cors())
-app.use(session({
-  secret: process.env.SESSION_SECRET,
-  resave: true,
-  saveUninitialized: true
-}))
-app.use(bodyParser.json())
-app.use(bodyParser.urlencoded({ extended: false }))
-app.use(awsServerlessExpressMiddleware.eventContext())
-
-const host = process.env.DOMAIN.split('://')[1]
-const protocol = process.env.DOMAIN.split('://')[0]
-
-const options = {
-  providerOptions: {
-    s3: {
-      getKey: (req, filename) => filename,
-      bucket: process.env.AWS_S3_BUCKET,
-      region: process.env.AWS_S3_REGION
-    },
-    instagram: {
-      key: process.env.INSTAGRAM_KEY,
-      secret: process.env.INSTAGRAM_SECRET
-    },
-    google: {
-      key: process.env.GOOGLE_KEY,
-      secret: process.env.GOOGLE_SECRET
-    },
-    dropbox: {
-      key: process.env.DROPBOX_KEY,
-      secret: process.env.DROPBOX_SECRET
-    }
-  },
-  server: {
-    host: host,
-    protocol: protocol
-  },
-  filePath: '/tmp',
-  secret: process.env.UPPY_SECRET
-}
-
-app.use(companion.app(options))
-
-app.get('/', (req, res) => {
-  res.setHeader('Content-Type', 'text/plain')
-  res.send("Hello there, here's a response from companion")
-})
-
-const server = awsServerlessExpress.createServer(app)
-
-exports.companion = (event, context) =>
-  awsServerlessExpress.proxy(server, event, context)

+ 0 - 16
packages/@uppy/companion/examples/serverless/package.json

@@ -1,16 +0,0 @@
-{
-  "name": "uploader",
-  "version": "1.0.0",
-  "dependencies": {
-    "@uppy/companion": "^0.17.3",
-    "aws-serverless-express": "^3.3.6",
-    "body-parser": "^1.18.3",
-    "compression": "^1.7.4",
-    "cors": "^2.8.5",
-    "express": "^4.16.4",
-    "express-session": "^1.15.6"
-  },
-  "devDependencies": {
-    "serverless-offline": "^4.9.3"
-  }
-}

+ 0 - 39
packages/@uppy/companion/examples/serverless/serverless.yml

@@ -1,39 +0,0 @@
-service: uppyloader
-
-provider:
-  name: aws
-  runtime: nodejs8.10
-
-  environment:
-    # NOTE: Make sure you set this to the url of your service endpoint
-
-    DOMAIN: <YOUR_SERVICE_ENDPOINT>
-
-    # NOTE: Make sure you set the API Keys for your chosen provider
-
-    AWS_S3_BUCKET: <YOUR_AWS_S3_BUCKET_NAME>
-    AWS_S3_REGION: <YOUR_AWS_S3_BUCKET_REGION>
-
-    SESSION_SECRET: <YOUR_SESSION_SECRET>
-
-    UPPY_SECRET: <YOUR_UPPY_SECRET>
-
-    # INSTAGRAM_KEY: <YOUR_INSTAGRAM_KEY>
-    # INSTAGRAM_SECRET: <YOUR_INSTAGRAM_SECRET>
-
-    # GOOGLE_KEY: <YOUR_GOOGLE_KEY>
-    # GOOGLE_SECRET: <YOUR_GOOGLE_SECRET>
-
-    # DROPBOX_KEY: <YOUR_DROPBOX_KEY>
-    # DROPBOX_SECRET: <YOUR_DROPBOX_SECRET>
-
-functions:
-  companion:
-    handler: index.companion
-
-    events:
-      - http: ANY /
-      - http: 'ANY {proxy+}'
-
-plugins:
-  - serverless-offline