Easy to use Node.js server for statics
git clone https://github.com/kekovina/fastify-static-server.git
or
git@github.com:kekovina/fastify-static-server.git
-
npm i
-
Copy
.env.example
and rename to.env
-
Set
Bearer tokens
in.env
-
npm run start
- Add
docker-compose.yml
...
static-server:
container_name: static-server
restart: always
build:
context: '.'
ports:
- 8081:3000
environment:
- BEARER_TOKENS=${BEARER_TOKENS}
volumes:
- '${path-to}:/static-data/static'
...
POST /{collection}
Content-Type: multipart/form-data
Authorization: Bearer {token}
Files field name will be set as filename on server
If collection doesn`t exists, it will be created.
Available mime types:
Type |
---|
image/png |
image/jpeg |
image/gif |
image/webp |
image/svg+xml |
GET /{collection}/{filename}
GET /{collection}
Authorization: Bearer {token}
GET /collections
Authorization: Bearer {token}
DELETE /{collection}/{filename}
Authorization: Bearer {token}
DELETE /{collection}
Authorization: Bearer {token}
- Image optimization
- Jest tests