Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fwcd/bassment
Music library server with support for playlists, crates and a web/mobile frontend
https://github.com/fwcd/bassment
actix-web crates dj music music-library playlists react-native-web server
Last synced: about 1 month ago
JSON representation
Music library server with support for playlists, crates and a web/mobile frontend
- Host: GitHub
- URL: https://github.com/fwcd/bassment
- Owner: fwcd
- License: gpl-3.0
- Created: 2022-02-10T11:20:08.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-08T09:56:36.000Z (over 1 year ago)
- Last Synced: 2024-04-26T01:33:00.098Z (9 months ago)
- Topics: actix-web, crates, dj, music, music-library, playlists, react-native-web, server
- Language: TypeScript
- Homepage:
- Size: 2.62 MB
- Stars: 10
- Watchers: 4
- Forks: 0
- Open Issues: 52
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bassment
[![Build](https://github.com/fwcd/bassment/actions/workflows/build.yml/badge.svg)](https://github.com/fwcd/bassment/actions/workflows/build.yml)
[![Frontend](https://github.com/fwcd/bassment/actions/workflows/frontend.yml/badge.svg)](https://github.com/fwcd/bassment/actions/workflows/frontend.yml)Music library server with support for playlists, crates and more.
## Repository Structure
Bassment primarily consists of two components:
- The backend server, written in Rust (using `actix-web` and `diesel`), located in the repository root.
- The frontend, written in TypeScript (using `react-native`, targeting Web, iOS and Android), located in the `frontend` folder.While the backend server can serve the frontend from `frontend/dist` (after building and bundling it with Webpack), it can also run in API-only mode and independently (with `--api-only`).
## Getting Started
### Backend
To develop the backend server, make sure to have a Rust toolchain and PostgreSQL installed (the latter also running). Create a database and make sure that the `pgcrypto` extension is enabled (within the database). With sufficient privileges, you can enable it from `psql your_db_name` using
```sql
CREATE EXTENSION pgcrypto;
```Create a database and a `.env` file in this repo that points to the database:
```
DATABASE_URL=postgres://your_username:your_password@localhost/your_db_name
```To start the server, run
```sh
scripts/run-dev-backend
```By default, the server will run on `http://localhost:8090` in API-only mode and allow CORS requests (to permit requests from a frontend dev server running in parallel).
> You can of course also use `cargo run` manually. Note that the default configuration is more geared towards production use, however, therefore check out `cargo run -- --help` to view the list of flags.
On the first run, the server will automatically run all of the migrations and generate a root user, whose password is output to the console. If, at any point, you wish to regenerate this root user, pass `--regenerate-root` to the server.
> Note that the Diesel CLI, which can be installed using `cargo install diesel_cli --no-default-features --features postgres` (see [here](https://diesel.rs/guides/getting-started)), might also be useful. The Diesel CLI lets you e.g. run migrations with `diesel migration run` and undo them with `diesel migration revert`.
Since all API routes are gated behind authentication (you need to log in via `/auth/v1/login`), it can sometimes be cumbersome to manually copy-and-paste tokens to `curl` while developing. Therefore the server also supports the flag `--allow-unauthenticated-access` for disabling authentication (obviously do not use this production):
```sh
scripts/run-dev-backend --allow-unauthenticated-access
```We can verify that this works correctly by sending a simple API request with `curl`:
```sh
curl -i http://localhost:8090/api/v1/tracks
``````
HTTP/1.1 200 OK
content-length: 2
access-control-expose-headers: host, user-agent, accept
vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers
access-control-allow-credentials: true
content-type: application/json
date: Sun, 08 May 2022 19:42:42 GMT[]
```### Frontend
To develop the frontend, you can either use `npm` in the `frontend` directory directly or the convenience scripts mentioned in the following paragraphs from the repository root.
First, make sure to have the npm dependencies installed:
```sh
scripts/bootstrap-frontend
```Now you can run the frontend with a dev server on `http://localhost:8080` (you probably want to have the backend running in API-only mode simultaneously for it to do anything useful):
```sh
scripts/run-dev-frontend
```To bundle the frontend for production use into `frontend/dist`, run
```sh
scripts/bundle-frontend
```You can then run the backend server, now also serving the frontend, with vanilla `cargo run` and visit the entire web application at `http://localhost:8090` in your browser.