https://github.com/spimy/static.spimy.dev
Personal static image host using express and multer
https://github.com/spimy/static.spimy.dev
Last synced: 10 months ago
JSON representation
Personal static image host using express and multer
- Host: GitHub
- URL: https://github.com/spimy/static.spimy.dev
- Owner: Spimy
- Created: 2023-02-06T20:31:39.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-08T15:53:05.000Z (almost 3 years ago)
- Last Synced: 2024-10-08T20:41:36.555Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 36.1 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# static.spimy.dev
An express server is used to handle file uploading and serving all the files uploaded. Accepts only images.
## Routes
### GET
**Route:** `/`
GET requests is for fetching files from the server so there is no fixed route.
### Responses
**Status:** `404`
```json
{ "message": "You have stumbled across an inexistent path." }
```
**Status:** `200`
It is the link to the file which can be used as the source in the `
` tag.
### POST
**Route:** `/upload`
Post requests should contain a file upload with the field named `file`.
An optional body can be sent along the request:
```json
{ "folder": "screenshots" }
```
I am personally using the screenshots folder for my [ShareX](https://getsharex.com/) uploads.
### Reponses
**Status:** `422`
This means either a file was not provided or the file provided was not an image. The following responses are returned:
**_No file provided_**
```json
{ "message": "A file was not provided in the request." }
```
**_Non-image file provided_**
```json
{ "message": "Only images are allowed." }
```
**Status:** `413`
This means that the file uploaded was larger than the max file size limit allowed. The following response is returned:
```json
{
"message": "The file uploaded was larger than the max size limit of MiB."
}
```
**Status:** `200`
File was successfully uploaded to the server and stored. The following response is returned:
```json
{
"message": "Successfully uploaded ..",
"url": "http://static.spimy.dev/."
}
```
### DELETE
**Route:** `/delete`
Delete a file from the server. The request should contain the following body:
```json
{
"url": "http://static.spimy.dev/."
}
```
## Authorization
For `POST` and `DELETE` requests, the request must contain an `Authorization` header with the value being the same as what's been set in value for `UPLOAD_TOKEN` in the environment variable or `.env` file.
## Environment Variables (.env)
```
PORT=
UPLOAD_TOKEN=
```
The server should automatically redirect the user to HTTPS.