Giter VIP home page Giter VIP logo

expo-up-server's Introduction

expo-up-server

Description

This is a simple server package that allow you to upload Expo Updates to your custom server and cloud storage.

Features

  • Easily upload Expo Updates to your custom server and cloud storage by using expo-up CLI
  • Can plug in to any Node.js server. (Express, Koa, etc.) by using the provided functions. [Tested with Next.js API routes]

Prerequisites

  • Firebase Admin SDK (for now, only Firebase is supported)

Installation

For npm users:

npm install expo-up-server

For yarn users:

yarn add expo-up-server

Usage

See example repository: sample-expo-up-server

For Firebase Storage, you need to initialize the Firebase Admin SDK first.

Source: https://firebase.google.com/docs/admin/setup#initialize_the_sdk_in_non-google_environments

import { initializeApp } from "firebase-admin";

initializeApp({
  credential: applicationDefault(),
  databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
  storageBucket: "<BUCKET_NAME>.appspot.com",
});

export const bucket = getStorage();

Then, setup Expo Up Package:

import { ExpoUp } from "expo-up-server";
import { bucket } from "path/to/firebaseInitialize";

export const expoUp = ExpoUp({
  bucket,
  // customize file names and storage root folder if needed
  // below are the default values
  // rollbackEmbeddedFileName: "rollback_embedded"
  // rollbackFileName: "rollback",
  // storageRootFolder: "_expo_up_storage",
  // authFileName: "AUTH_TOKEN",
});

Use the expoUp functions in your server. For example, in Next.js API routes:

Please this follow this API format for the expo-up CLI to work properly.

  • GET /api/expo-up - Initialize the auth file
  • POST /api/expo-up - Upload and rollback the Expo Updates
  • GET /api/expo-up/manifest - Send the updates to Expo Update Client
// app/api/expo-up/routes.ts
import { expoUp } from "path/to/expoUp";

export async function GET() {
  // This function will initialize the auth file for the first time.
  return expoUp.initializeAuthFile();
}

export async function POST(req: Request) {
  // This function will do the upload and rollback process.
  return expoUp.uploadAndRollback(req);
}
// app/api/expo-up/manifest/routes.ts
export async function GET(req: Request) {
  // This function will send the updates to Expo Update Client
  return expoUp.sendUpdate(req);
}

After that, you can use the expo-up CLI to upload the Expo Updates to your server.

expo-up release --platform [android|ios] --token [your-token]

Learn more about the expo-up CLI here.

Authorization Token

Once you run GET /api/expo-up, it will generate an auth file in cloud storage and return the token.

This file will be used to authorize the expo-up CLI to upload the Expo Updates to your server.

To retrieve the token, you can download the Auth file from your cloud storage.

Authorization Token Rotation

To rotate the authorization token, visit your cloud storage and delete the auth file.

Then, run GET /api/expo-up again to generate a new auth file.

Roadmap

  • Support for Firebase Storage
  • Support for Vercel Serverless Functions
  • Support for AWS S3
  • Unit Tests
  • Authentication using Authentication Providers Like Firebase Auth, Supabase, etc.
  • Add Code Signing Certificates for updates

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

expo-up-server's People

Stargazers

Sebastian Ciobanu avatar Montlouis-Calixte Stéphane avatar Amine Bezzarga avatar Aidar Nugmanoff avatar Glency Tirao avatar Phạm Ngọc Thạch avatar

Watchers

Glency Tirao 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.