Server
Setup

Server

The server backend is built on top of Supabase (opens in a new tab), which provides infrastructure for database, file storage, user authentication, serverless functions and more.

Local development requires running a self-managed supabase instance using docker containers. Serverless functions are run using a Deno runtime environment

Prerequisites

Quickstart

Start Server

yarn start:server

This will start various backend services within docker containers

FeatureURI
Studiohttp://localhost:54323 (opens in a new tab)
APIhttp://localhost:54321 (opens in a new tab)
DBpostgresql://postgres:postgres@localhost:54322/postgres
GraphQLhttp://localhost:54321/graphql/v1 (opens in a new tab)
Inbuckethttp://localhost:54324 (opens in a new tab)

Frontend Config
In order for frontend apps to communicate with the server an anon key created by the server must be populated to local configuration.

This key can be found in the console when the server starts, or by running the script

yarn nx run picsa-server:supabase status

This key should be populated to libs\environments\src\supabase\config.json

Create User

In order to allow communication from unauthenticated users to the database a custom anonymous user should be created from the studio dashboard with credentials:

http://localhost:54323/project/default/auth/users (opens in a new tab)

email: anonymous_user@picsa.app password: anonymous_user@picsa.app

Ensure Auto Confirm is checked

Stop Server

When no longer in use the server can be stopped by either stopping the container running in docker desktop, or by command

yarn nx run picsa-server:supabase stop

Troubleshooting

Relative import path "@supabase/supabase-js" not prefixed

Any Imports have to be defined both in import-map.json file

Ports are not available exposing port TCP 0.0.0.0:54322 -> 0.0.0.0:0: listen tcp 0.0.0.0:54322: bind: An attempt was made to access a socket in a way forbidden by its access permissions

Windows reserves some of the same ports that supabase uses. Either the supabase ports can be modified from the config.toml file, or windows updated to change restricted port ranges

https://stackoverflow.com/a/71190107/5693245 (opens in a new tab) https://github.com/supabase/cli/issues/189 (opens in a new tab)

Server restart fails (corrupted server)

If the server stops working it may need a clean restart

yarn nx run picsa-server:supabase stop --no-backup

This will stop the running container but not persist any data

yarn nx run picsa-server:supabase start

Links