0.0.7 • Published 3 years ago
nuxt-restream v0.0.7
nuxt-restream
Restream is a module that allows you to create a stream of an audio/video file from the Firebase storage, protected from direct download through the client. Convenient to use if needed provide media files with restricted access such as purchase, subscription and avoid downloading the file directly from the Firebase storage on the client-side
Features
- 🤓 Very easy to use
- 🛡 Direct download protection
- 🔥 Setup for Firebase Admin
- 🟢 Nuxt 3
Quick setup
Install
nuxt-restreamyarn add --dev nuxt-restream # or npm install --save-dev nuxt-restreamAdd it to the
modulessection ofnuxt.config.tsimport { defineNuxtConfig } from 'nuxt' export default defineNuxtConfig({ modules: ['nuxt-restream'] })Basic configuration
restreamsetup for accessing Firebase Get JSON file with credential Admin Firebaseimport { defineNuxtConfig } from 'nuxt' export default defineNuxtConfig({ restream: { credential: './firebase-admin-sdk.json', storage: 'firebase-storage-name.appspot.com' } })Add
srcattribute with a link to server routes/api/restreamwith the?f=parameter containing the path to the file in Firebase storage.<template> <div> <audio src="/api/restream?f=path_to/audio.mp3" typeof="audio/mp3" controls /> </div> </template>Configuration
Restream supports a number of options, which you can pass in your nuxt.config.ts file:
import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({
// ...
restream: {
/**
* Path (relative to your base URL) where the JSON file with Firebase admin credentials.
* @example './assets/fearbook-c8d55-firebase-adminsdk-vbvi5-57b761f13c.json'
* @default undefund
*/
credential: string,
/**
* Firebase storage bucket url
* @example 'fearbook-c8d55.appspot.com'
* @default undefund
*/
storage: string,
/**
* Base route that will be used for restream api
* @example 'restream' -> 'api/restream?f=...'
* @default 'restream'
*/
apiRouteName: string
},
})