@acmucsd/membership-portal v2.11.0
membership-portal-api 
REST API for the UC San Diego ACM chapter's membership portal.
Build Instructions
Feel free to use yarn ... instead of npm run ..., but make sure not to commit the yarn.lock.
- Clone the repository:
git clone https://github.com/acmucsd/membership-portal. - Navigate to the directory:
cd membership-portal. - Install PostgreSQL. See installation instructions below.
- Install the necessary dependencies:
npm install. For Windows users, see specific build instructions below. - Create a new
.envfile using.env.exampleas a template:cp .env.example .env. - Fill out the
.env. See the example file below. - Run the containerized service(s) (e.g. Postgres):
docker-compose up -d. - Initialize the database:
npm run db:migrate. - Populate the database:
npm run db:seed. - Start the Node app:
npm run dev.
Installing Postgres
MacOS and Linux users can install Postgres via Homebrew, and Linux users can use apt. Windows users will need to download the Postgres 11.5 installer from here, run the installer, and add the Postgres bin to the PATH environment variable.
Windows Build Instructions
- Run the Windows Powershell as administrator.
- Install build tools to compile native Node modules:
npm install -g windows-build-tools. - Rerun
npm installin a separate command prompt window.
Sample .env
RDS_HOST=localhost
RDS_PORT=5432
RDS_DATABASE=membership_portal
RDS_USER=acmucsd_dev
RDS_PASSWORD=password
AUTH_SECRET=secret
CLIENT=localhost:8000Note: For Windows users, localhost won't work—you'll need to set RDS_HOST to the Docker Machine's IP address.
Useful Commands
docker-compose up -dto configure and run any required servicesnpm installto install the necessary dependenciesnpm run devto run the Node app with Nodemon and ts-nodenpm run lintto lint the Node app with ESLint (without--fix)npm run lint:fixto fix the simple linter issues automaticallynpm run testto run the test suite with Jestnpm run db:migrateto run any new database migrationsnpm run db:rollbackto roll back the last database migrationnpm run db:seedto populate the database with seedsnpm run db:unseedto completely clear the databasedocker exec -it rds.acmucsd.local psql -U [RDS_USER] -d [RDS_DATABASE]to access Postgres (RDS_XYZfrom.env).
Take a look at package.json for the actual commands.
Database Migrations
To write database migrations, take a look at the TypeORM documentation and previous migrations. Everything's already configured via ormconfig.ts so executing npm run db:migrate should work. Migrations on the production database automatically run upon deployment using Heroku's release phase (configured in the Procfile).
Upgrading to Latest Version
The first iteration of the membership portal is a JavaScript app written in 2019. The second and latest iteration, written 2020, is a TypeScript app built with better reliability and error handling, stronger concurrency guarantees, and a smoother development experience in mind, and includes a number of breaking changes at the API and database levels. For a more concrete list of improvements, see acmucsd/membership-portal#115.
API Breaks and Changes
GET /auth/resetPassword: renamed to/auth/passwordResetPOST /auth/resetPassword: renamed to/auth/passwordReset- some routes (e.g. events search) accept optional auth tokens for more detailed responses
POST /user/bonus: renamed to/admin/bonusPOST /user/milestone: renamed to/admin/milestone;resetPoints?: booleanhas been replaced in the request body bypoints?: numberGET /store/collection/:uuid:merchandisehas been renamed in the response body toitemsGET /store/merchandise: deleted- passwordChange field is breaking change (see Auth/UserControllerRequests)
POST /user/picture/:uuid: the UUID parameter is optionalGET /attendance/:uuid?: theattendancefield in the response body has been renamedattendancesPOST /attendance/attend: no longer reachable, requests should be made to/attendance
To Upgrade
- Update the app to the latest release of the first iteration (0.14.2).
- Manually run this SQL script (
0000-sequelize-to-typeorm.sql). - Update the app to the latest release (latest).