Skip to content

Commit

Permalink
Merge pull request #1488 from NYCPlanning/revert-1486-revert-1484-tas…
Browse files Browse the repository at this point in the history
…k/13717-server-node@18

Revert "Revert "Task/13717 server node@18""
  • Loading branch information
TylerMatteo authored Jul 20, 2023
2 parents b5158d9 + dc673d2 commit 75badd7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 47 deletions.
9 changes: 5 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

cd client
yarn run lint-staged
echo "\033[0;31m Pre commit hooks are disabled. Please lint and test manually before pushing.\033[0m"
# cd client
# yarn run lint-staged

cd ../server
yarn run lint-staged
# cd ../server
# yarn run lint-staged
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,51 @@

An ambitious web app for filtering and viewing NYC land use application records stored in DCP's Zoning Application Portal (ZAP).

## Development Setup

### 1. Install prerequisite tools
## Prerequisite Tools

* [Git](https://git-scm.com/)
* [Node.js](https://nodejs.org/) (with npm)
- This installation was tested using Node v12.18.4, v14.15.0
* [Node.js](https://nodejs.org/)
* [Ember CLI](https://ember-cli.com/)
* [Yarn](https://yarnpkg.com/)


### 2. Install frontend and backend packages
## Prerequisite SSL Setup for Local Development
In order for cookies to work across both the client and the server during local development, we must have SSL setup for our development environment.

```
> git clone https://github.com/NYCPlanning/labs-zap-search
> cd labs-zap-search
> yarn
> cd labs-zap-search/client
> yarn
> cd labs-zap-search/server
> yarn
```
### Why is this necessary?
Google Chrome is beginning to enforce some restrictions on particular uses of cookies in cross-origin contexts. In our case, our server provides a cookie from one domain and is expected to be sent across subsequent requests via another. The only way to simulate this behavior as it works on a production environment is to run our local development servers with SSL enabled.

### 3. Set up SSL and environment files
### Steps to setup SSL locally
1. Clone this repo and follow the steps in its README: https://github.com/NYCPlanning/local-cert-generator

2. Note that Step 1 generates two files in the `local-cert-generator` repo: `server.key` and `server.crt`. Later, you will need to copy/paste these files into the `labs-zap-search` repo to run the application.
2. Note that Step 1 generates two files in the `local-cert-generator` repo: `server.key` and `server.crt`. Later, you will need to copy/paste these files into the `labs-zap-search` repo to run the application (Steps 2 and 3 under "Running the App").

3. Open up your hosts file on your machine with admin permissions: `/etc/hosts`. For example, `sudo vim /etc/hosts`

4. Add the following line: `127.0.0.1 local.planninglabs.nyc` ![image](https://user-images.githubusercontent.com/3311663/78998629-fc437e00-7b16-11ea-81ef-edb19b4b1d90.png)

5. Navigate into the `server` folder.
## Running the App
Once you have SSL enabled...
##### note: the client and server each run on their own node version, independent of each other. Refer to the .nvmrc of their respective folders to determine the appropriate node verion.
1. Clone `labs-zap-search` to your computer.
2. Navigate into the `server` folder.
- Create the `development.env` file using variables stored on 1Password.
- Copy the `server.key` and `server.crt` files from your `local-cert-generator` repo and paste both files into the `labs-zap-search/server/ssl/` folder.
6. Navigate into the `client` folder.
- Activate the compatible node version `nvm use`
- Run `yarn` to install dependencies for the server.
- Run `yarn run start:dev` to start a development server
3. Open a new terminal and navigate into the `client` folder.
- Copy the `server.key` and `server.crt` files from your `local-cert-generator` repo and paste both files into the `labs-zap-search/client/ssl/` folder.
- Activate the compatible node version `nvm use`
- Run `yarn` to install dependencies for the client.
- Run `yarn start:ssl` to start a development server

## One-click startup

At the root of this project, run
## Pre-commit linting and testing
The client and server application node versions have become out of sync with each other. Consequently, the pre-commit hooks have been turned off until both the server and client are on the same node version.

```
yarn run start
```
Husky is designed to use the node version set in the terminal PATH at the time the command is run. Whichever node version the developer chooses will be the one that the both the client and server are tested against. This can lead to weird cases where the client or server passes in the environment it's developed for but fails in the environment where its tests are run.

This will spin up both the frontend (in the `/client` folder) and the server API (in `/server`).
As the hooks have been disabled, please take care to run linting and testing scripts for the server and client before committing. These scripts are documented in their respective `package.json` files.

## Frontend and Backend Documentation
- See [./client/](./client/) for more docs on running and modifying the frontend
Expand Down
15 changes: 1 addition & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,5 @@
"name": "labs-zap-search",
"version": "1.0.0",
"repository": "[email protected]:NYCPlanning/labs-zap-search.git",
"license": "MIT",
"scripts": {
"start": "concurrently \"yarn run client\" \"yarn run server\"",
"server": "cd server && yarn run start:dev",
"client": "cd client && yarn run start:ssl"
},
"devDependencies": {
"concurrently": "^6.2.0"
},
"volta": {
"node": "14.19.1",
"yarn": "1.22.18"
},
"dependencies": {}
"license": "MIT"
}
2 changes: 1 addition & 1 deletion server/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.15.1
18.16.0
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "",
"license": "MIT",
"engines": {
"node": "16.*"
"node": "18"
},
"scripts": {
"build": "rimraf dist && tsc -p tsconfig.build.json",
Expand Down

0 comments on commit 75badd7

Please sign in to comment.