-
Make sure you have node installed. You can check this by running
node -v
in your terminal. If you don't have node installed, you can download it here. -
Clone or fork this repository. You can do this by running
git clone https://github.com/rit-sse/WebsiteTheSSEquel.git
in your terminal in the directory you want to clone the repository to. -
Navigate to the directory you cloned the repository to and run
cd ./next
. This will take you to thenext
directory, which is where the Next.js application is located. -
Run
npm install
to install all the dependencies for the project. -
Run
npm run dev
to start the development server. You can view the website atlocalhost:3000
.
At this point, you should be able to explore the site without logging in or having to set up a database. In order to have authentication and access to the database, you will need to set up a .env
file. This file is not included in the repository because it contains sensitive information. The .env
file should be located in the next
directory. The contents of the .env
file should be as follows:
DATABASE_URL="database url string"
GOOGLE_CLIENT_ID="google cloud OAuth client id"
GOOGLE_CLIENT_SECRET="google cloud OAuth client secret"
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="random string of characters used for encryption -- feel free to make this up or use openssl to generate one"
The above is just a placeholder, you'll need to fill in each entry with the appropriate information. First, let's step through setting up a local database.
-
Download and install PostgreSQL 14. Make sure you're installing 14, not any higher versions! This is the database management system we are using for the project. When you visit the downloads page, click on your operating system and look for the following in the subsequent page:
-
Run the installer and follow the instructions to install PostgreSQL. Make sure you remember the password you set for the database superuser.
-
Open up pgAdmin 4. This should have been installed along with PostgreSQL. Click on the
Servers
dropdown in the top left corner and selectPostgreSQL 14
. You will be prompted to enter the password you set for the database superuser. -
Create a new database by right clicking on
Databases
and selectingCreate > Database...
. Name the database something likessequel-dev
and clickSave
. -
Now that you have a database, you can fill in the
DATABASE_URL
entry in the.env
file. TheDATABASE_URL
should be in the following format:postgresql://<username>:<password>@localhost:5432/<database name>
, where<username>
is the username of the database superuser,<password>
is the password you set for the database superuser, and<database name>
is the name of the database you created in step 4. The default username for the database superuser ispostgres
.
-
Go to the Google Cloud Console and create a new project. Name the project something like
ssequel-dev
. -
Navigate to
APIs & Services
and go to the Credentials tab. Click onCreate Credentials
and selectOAuth client ID
. -
On the next screen, select
Configure consent screen
. -
Select
External
and clickCreate
. -
Fill in the
Application name
field with something likeSSEquel Dev
, and your email for the requiredUser support email
andDeveloper contact information
fields. You can leave the other fields blank. ClickSave and Continue
. -
On the Scopes page, click
Save and Continue
. -
On the Test users page, click
Save and Continue
. -
On the Summary page, click
Back to Dashboard
. -
Now that you've configured the consent screen, you can create the OAuth client ID. Back on the Credentials tab page, click on
Create Credentials
and selectOAuth client ID
. -
On the next screen, select
Web application
. Name the OAuth client ID something likeSSEquel Dev
. UnderAuthorized JavaScript origins
, addhttp://localhost:3000
. UnderAuthorized redirect URIs
, addhttp://localhost:3000/api/auth/callback/google
. ClickCreate
. You should be presented with a modal titledOAuth client created
. -
Congratulations, you've created a Google OAuth client ID! You can now fill in the
GOOGLE_CLIENT_ID
andGOOGLE_CLIENT_SECRET
entries in the.env
file.
The GOOGLE_CLIENT_ID
and GOOGLE_CLIENT_SECRET
can be found again later by going to the Credentials tab and clicking on the client ID under OAuth 2.0 Client IDs
.
If you run the project now, you'll encounter schema errors. This is because the local database hasn't been built. We use Prisma for managing the Postgres database, so we'll use Prisma's migrate command to build the db tables using the schema defined in the schema.prisma file.
In the /next/ directory, run npx prisma migrate dev
. Then run npx prisma db seed
to populate the database with test data.
That's it! You should now be able to run npm run dev
and view the website at localhost:3000
with authentication and access to your local database instance. Try logging in with your RIT email.