-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
please see `README.md` TODO: - [ ] Add to docker-compose
- Loading branch information
1 parent
43efcc4
commit 5b52afa
Showing
28 changed files
with
3,394 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Dockerfile | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Use latest slim node | ||
FROM node:current-slim | ||
|
||
# Set the working directory | ||
WORKDIR /www | ||
|
||
# Copy package.json and package-lock.json to the working directory | ||
COPY package*.json ./ | ||
|
||
# Install modules for production | ||
RUN npm install --production | ||
|
||
# Copy entire bundle to the working directory | ||
COPY . . | ||
|
||
# Create a mount point marked as containing externally mounted volumes. | ||
# Prevents the container's size from increasing with the addition of more static media assets. | ||
# Can be overridden by binding a host directory at runtime. | ||
VOLUME /www/media/static | ||
|
||
# Override and expose port 8080 | ||
ENV PORT 8080 | ||
EXPOSE 8080 | ||
|
||
# Start the server | ||
CMD ["npm", "run", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# `media-server` | ||
|
||
A media server that serves static resources. | ||
|
||
## ENV | ||
|
||
- `UPLOAD_USER` | ||
- `UPLOAD_PASSWORD` | ||
- `DISCOGS_API_KEY` | ||
|
||
|
||
## Static Endpoints | ||
|
||
For all static resources, this server will attempt to return a relevant resource, or else if the resource does not exist, it will return a default 'placeholder' resource. This prevents clients from having no resource to display at all; clients can make use of this media server's 'describe' endpoint to learn about what resources are available. | ||
|
||
### `GET` /static/icons/:icon.png | ||
|
||
Returns an icon based on the filename. | ||
|
||
`:icon` can be any icon filename. | ||
|
||
Example: return an icon with filename 'accept.png'. | ||
|
||
```bash | ||
curl --request GET \ | ||
--url http://path_to_server/static/icons/accept.png | ||
``` | ||
|
||
### `GET` /static/resume/:resume.pdf | ||
|
||
Returns a resume based on the filename. | ||
|
||
`:resume` can be any resume filename. | ||
|
||
Example: return a resume with filename 'resume.pdf'. | ||
|
||
```bash | ||
curl --request GET \ | ||
--url http://path_to_server/static/resume/resume.pdf | ||
``` | ||
|
||
|
||
## Describe | ||
|
||
### `GET` /describe | ||
|
||
Returns a JSON representation of the media groups. | ||
|
||
Example: return JSON containing of all groups present. | ||
|
||
```bash | ||
curl --request GET \ | ||
--url http://localhost:8910/describe | ||
``` | ||
|
||
```json | ||
{ | ||
"success": true, | ||
"path": "/static/", | ||
"groups": ["icons", "resume"] | ||
} | ||
``` | ||
|
||
### `GET` /describe/:group | ||
|
||
Returns a JSON representation of all the files current present for a given group. | ||
|
||
`:group` can be any valid group. | ||
|
||
Example: return JSON containing all the media resources for a the exec resource group. | ||
|
||
```bash | ||
curl --request GET \ | ||
--url http://localhost:8910/describe/exec | ||
``` | ||
|
||
```json | ||
{ | ||
"success": true, | ||
"path": "/static/exec/", | ||
"mimeType": "image/jpeg", | ||
"files": [] | ||
} | ||
``` | ||
|
||
## Upload | ||
|
||
Upload and convert media to any of the given static resource group. | ||
|
||
All upload routes are protected by basic HTTP auth. The credentials are defined by ENV variables `UPLOAD_USER` and `UPLOAD_PASSWORD`. | ||
|
||
### `POST` /upload/:group | ||
|
||
POST a resource to a given group, assigning that resource a given filename. | ||
|
||
`:group` can be any valid group. | ||
|
||
```bash | ||
curl --location 'http://path-to-server/upload/resume/' \ | ||
--header 'Authorization: Basic dXNlcjpwYXNz' \ | ||
--form 'resource=@"/C:/Users/ibrah/Downloads/Ibrahim_Abou_Elenein_Resume.pdf"' \ | ||
--form 'filename="aboueleyes-reume-2"' | ||
``` | ||
|
||
```json | ||
{ | ||
"success": true, | ||
"path": "/static/resume/aboueleyes-reume-2.pdf" | ||
} | ||
``` | ||
|
||
A resource at `http://path_to_server/static/resume/aboueleyes-reume-2.pdf` will now be available. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Load env variables. | ||
*/ | ||
require("dotenv").config(); | ||
|
||
/** | ||
* Load the server config constants. | ||
*/ | ||
const config = require("./src/config"); | ||
|
||
/** | ||
* Initiate the app. | ||
*/ | ||
const app = require("./src/app"); | ||
|
||
/** | ||
* Define port, and listen... | ||
*/ | ||
const port = config.PORT; | ||
app.listen(port, () => console.log("listening on port " + port)); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.