import fs from 'fs'
import { ServiceCore } from 'service-core'
import * as index from './index.mjs'

const port = 4040

var core = new ServiceCore('storage-upload', import.meta.url, port, '')

let config = {
  "sites": {
    "development": {
      "keys": {
        "default@HS256": "asdf1234"
      }
    },
    "existing": {
      "public": true,
      "keys": {
        "default@HS256": "asdf1234"
      }
    }
  }
}

try {
  config = JSON.parse(fs.readFileSync('./config.json'))
} catch {}

config.port = port

core.setConfig(config)
core.init(index).then(function() {
  return core.run()
})
