This project contains boilerplate code for a TypeScript React app with a REST API running on Express. The entire project is Dockerized for easy setup of a development environment.
Installation prerequisites:
- Docker
- Yarn or npm
- Create a
.env
file containing all the required environment variables needed to run both the client and the server docker-compose build
docker-compose up
- Gain terminal access into a specific service by using
docker-compose exec service_name bash
, whereservice_name
can be replaced with eitherserver
,client
,postgres
orredis
- Create a
.env
file containing all the required environment variables needed to run both the client and the server docker-compose build
docker-compose run --rm -p 5000:5000 server yarn dev:watch
- The REST API can be accessed at http://localhost:5000
DATABASE_NAME=react-rest
POSTGRES_PASSWORD=verysecretpassword
DATABASE_URL=postgresql://postgres:verysecretpassword@postgres:5432/react-rest
REDIS_URL=redis:6379
COOKIE_DOMAIN=.felixtan.me
CORS_ORIGIN=http://localhost:3000
PORT=5000
SESSION_SECRET=laksdjfpq08w439owijhdklmbsdfklqjwyhef98
NEXT_PUBLIC_SERVER_URL=http://localhost:5000
Environment variable | Description |
---|---|
DATABASE_NAME |
Name of database to be created in Postgres |
POSTGRES_PASSWORD |
Password used for accessing Postgres database |
DATABASE_URL |
Postgres connection URL |
REDIS_URL |
Redis connection URL |
COOKIE_DOMAIN |
The base domain that cookies will work on. Must be set if using subdomains in production |
CORS_ORIGIN |
CORS origin (client URL) |
PORT |
Port that the Express server uses/exposes |
SESSION_SECRET |
Used for encrypting session data. Put a long, hard to crack string here |
NEXT_PUBLIC_SERVER_URL |
Endpoint that the client uses to access the REST API server |