Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/loockeeer/download-server
Download Server is a node.js app for deploying content and making your clients able to only download the files that changed. It is very useful when you need a fast and reliable deployment.
https://github.com/loockeeer/download-server
Last synced: 12 days ago
JSON representation
Download Server is a node.js app for deploying content and making your clients able to only download the files that changed. It is very useful when you need a fast and reliable deployment.
- Host: GitHub
- URL: https://github.com/loockeeer/download-server
- Owner: loockeeer
- Created: 2020-12-03T18:22:11.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-17T19:09:24.000Z (over 3 years ago)
- Last Synced: 2024-10-11T03:21:54.776Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 79.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Download Server
This is a download server, allowing you to deploy files and updates without having to download all the files.
It uses a hash of the tree to be deployed, which is compared with the client's hash before sending back the different files that have changed.
## Start
You can start it with `npm run start`
You can also specify `PORT` (number), `HOST` (string) and env. variables if you want to configure what they correspond to
Also, specify the `NODE_ENV=dev|production` env. variable depending on whether you are in production or development.
## Where to put files
You just need to put them into a `public` folder at the root of the app## How does it work ?
You can check [this file](https://github.com/loockeeer/download-server/blob/master/test/index.js) if you want to see how you could implement a client for it.
Also, a client is ready [here](https://github.com/loockeeer/download-client-go)
First, you need to compute the hash of every file on the client side.
Then, put them into an array like that :
```js
const files = [
{
relativePath: "src/index.js",
hash: "2988785785"
}
]
```
Note: the hash is a sha1 hash of the fileAfter that you can send it to the API at route `/compare` in a POST request. The body part is a json like that:
```json
{
"files": ["YOUR FILES"]
}
```The server will send you an Array like the one you sent, but with the files you need to download, and a field "op" with either "download" or "remove".
To download a file, just make a GET request at `/download/PATH` where `PATH` is the `relativePath` you received for the file you are downloading. Finally, if you want, you can compute the hash of the files you received and compare to the ones the server sent.