Переглянути джерело

replace uppy-server occurrencies

Ifedapo Olarewaju 6 роки тому
батько
коміт
be040e3218

+ 8 - 8
packages/@uppy/companion/ARCHITECTURE.md

@@ -1,10 +1,10 @@
-Uppy Server is the server side component for Uppy.  It is currently built with the Express.js.
-The purpose of Uppy Server is to interface with third party APIs and handle remote file uploading from them.
+Companion is the server side component for Uppy.  It is currently built with the Express.js.
+The purpose of Companion is to interface with third party APIs and handle remote file uploading from them.
 
 # How it works
 
 ## oAuth with Grant, Sessions
-Uppy Server uses an oAuth middleware library called `Grant` to simplify oAuth authentication.
+Companion uses an oAuth middleware library called `Grant` to simplify oAuth authentication.
 Inside of `config/grant.js`, you configure the oAuth providers you wish to use, providing things like client key, 
 client secret, scopes, and the callback URL you wish to use.  For example:
 
@@ -53,7 +53,7 @@ There are 5 controllers:
 These controllers are generalized to work for any provider.  The provider specific implementation code for each provider can be found under `server/providers`.
 
 ## Adding new providers
-To add a new provider to Uppy Server, you need to do two things: add the provider config to `config/grant.js`, and then create a new file in `server/providers` that describes how to interface with the provider's API.
+To add a new provider to Companion, you need to do two things: add the provider config to `config/grant.js`, and then create a new file in `server/providers` that describes how to interface with the provider's API.
 
 We are using a library called [purest](https://github.com/simov/purest) to make it easier to interface with third party APIs.  Instead of dealing with each and every single provider's client library/SDK, we use Purest, a "generic REST API client library" that gives us a consistent, "generic" API to interface with any provider.  This makes life a lot easier.
 
@@ -64,19 +64,19 @@ Since each API works differently, we need to describe how to `download` and `lis
 This whole approach was inspired by an example from `purest 2.x`.  Keep in mind that we're using `3.x`, so the API is different, but here is the example for reference: https://github.com/simov/purest/tree/2.x/examples/storage
 
 ## WebSockets
-Uppy Server uses WebSockets to transfer `progress` events to the client during file transfers.  It's currently only set up to transfer progress during Tus uploads to the target server.  
+Companion uses WebSockets to transfer `progress` events to the client during file transfers.  It's currently only set up to transfer progress during Tus uploads to the target server.  
 
 When a request is made to `/:provider/get` to start a transfer, a token is generated and sent back to the client in response.  The client then connects to `wss://your-server/whatever-their-token-is`.  Any events that are emitted using the token as the name (i.e. `emitter.emit('whatever-their-token-is', progressData)`) are sent back to the client.
 
 WebSockets aren't particularly secure, but we feel this is safe because the token is only usable during the corresponding file transfer, and no sensitive information is being sent, only a file id and the progress.
 
 # Design Goals
-These are the goals I had in mind while designing and building Uppy Server.
+These are the goals I had in mind while designing and building Companion.
 
 ## Standalone Server / Pluggable Module
-Uppy Server currently works as a standalone server.  It should also work as a module that can easily be incorporated into an already existing server, so people don't have to manage another server just to use Uppy.
+Companion currently works as a standalone server.  It should also work as a module that can easily be incorporated into an already existing server, so people don't have to manage another server just to use Uppy.
 
-One issue here is that `Grant` has different versions for Koa, Express, and Hapi.  We're using `grant-express` right now, and also use all express modules.  This becomes a problem if someone is using Koa, or Hapi, or something else.  I don't think we can make Uppy Server completely framework agnostic, so best case scenario would be to follow Grant and make versions for Koa, Hapi, and Express.
+One issue here is that `Grant` has different versions for Koa, Express, and Hapi.  We're using `grant-express` right now, and also use all express modules.  This becomes a problem if someone is using Koa, or Hapi, or something else.  I don't think we can make Companion completely framework agnostic, so best case scenario would be to follow Grant and make versions for Koa, Hapi, and Express.
 
 All of this may be more trouble than it's worth if no one needs it, so I'd get some community feedback beforehand.
 

+ 18 - 18
packages/@uppy/companion/KUBERNETES.md

@@ -1,6 +1,6 @@
-### Run uppy-server on kuberenetes
+### Run companion on kuberenetes
 
-You can use our docker container to run uppy-server on kubernetes with the following configuration.
+You can use our docker container to run companion on kubernetes with the following configuration.
 ```bash
 kubectl create ns uppy
 ```
@@ -13,7 +13,7 @@ We will need a Redis container that we can get through [helm](https://github.com
     stable/redis
 ```
 
-> uppy-server-env.yml
+> companion-env.yml
 ```yaml
 apiVersion: v1
 data:
@@ -38,17 +38,17 @@ data:
   UPPYSERVER_UPLOAD_URLS: "http://master.tus.io/files/,https://master.tus.io/files/"
 kind: Secret
 metadata:
-  name: uppy-server-env
+  name: companion-env
   namespace: uppy
 type: Opaque
 ```
 
-> uppy-server-deployment.yml
+> companion-deployment.yml
 ```yaml
 apiVersion: extensions/v1beta1
 kind: Deployment
 metadata:
-  name: uppy-server
+  name: companion
   namespace: uppy
 spec:
   replicas: 2
@@ -61,12 +61,12 @@ spec:
   template:
     metadata:
       labels:
-        app: uppy-server
+        app: companion
     spec:
       containers:
-      - image: docker.io/transloadit/uppy-server:latest
+      - image: docker.io/transloadit/companion:latest
         imagePullPolicy: ifNotPresent
-        name: uppy-server        
+        name: companion        
         resources:
           limits:
             memory: 150Mi
@@ -74,26 +74,26 @@ spec:
             memory: 100Mi
         envFrom:
         - secretRef:
-            name: uppy-server-env
+            name: companion-env
         ports:
         - containerPort: 3020
         volumeMounts:
-        - name: uppy-server-data
-          mountPath: /mnt/uppy-server-data
+        - name: companion-data
+          mountPath: /mnt/companion-data
       volumes:
-      - name: uppy-server-data
+      - name: companion-data
         emptyDir: {}
 ```
 
-`kubectl apply -f uppy-server-deployment.yml`
+`kubectl apply -f companion-deployment.yml`
 
-> uppy-server-service.yml
+> companion-service.yml
 
 ```yaml
 apiVersion: v1
 kind: Service
 metadata:
-  name: uppy-server
+  name: companion
   namespace: uppy
 spec:
   ports:
@@ -101,10 +101,10 @@ spec:
     targetPort: 3020
     protocol: TCP
   selector:
-    app: uppy-server
+    app: companion
 ```
 
-`kubectl apply -f uppy-server-service.yml`
+`kubectl apply -f companion-service.yml`
 
 ## Logging
 

+ 9 - 9
packages/@uppy/companion/README.md

@@ -1,10 +1,10 @@
-# uppy-server
+# Companion
 
 <img src="http://uppy.io/images/logos/uppy-dog-full.svg" width="120" alt="Uppy logo — a superman puppy in a pink suit" align="right">
 
-[![Build Status](https://travis-ci.org/transloadit/uppy-server.svg?branch=master)](https://travis-ci.org/transloadit/uppy-server)
+[![Build Status](https://travis-ci.org/transloadit/uppy.svg?branch=master)](https://travis-ci.org/transloadit/uppy)
 
-Uppy-server is a server integration for [Uppy](https://github.com/transloadit/uppy) file uploader.
+Companion is a server integration for [Uppy](https://github.com/transloadit/uppy) file uploader.
 
 It handles the server-to-server communication between your server and file storage providers such as Google Drive, Dropbox,
 Instagram, etc. [See here for full documentation](https://uppy.io/docs/server/)
@@ -12,12 +12,12 @@ Instagram, etc. [See here for full documentation](https://uppy.io/docs/server/)
 ## Install
 
 ```bash
-npm install uppy-server
+npm install @uppy/companion
 ```
 
 ## Usage
 
-Uppy-server may either be used as pluggable express app, which you plug to your already existing server, or it may simply be run as a standalone server:
+companion may either be used as pluggable express app, which you plug to your already existing server, or it may simply be run as a standalone server:
 
 ### Plug to already existing server
 
@@ -26,7 +26,7 @@ Uppy-server may either be used as pluggable express app, which you plug to your
 var express = require('express')
 var bodyParser = require('body-parser')
 var session = require('express-session')
-var uppy = require('uppy-server')
+var uppy = require('@uppy/companion')
 
 var app = express()
 app.use(bodyParser.json())
@@ -62,10 +62,10 @@ uppy.socket(server, options)
 ```
 
 ### Run as standalone server
-Please ensure that the required env variables are set before runnning/using uppy-server as a standalone server. [See](https://uppy.io/docs/server/#Configure-Standalone).
+Please ensure that the required env variables are set before runnning/using companion as a standalone server. [See](https://uppy.io/docs/server/#Configure-Standalone).
 
 ```bash
-$ uppy-server
+$ companion
 ```
 
 If you cloned the repo from gtihub and want to run it as a standalone server, you may also run the following command from within its
@@ -77,7 +77,7 @@ npm start
 
 ### Run as a serverless function
 
-Uppy-server 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.
+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`:
 ```

+ 10 - 10
packages/@uppy/companion/infra/kube/gcloud-deploy.sh

@@ -9,10 +9,10 @@ __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 __kube="${__dir}"
 
 # Store the new image in docker hub
-docker build --quiet -t transloadit/uppy-server:latest -t transloadit/uppy-server:$TRAVIS_COMMIT .;
+docker build --quiet -t transloadit/companion:latest -t transloadit/companion:$TRAVIS_COMMIT .;
 docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
-docker push transloadit/uppy-server:$TRAVIS_COMMIT;
-docker push transloadit/uppy-server:latest;
+docker push transloadit/companion:$TRAVIS_COMMIT;
+docker push transloadit/companion:latest;
 
 echo $CA_CRT | base64 --decode -i > ${HOME}/ca.crt
 
@@ -24,16 +24,16 @@ kubectl config set-credentials travis-uppy --token=$SA_TOKEN
 kubectl config set-context travis --cluster=$CLUSTER_NAME --user=travis-uppy --namespace=uppy
 kubectl config use-context travis
 # Should be already removed. Using it temporarily.
-rm -f "${__kube}/uppy-server/uppy-env.yaml"
-echo $UPPY_ENV | base64 --decode > "${__kube}/uppy-server/uppy-env.yaml"
+rm -f "${__kube}/companion/uppy-env.yaml"
+echo $UPPY_ENV | base64 --decode > "${__kube}/companion/uppy-env.yaml"
 
 kubectl config current-context
 
-kubectl apply -f "${__kube}/uppy-server/uppy-env.yaml"
+kubectl apply -f "${__kube}/companion/uppy-env.yaml"
 sleep 10s # This cost me some precious debugging time.
-kubectl apply -f "${__kube}/uppy-server/uppy-server-kube.yaml"
-kubectl apply -f "${__kube}/uppy-server/uppy-server-redis.yaml"
-kubectl set image statefulset uppy-server --namespace=uppy uppy-server=docker.io/transloadit/uppy-server:$TRAVIS_COMMIT
+kubectl apply -f "${__kube}/companion/companion-kube.yaml"
+kubectl apply -f "${__kube}/companion/companion-redis.yaml"
+kubectl set image statefulset companion --namespace=uppy companion=docker.io/transloadit/companion:$TRAVIS_COMMIT
 sleep 10s
 
 kubectl get pods --namespace=uppy
@@ -42,7 +42,7 @@ kubectl get deployment --namespace=uppy
 
 function cleanup {
     printf "Cleaning up...\n"
-    rm -vf "${__kube}/uppy-server/uppy-env.yaml"
+    rm -vf "${__kube}/companion/uppy-env.yaml"
     printf "Cleaning done."
 }
 

+ 1 - 0
packages/@uppy/companion/src/server/Uploader.js

@@ -400,6 +400,7 @@ class Uploader {
 }
 
 Uploader.FILE_NAME_PREFIX = 'uppy-file'
+// @todo do a proper migration to change this name
 Uploader.STORAGE_PREFIX = 'uppy-server'
 
 module.exports = Uploader

+ 4 - 4
packages/@uppy/companion/src/standalone/helper.js

@@ -178,18 +178,18 @@ exports.buildHelpfulStartupMessage = (uppyOptions) => {
   })
 
   return stripIndent`
-    Welcome to Uppy Server v${version}
+    Welcome to Companion v${version}
     ===================================
 
-    Congratulations on setting up Uppy Server! Thanks for joining our cause, you have taken
+    Congratulations on setting up Companion! Thanks for joining our cause, you have taken
     the first step towards the future of file uploading! We
     hope you are as excited about this as we are!
 
-    While you did an awesome job on getting Uppy Server running, this is just the welcome
+    While you did an awesome job on getting Companion running, this is just the welcome
     message, so let's talk about the places that really matter:
 
     - Be sure to add ${callbackURLs.join(', ')} as your Oauth redirect uris on their corresponding developer interfaces.
-    - The URL ${buildURL('/metrics', true)} is available for  statistics to keep Uppy Server running smoothly
+    - The URL ${buildURL('/metrics', true)} is available for  statistics to keep Companion running smoothly
     - https://github.com/transloadit/uppy/issues - report your bugs here
 
     So quit lollygagging, start uploading and experience the future!

+ 1 - 1
packages/@uppy/companion/src/standalone/start-server.js

@@ -7,5 +7,5 @@ const PORT = process.env.UPPYSERVER_PORT || 3020
 
 uppy.socket(app.listen(PORT))
 
-console.log(`Welcome to Uppy Server! v${version}`)
+console.log(`Welcome to Companion! v${version}`)
 console.log(`Listening on http://0.0.0.0:${PORT}`)