Commit Graph

12 Commits (197950c3b2cb164807072ae018b5dacdf864ff08)

Author SHA1 Message Date
Aravinth Manivannan 197950c3b2
feat: accommodate binary file content
SUMMARY
    Binary content is essential to store images. ContentType enum
    accommodates both utf-8 and and non utf-8 encodings.

    Data::write_file and Data::read_file are modified to handle
    ContentType enum
2022-02-16 20:23:04 +05:30
Aravinth Manivannan 7cdfcc47bb
feat: HTTP JSON endpoint to create new gist 2022-02-15 23:48:05 +05:30
Aravinth Manivannan 82acb06eac
feat: Data::write_file accepts gist ID/gist repository & test cleanup 2022-02-15 23:46:31 +05:30
Aravinth Manivannan 18865552e1
feat: Data::write_file and Data::read_file to save and read gists
SUMMARY
    Data::write_file
	Creates a new files and commits them to "master" branch on the
	bare repository allocated for the gist. If multiple files are
	supplied, all files are written and committed in a single
	commit.

	Currently, empty commit message is used but this should probably
	be changed.

	If filename includes spaces it is escaped. Example "foo bar".txt
	is escaped and converted into "foo\ bar".txt.

    Data::read_file
	Reads files already committed to the repository allocated for
	the gist. This method expects filenames provided to be already
	escaped. Failure would result in file not found errors

    Data::get_repository_path
	Receives gist public ID and returns path of the repository
	allocated for the gist. Programmers are expected to use this
	method to work on the repositories instead of manually
	constructing paths.

    crate::utils::escape_spaces
	Escapes spaces in the provided string, "foo bar".txt is
	converted to "foo\ bar".txt
2022-02-15 21:29:55 +05:30
Aravinth Manivannan 303a4ab0ba
feat: helper method Data::new_gist to create new gist and tests
DESCRIPTION
    Data::new_gist creates a bare repository in the supplied
    Data.settings.repository.root directory and saves metadata in the
    database

    See accompanying test for usage
2022-02-14 22:46:17 +05:30
Aravinth Manivannan c636826ecf
fix: cargo fmt 2022-02-14 22:42:02 +05:30
Aravinth Manivannan 303a430113
fix: rename GistPrivacy to GistVisibility and *privacy to *visibility 2022-02-14 20:38:19 +05:30
Aravinth Manivannan 6b60e2a064
feat: add gists_gists, gists_comments and gists_comments & related methods
The following changes are implemented for both db-sqlx-postgres and
db-sqlx-sqlite:

TABLE gists_gists
    Stores gist metadata with unique index on gists_gists.public_id for fast
    lookups

TABLE gists_comments
    Stores comment metadata

TABLE gists_privacy
    Stores gist privacy: sqlx currently doesn't have support Postgres
    enums(ref: https://github.com/launchbadge/sqlx/issues/1171), so storing
    possible privacy values as references from this table.

    This table shouldn't be mutated during runtime. Possible values are
    already recorded in database during migrations. All runtime operations
    on this table must only take references.

    Each implementation of GistDatabase also includes a method called
    privacy_exists, which is called during tests to ensure that
    migrations are successful.

VIEW gists_gists_view
    Gist lookups combines data from gists_users, gists_gists and
    gists_privacy. This SQL view boots performance(I think?). At any rate,
    it is much nicer to work with.

QUIRKS
    Database indexes are i64 in SQLite while i32 in Postgres
2022-02-14 20:11:26 +05:30
Aravinth Manivannan 9c35c6f99b
feat: add tests for health meta route 2022-02-13 16:27:42 +05:30
Aravinth Manivannan 6fc667ffc9 feat: run migrations on start up 2022-02-13 00:18:49 +05:30
Aravinth Manivannan 915fb46445 fix: lints and run migrations before generating coverage in CI 2022-02-13 00:07:28 +05:30
Aravinth Manivannan 34a67a5535 feat: bootstarp gists
AUTHENTICATION

- Sign Up
- Sign IN

ACCOUNT
- Username Exists
- Email Exists
- Account delete
- Password update
- Email update
- Username update
- Get account secret
- Update secret

All routes are implemented with proper error handling and testing

CONFIGURATION
See ./config/default.toml for full list
2022-02-12 23:48:35 +05:30