A little concept program with authentication using NodeJS with Passport, PostgreSQL, and ExpressJS. It contains login, registration, and password updating functionality.
I've built small applications with authentication using Passport with MongoDB, but not with Postgres. This gave me the opportunity to learn something new. Hopefully it can help someone else with their projects.
- Clone the repository
git clone https://github.com/ad3m3r5/passport-postgres-authentication.git
- Install necessary packages
npm install
- Create your database and table in PostgreSQL. This is the statement I used.
CREATE TABLE users (
id UUID NOT NULL,
username TEXT NOT NULL UNIQUE,
password TEXT NOT NULL,
CONSTRAINT users_pkey PRIMARY KEY(id)
)
WITH (oids = false);
- Create the file .env, which will store database connection information. Add the following variables using your respective values.
PGHOST=<postgres_host>
PGPORT=<postgres_port>
PGDATABASE=<database_name>
PGUSER=<postgres_username>
PGPASSWORD=<postgres_password>
- Run the application
node server.js
Main Packages Used