https://github.com/dashpilot/vercel-serverless-backend
Save data to S3 or Github straight from your front-end app using Vercel functions! Authentication via Google Firebase.
https://github.com/dashpilot/vercel-serverless-backend
Last synced: 10 months ago
JSON representation
Save data to S3 or Github straight from your front-end app using Vercel functions! Authentication via Google Firebase.
- Host: GitHub
- URL: https://github.com/dashpilot/vercel-serverless-backend
- Owner: dashpilot
- Created: 2021-01-12T02:34:04.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-02-04T12:03:00.000Z (over 3 years ago)
- Last Synced: 2025-03-04T08:45:19.049Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 43.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Vercel Serverless Backend for S3 or Github
Save data to S3 or Github straight from your front-end app using Vercel functions!
This project provides a unified api to communicate with any S3-compatible storage (e.g. Amazon S3, Digitalocean Spaces, Linode Object Storage, etc) or a Github repo. It currently uses Firebase Auth for authentication but can easily be adapted to your preferred auth system
# How To
1. Clone this repo and deploy to Vercel
2. Set the following environment variables in Vercel:
### For use with S3-compatible storage:
S3_ENDPOINT: the endpoint of your S3-compatible storage (e.g. eu-central-1.linodeobjects.com)\
S3_BUCKET: your bucket\
S3_KEY: your S3 key\
S3_SECRET: your S3 secret
### For use with a Github repo
GH_OWNER: Github username\
GH_REPO: Github repo\
GH_TOKEN: Github token
3. Set the Firebase config in public/js/firebase.js to match your Firebase account
4. Visit index.html to check out the demos
# Api
### Saving Data
To save data from your front-end app, just call:
`setData(service, path, type, content)`
`service`: either 's3' or 'github', depending on which backend storage you want to use\
`path`: path to the file you want to save, e.g. `data.json` or `myimage.jpg`\
`type`: type of data, e.g. `json` or `img`\
`content`: the data
### Fetching data
To fetch data, just call:
`getData(service, path)`
`service`: either 's3' or 'github', depending on which backend storage you want to use\
`path`: path to the file you want to save, e.g. `data.json` or `myimage.jpg`\