/toxen-poly

Toxen: Poly is a recreation of Toxen3, built to support local or external music servers. Share music with those around your home, listen on your phone streamed from your PC, or run a standalone music server for clients to use.

Primary LanguageTypeScript

Ioncore Project Template

Build Status

This is a template for an Ioncore project. It contains a TypeScript full-stack application, with a server in Nodejs and a client in React.

Getting Started

Prerequisites

  • Nodejs (Recommended: v16.10.0 or higher)
  • Yarn (Recommended: v1.22.10 or higher)
    • Install with npm install -g yarn

Installation

Both the server's and the client's dependencies must be installed. To do so, run the following command in the root directory of the project:
Unless stated otherwise, all terminal code in this file should work on Windows CMD, PowerShell, Linux, and OSX terminals.

cd server
yarn install
cd ../client
yarn install
cd ..

Running the Project

To run the project in development mode, the easiest way is to open the project in Visual Studio Code and start debugging (F5). This also enables debugging in the server and client and allows breakpoints to be used.
Alternatively, you can open 2 terminals, one in the server directory and one in the client directory, and run the following commands:
Terminal 1:

cd server
yarn dev

Terminal 2:

cd client
yarn dev

This will start the server on port 3080 (default). The client is proxied to the server, so you can access it on http://localhost:3080.

HTTPS

To enable HTTPS, you need to generate a certificate and passphrase. The certificate must be placed in the server directory and named certificate.pfx.
You can then set the CERTIFICATE_PASSPHRASE environment variable to the passphrase you generated.

certificate.pfx is ignored by .gitignore, so it will not be committed to the repository. Remove it from .gitignore if you want to commit it.

When building the project, the certificate will be copied to the dist directory.

As of right now, enabling HTTPS will disable HMR (Hot Module Replacement) in the client.

Generating a Certificate

Windows Powershell

You can generate a self-signed certificate with a passphrase using the following command, assuming you are in the root directory of the project:

$domain = "mydomain.com"
$passphrase = "YourPassphrase"
$cert = New-SelfSignedCertificate -DnsName $domain -CertStoreLocation cert:\LocalMachine\My
$pwd = ConvertTo-SecureString -String $passphrase -Force -AsPlainText
Export-PfxCertificate -Cert $cert -FilePath .\server\certificate.pfx -Password $pwd