Giter Club home page Giter Club logo

apollo-federation-file-upload's Introduction

Apollo federation file upload

This library makes it easier to support file uploads to your federated micro-services. It uses the Apollo server's solution. It works by simple redirecting the file uploaded stream to the micro-service. This package do not use third-party services to send the package to your micro-services.

Using HTTP Transfer-Encoding: chunked

By default the FileUploadDataSource will use chunked transfers and we advice that you do not change this setup. However, for some reason you can't support this kind of transfer one can provide the useChunkedTransfer option to the FileUploadDataSource constructor as false to do not use chunked transfer (See the example below on how to set this property). Be advised once again, that this can lead to DDOS attacks.

Example

On your Gateway you must add the FileUploadDataSource in order to the micro-service be able to receive the uploaded file(s).

import { ApolloServer } from 'apollo-server';
import { ApolloGateway } from '@apollo/gateway';
import FileUploadDataSource from '@profusion/apollo-federation-upload';

const runServer = async () => {
  const server = new ApolloServer({
    gateway: new ApolloGateway({
      // Add this line in order to support file uploads.
      buildService: ({ url }) => new FileUploadDataSource({ url, useChunkedTransfer: true }),
      serviceList: [
        /* The services ... */
      ],
    }),
    subscriptions: false,
  });

  const { url } = await server.listen();

  console.log(`๐Ÿš€  Server ready at ${url}`);
};

runServer().catch(error => {
  console.error('๐Ÿ’ฅ  Failed to start server:', error);
  process.exit(1);
});

apollo-federation-file-upload's People

Contributors

barbieri avatar cabelitos avatar dependabot[bot] avatar mrjamesjcho avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.