DanielFGray / react-pg-session-example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-pg-session-example

This is a small example of using create-react-app, express, and express-session together and storing session data in Postgres.

Requirements

This uses docker and docker-compose to manage a Postgres cluster and run migrations using db-mate.

Getting started

After you clone the repo, you should run the setup script:

yarn setup

This will do a number of things, like generate a .env file and prompt for passwords, start the Postgres cluster in docker, run migrations, and generate TS types from the database using zapatos.

After that's done, you can start the project with:

yarn start

Roadmap

  • settings page
  • client-side protected routes
  • server-side rendering?

Non-goals

I've specifically not done a lot of organization on the server, route handlers are crammed full of logic that should likely be separated, but I've deliberately kept it this way to keep the implementation simple and easy to understand. Consider separating the database calls into their own module, and using zod to validate form responses.

About


Languages

Language:TypeScript 57.9%Language:JavaScript 31.4%Language:HTML 7.3%Language:CSS 3.5%