This is the backend repository for the Face Detective project. This repository contains a Node.js server with endpoints for user registration, authentication, and more.
- Prerequisites
- Installation
- Setting Up a PostgreSQL Database
- Environment Variables
- Running the Server
- Modifying the Code
- Submitting Issues and Pull Requests
- Node.js (>=14.0.0)
- npm (>=6.0.0)
- PostgreSQL (>=12.0.0)
Clone the repository:
git clone https://github.com/ritabradley/face-detective-backend.git
cd face-detective-backend
Install the dependencies:
npm install
or
npm i
-
Install PostgreSQL on your machine if you haven't already. You can follow the official PostgreSQL installation guide.
-
Create a new PostgreSQL database and user:
createdb face_detective
createuser -P -s -e face_detective_user
- Set up the necessary tables by running the following SQL commands in the
psql
command-line interface:
CREATE TABLE users (
user_id SERIAL PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100) UNIQUE NOT NULL,
entries INTEGER DEFAULT 0,
joined TIMESTAMP NOT NULL
);
CREATE TABLE logins (
login_id SERIAL PRIMARY KEY,
email VARCHAR(100) UNIQUE NOT NULL,
hash VARCHAR(100) NOT NULL
);
Create a .env
file in the project root directory with the following variables:
DB_URL=your_database_url
DB_HOST=localhost
DB_PORT=5432
DB_USER=face_detective_user
DB_PASSWORD=your_database_password
Replace your_database_url
and your_database_password
with the appropriate values for your PostgreSQL setup.
To start the development server, run:
npm start
Feel free to modify the code to suit your needs. If you want to change the database connection details, you can update the knex
configuration in server.js
.
- For issues, open a new issue on the GitHub repository and provide a detailed description of the problem.
- For pull requests, create a new branch, make your changes, and submit a pull request. Please provide a clear description of the changes you've made.