Skip to content

Commit

Permalink
Merge branch 'main' into snyk-upgrade-52770756e42c9c578026ddbf14345d99
Browse files Browse the repository at this point in the history
  • Loading branch information
avenmia authored Dec 22, 2023
2 parents 85651d6 + 2ddc624 commit bbc6bc4
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 16 deletions.
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@next-auth/prisma-adapter": "^1.0.5",
"@prisma/client": "^4.10.0",
"@tanstack/react-query": "^4.20.0",
"@tanstack/react-query": "^4.36.1",
"@trpc/client": "^10.9.0",
"@trpc/next": "^10.9.0",
"@trpc/react-query": "^10.9.0",
Expand Down
1 change: 1 addition & 0 deletions prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @type {import("prettier").Config} */
module.exports = {
plugins: [require.resolve("prettier-plugin-tailwindcss")],
endOfLine: "auto",
};
11 changes: 11 additions & 0 deletions public/humans.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* TEAM */
Software Developer: Tyler Chong
Contact: tcchong [at] hawaii.edu
GitHub: @tyliec

Software Developer: Michael Avendano
Contact: mavenmia92 [at] gmail.com
GitHub: @avenmia

/* SITE */
Last update: 2023/11/26
61 changes: 61 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,67 @@ Follow these directions for easier database editing.
- `npx prisma db push`
- Run the application and confirm it works

# Prisma SQLite

Why use SQLite?

SQLite is a light-weight alternative to Microsoft SQL Server that provides an easier setup solution for those running the project locally.

Getting started with SQLite

Firstly, check if your machine already has SQLite. Many operating systems today come with SQLite pre-installed, but to verify run the following command:

```bash
$sqlite3
```

If already installed, a message similar to the following will display:

```bash
SQLite version 3.37.2 2022-01-06 13:25:41
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite>
```

If not already installed, continue below:

Windows Users

