Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# misc
.DS_Store
*.pem
.turbo

# debug
npm-debug.log*
Expand All @@ -30,6 +31,11 @@ yarn-error.log*
.env.test.local
.env.production.local

# config files
micro.yaml
micro
!example/*

*.tsbuildinfo
dist
/.microrc
Expand All @@ -42,4 +48,4 @@ dist

packages/web/.next
packages/api/data
packages/*/.turbo
packages/*/.turbo
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ A vanity file sharing service with support for ShareX. You can see a preview at

## development

You can pull the repo and then `pnpm install`, after that everything should be good to go. You can start the `packages/api`/`packages/web` with `pnpm watch`.
1. Pull the repo and then `pnpm install`.
2. Run `docker compose up -d` to start postgres and minio development instances.
3. Copy `micro.example.yaml` to `micro.yaml`, change any options relevant to your environment.
5. Then, you can start the `packages/api`/`packages/web` with `pnpm watch`. Keep a look out for a `InviteService` log entry, which will direct you to an invite to then create the initial account.

## todo

Expand Down
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
container_name: micro_postgres
restart: unless-stopped
ports:
- 127.0.0.1:5433:5432
- 127.0.0.1:5432:5432
environment:
- POSTGRES_USER=micro
- POSTGRES_PASSWORD=youshallnotpass
Expand Down
3 changes: 3 additions & 0 deletions example/micro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ inquiries: admin@example.com
# where to store files, can be relative to the cwd or absolute.
storagePath: /data

# string formatted maximum file upload size.
uploadLimit: 10MB

# whether files uploaded to one domain should be available on other domains.
# you should leave this enabled as it stops users uploading to {{username}}
# domains as other users, for example user "one" could upload to one.example.com
Expand Down
111 changes: 111 additions & 0 deletions micro.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# you can pass in most config options through environment variables,
# for example `MICRO_DATABASE_URL` will override the databaseUrl in this config file.
# remove the .yaml extension or change it to .json to use JSON-with-comments
# ref: https://github.com/sylv/venera#sources

databaseUrl: postgresql://micro:youshallnotpass@127.0.0.1/micro

# EXTREMELY IMPORTANT
# this is the secret used to sign json web tokens. this *must* be a secure, random string that no one else has.
# if you dont change this, any user will be able to act as any other user by creating a token for someone else.
# 32+ characters is recommended.
secret: YOU_SHALL_NOT_PASS

# the email that will show on the home page. in the future the home page will be customisable,
# until then change this to your own email.
inquiries: admin@example.com

# where to store files, can be relative to the cwd or absolute.
storagePath: data

# string formatted maximum file upload size.
uploadLimit: 10MB

# whether files uploaded to one domain should be available on other domains.
# you should leave this enabled as it stops users uploading to {{username}}
# domains as other users, for example user "one" could upload to one.example.com
# then replace "one" with "two" and it would look like user "two" uploaded it.
restrictFilesToHost: true

# # purging can be used to clean up old files, useful if you want to allow large files to be uploaded
# # but dont want to store them forever. this is commented by default to prevent accidental purging
# # uncomment the section below to enable it.
# purge:
# overLimit: 1MB # files over this size will be purged
# afterTime: 1d # after this many days
# underViews: 5 # only delete files with <5 views

# # allowTypes is a list of file types that can be uploaded.
# # a prefix will be expanded into known types, so `video` becomes `video/mp4`, `video/webm`, etc.
# # omit entirely to allow all types to be uploaded.
# allowTypes:
# - video
# - image
# - image/png

hosts:
# the first host in the list is the default host
- url: http://127.0.0.1

# {{username}} will become the users name when they use this host
# - url: https://{{username}}.example.com

# - url: https://i.example.net
# redirect when users go to this hosts url without a file
# redirect: https://example.net
# only allow users with the "admin" tag to use this host
# tags: ["admin"]





# # To allow and require users to sign up with an email, specify an SMTP server to send emails from.
# # If you do not specify an email, it will not be asked for during signup and users will sign in with their username.
# # Enabling this on an existing instance will prompt users without an email to add one (https://micro.sylo.digital/i/J1Ilba)
# email:
# from: 'noreply@example.net'
# smtp:
# host: smtp.example.net
# port: 465
# secure: true
# auth:
# user: 'username'
# pass: 'password'





# Conversions allow you to convert files to other formats on upload.
# This is intended for converting inefficient formats like gif to webm (40mb>4mb in testing).
# The original copy will be discarded.

# Video conversions rely on ffmpeg which is a slow and flakey process. If possible,
# it's recommended to disable conversions and just don't upload gifs.

# The recommended options are below, on low power devices like a raspberry pi you should disable conversions entirely.
# This is currently not retroactive, but in the future old files may also be converted.
conversions:
# You cannot convert video/* to image/* and vice versa. How would that even work?
# image/gif to video/webm is an exception.
- from: image/gif # This could also be a list of types, just a category like "image", or both.
to: video/webm
minSize: 1MB # Required size before conversion, files uploaded under this limit are ignored

# # externalStorage lets you offload files to S3 to free up space locally.
# # you should prefer local storage over external storage, as external storage is usually very slow.
# # the benefit is that external storage is unlimited, local disk space is not.
# externalStorage:
# type: s3
# bucket: my-bucket
# region: us-west-1
# endpoint: s3.us-west-1.amazonaws.com # optional
# forcePathStyle: false # optional
# credentials:
# accessKeyId: my-access-key
# secretAccessKey: my-secret-key
# filter:
# decayDuration: 7d # how long before files are moved to external storage
# minSize: 1MB # files under this size will not be moved
# maxSize: 1GB # files over this size will be moved
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "tsc --noEmit && tsup",
"start": "node dist/main.js",
"test": "vitest run",
"watch": "tsup --watch --onSuccess \"node dist/main.js\"",
"watch": "NODE_ENV=development tsup --watch --onSuccess \"node dist/main.js\"",
"mikro-orm": "tsup --no-dts --silent && MIKRO_ORM_MIGRATIONS_PATH=src/migrations mikro-orm"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ if (rootHost.isWildcard) {
}

const disallowed = new Set(["youshallnotpass", "you_shall_not_pass", "secret", "test"]);
if (disallowed.has(config.secret.toLowerCase())) {
if (process.env.NODE_ENV !== "development" && disallowed.has(config.secret.toLowerCase())) {
const token = randomBytes(24).toString("hex");
throw new Error(
dedent`
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/pages/upload/+Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const Page: FC = () => {
<Container center>
<Card className="flex flex-col items-center justify-center w-full h-2/4">
<h1 className="mb-4 text-2xl">{file.name}</h1>
<div className="flex items-center justify-center">
<div className="flex items-center justify-center gap-4">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't mean to add this, but this just adds a small gap between the file and Upload button on the upload page (previously tied at the hip)

<Select
prefix="Host"
className="shrink-0 w-40 mr-2"
Expand Down