Skip to content

kekovina/fastify-static-server

Repository files navigation

Fastify Static Server

Fastify TypeScript RollupJS

Easy to use Node.js server for statics

How to use

Download

  git clone https://github.com/kekovina/fastify-static-server.git

or

  git@github.com:kekovina/fastify-static-server.git

Manually

  1. npm i

  2. Copy .env.example and rename to .env

  3. Set Bearer tokens in .env

  4. npm run start

Docker

  1. 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'

...

API Reference

Upload item

  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 item

  GET /{collection}/{filename}

Get items from collection

  GET /{collection}
  Authorization: Bearer {token}

Get all collections

  GET /collections
  Authorization: Bearer {token}

Drop item

  DELETE /{collection}/{filename}
  Authorization: Bearer {token}

Drop collection

  DELETE /{collection}
  Authorization: Bearer {token}

Roadmap

  • Image optimization
  • Jest tests