- Checkout [SQLiteTutorial.net](https://www.sqlitetutorial.net/download-install-sqlite/) for a quick and simple Windows setup.

Mac and Linux Users

1. Go to the [SQLite download page](https://www.sqlite.org/download.html) and download sqlite-autoconf-\*.tar.gz from the **Source Code** section.
2. Run the following commands:

```bash
$tar xvfz sqlite-autoconf-3071502.tar.gz
$cd sqlite-autoconf-3071502
$./configure --prefix=/usr/local
$make
$make install
```

Configuration

- Update the schema.prisma file to use the following provider

`provider = "sqlite"`

- Update the env file to specify the database file

`DATABASE_URL="file:./db.sqlite"`

- Run the following command to update the database

```bash
npx prisma db push
```

> Note: The demographic questions will not populate because they are hard-coded in the SQL migrations.
# Working with prisma

When the data model changes, run the following to update your local database with the latest migrations
Expand Down
142 changes: 142 additions & 0 deletions src/docs/deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# HIERR Application Assumptions

1. Windows Server 2022

> Some additional components may need to be installed if this is not the version of Windows used
# Update Instructions

1. Download the HIERR application package from the [releases page](https://github.com/CodeWithAloha/HIERR/releases).
2. Expand the zip file to a new directory (do not overwrite the existing HIERR application directory).
3. Open PowerShell and run the following commands (open a new PowerShell window if one running the HIERR application is already open)

1. `cd <new expanded HIERR directory>`
1. `dir`
- Make sure that you see a README.md file in this directory
1. `cp ..\<old HIERR app directory>\.env .env`

4. If the HIERR application is running in a different PowerShell window, click that window and:
1. Press Ctrl-C, then type “Y” and enter to stop the previous version of the HIERR application
2. Close the old PowerShell window
5. In the new PowerShell window:

```bash
npm install
npx prisma db push
npm run build
npm run start
```

# Installation Instructions

## Directions

1. Download Node.js installer (https://nodejs.org/dist/v18.14.2/node-v18.14.2-x64.msi)
2. Run installer to install Node.js
a. When prompted to install necessary tools, make sure to click this “on” before proceeding.
b. When prompted with a new text console window for “Tools for Node.js Native Modules Installation Script” press y on the keyboard. You will need to press y twice.
c. At some point, an installer for PowerShell will appear. Proceed with PowerShell installation.
3. Download Microsoft SQL Server Express Installer (https://go.microsoft.com/fwlink/p/?linkid=2216019&clcid=0x409&culture=en-us&country=us)
4. Run installer to install Microsoft SQL Server Express
5. Download Microsoft SQL Server Management Studio (https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver16)
6. Open SQL Server Configuration Manager
a. Select SQL Server Network Configuration from the left sidebar
b. Select Protocols for MSSQL Server
c. Set TCP/IP to enable
d. Restart SQL Server
7. Download HIERR application package from Github (link)
8. Expand the zip file
9. Open PowerShell and run the following commands (and leave PowerShell open)
a. `cd <expanded HIERR directory>`
b. `dir`

1. Make sure that you see a README.md file in this directory

c. `New-Item .env -type file`

10. Open Notepad, and open the newly created .env file in the expanded HIERR directory (you may need to select all files in the open file dialog box), and add the following four lines:
a. `DATABASE_URL="sqlserver://localhost:1433;initial catalog=<YourDBName>;integratedSecurity=true;trustServerCertificate=true;"`
b. `NEXTAUTH_URL="<YourURL>"`
c. `NEXTAUTH_SECRET=<YourSecret>`
d. `EMAIL_SERVER=<YourEmailServer>`
e. `EMAIL_FROM=<YourEmailAddress>`
f. `AUTHORIZED_POLIS_CONVERT_EMAILS_FILE={path to file that contains a list of email addresses (one per line) whose users are authorized to export POLIS data}`
For example: AUTHORIZED_POLIS_CONVERT_EMAILS_FILE={YourAuthorizedEmailTextFile}
11. Save and close the Nodepad file.
12. Back in PowerShell, run the following commands:

```
npm install
npx prisma db push
npm run build
npm run start
```

1. Visit http://localhost:3000 from the same computer and verify that you can see the HIERR application.
a. Do not proceed if you cannot load the HIERR main page through this link.
1. Turn on IIS
a. Open “Control Panel”
b. Click “Turn Windows Features on and off”
c. Click “Add Roles and Features”
d. Click “Next” on “Before You Begin” screen (if it appears)
e. Select “Role or feature-based installation”
f. On the server selection screen, click “Next”.
g. Click “Web Server (IIS)” and click Management tools on, then click “Next”
h. Click “Next” on the Features screen. If “Next” is greyed out, then this is likely already installed. Skip to step j.
i. Run that installation until it completes
j. Download and install URL rewrite module https://www.iis.net/downloads/microsoft/application-request-routing - use x64 version
k. Download and install Application Request Routing 3.0 https://iis-umbraco.azurewebsites.net/downloads/microsoft/application-request-routing - use x64 version
1. Download Certify the Web (https://certifytheweb.s3.amazonaws.com/downloads/archive/CertifyTheWebSetup_V5.6.8.exe)
1. Run Certify the Web installer.
1. Run Certify the Web once it’s installed.
a. Click “New Certificate”
b. Click “OK” when prompted to register a new contact.
c. Enter an email address for the HIERR application administrator. Scott’s email is fine.
d. Click “Yes, I agree” with the terms for the Let’s Encrypt Certificate Authority, then click “Register Contact”.
e. In the next window, select “Default web site”, type “<YourDomain>” in the “Add domains to certificate” field, then click the green Plus sign.
f. Click the “Test” button in the top right of the screen and verify that the test succeeds.
g. Click the back left arrow button.
h. Click the “Request Certificate” button
i. Wait until page says “Success” and “Request Completed”.
j. Click the back left arrow button if one shows up.
k. Close Certify the Web
1. Add a reverse proxy in IIS from inbound port 80 to port 3000 in the VM and inbound port 443 to port 3000 in the VM
a. Open “Internet Information Services (IIS) manager”
b. Click on the “Default Web Site” from the tree view on the left under the server tree under “Sites”
c. Double check the “URL Rewrite” Icon from the middle pane.
d. Click “Add Rule(s)…”
e. Select “Blank rule” in the Inbound rules section, then click the OK button.
f. Type “HTTPS Redirect” for the name.
g. In the Matched URL section:
i. Set Requested URL: to Matches the Pattern.
ii. Set Using to Regular Expressions.
iii. Enter (.\*) as the Pattern.
iv. Check Ignore case.
h. Scroll down to Conditions and expand the section if necessary. Select Match All for Logical grouping, then click the Add… button.
i. A dialog box will open:
i. Type {HTTPS} in the Condition input field.
ii. Set Check if input string to Matches the Pattern.
iii. Type ^OFF$ in the Pattern field.
iv. Check Ignore case.
v. Click the OK button.
j. You should now see your condition in the list.
k. Scroll down to the Action section and enter these settings:
i. Select Redirect as the Action type.
ii. Type https://{HTTP_HOST}/{REQUEST_URI} in the Redirect URL field.
iii. Uncheck Append query string.
iv. Set Redirect type to Permanent (301).
l. Click Apply in the right-hand Actions menu.
m. Choose the ‘Add Rule’ action from the right pane of the management console, and select the ‘Reverse Proxy Rule’ from the ‘Inbound and Outbound Rules’ category.
n. If asked to enable proxy functionality, click “OK”.
o. Enter localhost:3000 as where requests will be forwarded
p. Click on enable SSL offloading
q. Click on Rewrite domain names
i. From localhost:3000 to <YourDomain>
r. Click the OK button.
s. You should now see a second condition in the list.
1. Turn on TLS on port 443
a. Navigate to your website in IIS (left sidebar) and select “Bindings…” on the right hand side.
b. Specify https and hostname is <YourDomain>
c. Save that
d. This page should now show http and https bindings. Close the window.
1. Visit http://<YourDomain> from a web browser other than the VM. Your browser should be redirected to https://<YourDomain> and it should use TLS to secure the website.

0 comments on commit bbc6bc4

Please sign in to comment.