docs: update README with configuration details and API endpoints; modify index.js logging message

This commit is contained in:
Schneider Roland 2025-02-28 09:31:21 +01:00
parent aa5b00f653
commit 3fd60617fb
2 changed files with 72 additions and 2 deletions

View File

@ -1,5 +1,75 @@
# simple http file api
## Configuration
API_KEY: if set, then the client must send the authrization header with the value "Bearer {API_KEY}", otherwise the api returnes 401. If not set, no authentication needed
UPLOAD_PATH: path, where the uploaded files will be stored
CONFIG: config in json format
e.g.
{
"uploadGroups": [
{
"matcher": "^mmkb-android-[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}-int.apk$", "groupSize": 3
}
]
}
uploadGroups: groups of files defined by a regex matcher. For each group can be set a groupSize property. If the file count in the group is more then the groupSize,
then the oldest files in the group will be deleted.
## API
### get all uploaded files
path: /
method: GET
get all uploaded files
### get the sate of the actual upload groups
path: /state
method: GET
Get the state of the actual upload groups
### Cleanup
path: /clean
Execute a cleanup manually.
Cleanup is beased on the uploadGroups configuration
### Get file
path /:filename
method: GET
get the file with the given name
### Delete file
path /:filename
method: DELETE
Delete the file with the given name
### Upload file
path /
method: POST
Upload a file. If file with the given name already exists, http status 409 will be returned.
After a successfull file upload, a cleanup will be performed
### Upload file
path /
method: PUT
Upload a file. If the file with the given name already exists, it will be overwritten
After a successfull file upload, a cleanup will be performed
## Create Docker image

View File

@ -8,7 +8,7 @@ const port = 3000;
const uploadPath = process.env.UPLOAD_PATH || '/tmp';
const config = process.env.CONFIG || "{ \"uploadGroups\": [] }";
//const config = process.env.CONFIG || "{ \"uploadGroups\": [{ \"matcher\": \"^mmkb-android-.*-test\\.apk$\", \"groupSize\": 3},{ \"matcher\": \"^mmkb-android-.*-int\\.apk$\", \"groupSize\": 3},{ \"matcher\": \"^mmkb-android-.*-prod\\.apk$\", \"groupSize\": 3}] }";
console.info("Upload path: ", uploadPath);
console.info("Config: ", config);
@ -184,5 +184,5 @@ app.get('/:filename', (req, res) => {
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
console.log(`Start app listening on port ${port}`);
});