Commit Graph

30 Commits

Author SHA1 Message Date
Andy Baird 27e3be5a2d
feat(server): add delete endpoint (#136)
* Delete endpoint implementation with delete_tokens configuration

* style(server): remove empty line, add dot at end of doc comment

* test(fixtures): add fixture test for file delete

* refactor(config): add delete_tokens to config.toml

* docs(readme): add info on how to delete file from server

* Update README.md

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>

* Update README.md

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>

* refactor(server): use log::error! and return 500

Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>

* test(server): add test_delete_file_without_token_in_config

* refactor(server): use one function to retrieve auth/delete tokens

Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>

* test(config): add test_get_tokens

* test(config): improve test_get_tokens

* feat(config): disallow empty tokens

* feat(server): update the messages for delete endpoint

---------

Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-09-03 17:47:52 +02:00
Orhun Parmaksız a44ae94132
chore(release): prepare for v0.13.0 2023-08-26 23:40:04 +03:00
Ömer Üstün 95379c9f66
feat(server): support handling spaces in filenames (#107)
* feat(server): add url encoding

- Introduced an option to enable encoding for filenames in the returned URL.
- Modified the encoding approach to specifically target whitespaces, replacing them with `%20`.
- Included unit tests to validate this encoding approach.
- Added fixture tests for broader functional verification.
- Removed the `urlencoding` dependency from `Cargo.toml`.

* Refactor code and fixtures for better compliance and consistency

- Fixed errors in the fixture configuration to ensure tests run as expected.
- Reformatted line endings for consistency across the codebase.
- Made necessary adjustments to adhere to Clippy's recommendations.

* Enhance whitespace handling options for filenames

- Implemented a configuration choice for space handling in filenames: encode, replace with underscores or none.
- Added corresponding unit and fixture tests.

* Remove redundant function call

Fixed misplaced line as per @tessus's review feedback, preventing duplicate handling of spaces in filenames.

* Delete test file with spaces.txt

* Refactor filename space handling

- Introduced `SpaceHandling` enum to manage filename spaces.
- Updated server.rs and paste.rs to utilize the new method.
- Added unit tests for the new filename handling method.
- Adjusted fixture tests to reflect these changes.

* Move filename processing into `SpaceHandling` enum

- Relocated filename processing logic to reside within the `SpaceHandling` enum, enhancing encapsulation.
- Updated calls in `server.rs` and `paste.rs` to use the new method structure.
- Adjusted unit tests to align with the refactored function location and call pattern.

* Refactor based on review suggestions

- Incorporated the inline suggestions made by @tessus, removing the unnecessary one-line assignments.
- Ensured the code adheres to Rust guidelines by running clippy and fmt.

* chore(deps): revert changes in Cargo.lock

* chore(config): replace spaces as default

* refactor(config): move SpaceHandling to config module

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-08-26 14:35:13 +02:00
Helmut K. C. Tessarek d2d07ad345
feat(server): improve random_url config handling (#122)
* feat(server): improve random_url config handling

* log deprecation warnings after hot reload of config

* refactor(config): adjust config files

* tests(config): add test for deprecation codepath

* remove unnecessary to_string()

* style: delete empty line

* refactor(server): clean up random_url config handling

* refactor(config): update configs accordingly to deprecated random_url.enabled

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-08-20 20:32:41 +02:00
Andy Baird d0a67751dc
feat(server): add an endpoint for retrieving a list of files (#94)
* Start

* Wip

* Implement path based JSON index

* Remove json_index_path

* Return datetime stamp instead of relative time

* Add file size to list item

* Add auth check when retrieving JSON index

* Make json index path hardcoded

* Test (currently failing)

* Fix test for test_json_list

* Clippy fix

* Revert cargo to original versions with only needed changes

* Add detail about auth guard affecting list route

* Change json_index_path to expose_list

* Remove unneeded linebreak

* Remove unnecessary import

* Remove unnecessary space at end of line

* Move config check after auth check

* Use new auth check syntax, add docs to struct, rename test_json_list to test_list

* Replace chrono usage with uts2ts

* Check list result in test

* Add example to README

* Upgrade serde_json to 1.0.103

* Add linebreak

* Remove unneeded clone

* Remove extra nl

* Update README.md

* Update README.md

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>

* Update README.md

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>

* Remove serde_json

* Set default config to false for expose_list

* Apply suggestions from code review

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>

* Check that option is value in test_list

* Update Cargo.toml

Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>

* Update cargo.lock

* Use expect() to check file name

* Remove underscore from list item struct

* Keep comma after last line

* refactor(server): rename ListItem fields

* test(fixtures): add fixture test for listing files

* test push

* remove file again

* chop off ts from filename and minor refactor

* update README

* docs(readme): fix capitalization

* refactor(server): clean up list implementation

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>
2023-08-07 12:55:13 +02:00
Helmut K. C. Tessarek 0d4808880f
feat(server): support multiple auth tokens (#84)
* feat(server): support multiple auth tokens

Example:

```toml
[server]
auth_tokens = [
  "super_secret_token1",
  "super_secret_token2",
]
```

The previously used `AUTH_TOKEN` environment variable can still be used
and will be evaluated as well.

* fixtures: add all tokens in array to the test

* add deprecation warning for auth_token

* also add deprecation warnings at server startup

* fix formatting

* fixed tests, so that we do not use deprecated config options

* use bash array

* refactor: use separate function

* refactor: check auth tokens

* Update fixtures/test-server-auth-multiple-tokens/test.sh

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>

* refactor: convert functions to methods

* refactor: check function

* refactor: get_tokens method

* style(format): add newline between functions

* refactor(server): print deprecation warnings once

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-07-21 12:28:17 +02:00
Helmut K. C. Tessarek 62bbfef6a3
feat(server): add random suffix mode (#69)
* add random suffix mode

* fix linter issues

* add test case

* fix linter issues

* add comments, remove empty lines and single line declarations

* more test cases

* refactor(config): rename suffix_mode to random_suffix

* refactor(paste): clean up the random suffix logic

* chore(config): add random suffix example to default config

* docs(readme): mention random suffix feature

* test(fixtures): add fixture test for random suffix mode

* random_suffix -> suffix_mode

* fix default extension for .dotfile w/o extension

* fix formatting

* style(format): fix the indentation for random suffix fixture

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-07-01 00:11:16 +02:00
Helmut K. C. Tessarek aa1734b3f8
refactor(config): use a separate section for the landing page (#65)
* add [landing_page] section to config

Migration path:

Old:

```
[server]
landing_page = "Landing page text."
landing_page_file = "index.html"
landing_page_content_type = "text/html; charset=utf-8"
```

New:

```
[landing_page]
text = "Landing page text."
file = "index.html"
content_type = "text/html; charset=utf-8"
```

* fix typo and remove comments

* make the section optional

* make the section optional

* test(server): fix landing page related test failures

* also change html_form.toml

* do not break current config

* refactor(config): deprecate server.landing_page config fields

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-06-23 17:20:24 +02:00
Chris Jones 9d153ad907
feat(server): allow configuring the content type for landing page (#48)
* Allow user configuration of content type

* style(format): apply formatting

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2023-05-28 00:16:46 +02:00
Orhun Parmaksız 29ddef8df0
feat(deploy): deploy on shuttle.rs (#36)
* feat(deploy): deploy on shuttle.rs

* chore(deploy): add automated shuttle deploy workflow

* style(readme): update the formatting in README.md

* chore(deploy): optimize shuttle workflow

* fix(deploy): start the project

* fix(deploy): remove start step

This reverts commit 4f25921aeb.

* chore(deploy): expose the version for the public instance

* docs(lib): update the comment for shuttle entry-point

* chore(deploy): run the shuttle deployment on new tag
2023-05-14 18:03:53 +02:00
Orhun Parmaksız ab5e153a4e
style(config): format the default config 2023-05-14 13:38:34 +03:00
Orhun Parmaksız 4a4301ee72
style(server): make the default landing page fancier 2023-05-14 01:56:57 +03:00
Orhun Parmaksız 607f07b6e1
feat(server): support server-side default expiry time 2023-05-14 01:30:35 +03:00
Orhun Parmaksız 4e45b6a20d
style(config): format the config 2023-05-13 22:50:39 +03:00
Leonidas Spyropoulos a324305a7d
fix(config): don't expose version endpoint in default config (#31)
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>

Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
2022-10-04 16:29:23 +00:00
Leonidas Spyropoulos 5cdbc8da61
feat(server): expose version as endpoint (#29)
Fixes: #27

Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
2022-10-04 09:38:37 +00:00
TheTechRobo 37cb4d3fcb
feat(server): add landing page (#26)
* feat(server): add landing page

Fixes orhun/rustypaste#13

* feat(server): allow using {REPOSITORY} in landing page

* fix(server): Get rid of unused import, add line about expiration

* chore(fmt): cargo fmt

* fix(tests): inject app data for fixing index test

* feat(server): redirect to GitHub repository if landing page is not specified

* test(fixtures): add fixture test for landing page

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2022-10-03 21:27:35 +00:00
PLANTROON a0f076269e
chore(config): do not check for duplicate files by default (#23)
It is an expensive operation to do on slower hardware and can take unreasonable amount of time for bigger files
2022-06-25 02:57:03 +03:00
Orhun Parmaksız dd91c50d50
feat(server): support auto-deletion of expired files (#17)
feat(server): support auto-deletion of expired files (#17)

chore(ci): set the number of test threads to 1

feat(config): allow the real-time update of cleanup routine

docs(readme): update README.md about deleting expired files
2022-03-23 16:13:46 +03:00
Orhun Parmaksız 94516c95bb
feat(config): support setting the timeout for HTTP requests 2022-03-12 00:35:54 +03:00
Orhun Parmaksız 9e5bd112e7
feat(config): support setting the refresh rate for hot-reloading 2022-03-12 00:02:25 +03:00
Orhun Parmaksız c08fd29a45
feat(paste): make duplicate uploads optional (#7) 2021-10-12 19:35:06 +03:00
orhun e7ad855f4d
feat(paste): support blacklisting MIME types 2021-08-09 22:48:51 +03:00
orhun 03348cb38f
feat(paste): support overriding MIME types 2021-08-09 22:28:33 +03:00
orhun f1e85b64b7
style(config): update the field order for random_url 2021-07-27 14:00:50 +03:00
orhun 338802cc9b
refactor(config): create the `random` module for generating URLs 2021-07-26 15:34:23 +03:00
orhun 181c8c602c
refactor(server): use .env for auth token 2021-07-24 14:10:30 +03:00
orhun f67e611781
feat(paste): make pet names configurable 2021-07-24 00:01:16 +03:00
orhun fc425067f7
feat(paste): support using random file names 2021-07-23 23:53:41 +03:00
orhun 1413335519
feat(server): support file upload and serving 2021-07-23 22:52:00 +03:00