REST API for the UC San Diego ACM chapter's membership portal. This is an open-source project, made for members by members, and we welcome any contributions! If you're interested in using the API for your own project and/or contributing, check out our guide here.
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
.env
file using.env.example
as 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
.
Even though our actual Postgres instance runs in a Docker container, we need to install Postgres to install the official pg
Node package. 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.
- Run the Windows Powershell as administrator.
- Install build tools to compile native Node modules:
npm install -g windows-build-tools
. - Rerun
npm install
in a separate command prompt window.
RDS_HOST=localhost
RDS_PORT=5432
RDS_DATABASE=membership_portal
RDS_USER=acmucsd_dev
RDS_PASSWORD=password
AUTH_SECRET=secret
CLIENT=localhost:8000
Note: For Windows users, localhost
won't work—you'll need to set RDS_HOST
to the Docker Machine's IP address.
docker-compose up -d
to configure and run any required servicesnpm install
to install the necessary dependenciesnpm run dev
to run the Node app with Nodemon and ts-nodenpm run build
to compile the code to JavaScriptnpm run lint
to lint the Node app with ESLint (without--fix
)npm run lint:fix
to fix the simple linter issues automaticallynpm run test
to run the test suite with Jestnpm run db:migrate
to run any new database migrationsnpm run db:rollback
to roll back the last database migrationnpm run db:seed
to populate the database with seedsnpm run db:unseed
to completely clear the databasedocker exec -it rds.acmucsd.local psql -U [RDS_USER] -d [RDS_DATABASE]
to access Postgres (RDS_XYZ
from.env
).
Take a look at package.json
for the actual commands.
After having executed npm run db:seed
, tests/Seeds.ts
will have been used to generate sample data. For all testing accounts, the password is password
. To test basic features of the portal, [email protected]
can be used for the demo admin account, and any seed email (e.g. [email protected]
) can be used for a demo member account.
For testing out the different portal roles, use the email acm_[role]@ucsd.edu
, such that [role]
is replaced with any of the following terms:
restricted
- User has been blocked from appearing on the leaderboard, although their account is still valid.standard
- The default user role for all member accounts.staff
- User is able to check in to events as a staff member.admin
- User has full permissions to administrate the portal and store.marketing
- User is able to create and edit events.store_manager
- User is able to administrate store, including modifying collections, items, options, stock, and pricing.store_distributor
- User is able to execute store distributions, including viewing and fulfilling orders for each pickup event.
For testing out the store, use the email [email protected]
, as the majority of demo orders will be placed with this account.
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.
GET /auth/resetPassword
: renamed to/auth/passwordReset
POST /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/bonus
POST /user/milestone
: renamed to/admin/milestone
;resetPoints?: boolean
has been replaced in the request body bypoints?: number
GET /store/collection/:uuid
:merchandise
has been renamed in the response body toitems
GET /store/merchandise
: deleted- passwordChange field is breaking change (see Auth/UserControllerRequests)
POST /user/picture/:uuid
: the UUID parameter is optionalGET /attendance/:uuid?
: theattendance
field in the response body has been renamedattendances
POST /attendance/attend
: no longer reachable, requests should be made to/attendance
- merch store has been completely reworked
- Update the app to the latest release of the first iteration (
v1-latest
). - Manually run this SQL script (
0000-sequelize-to-typeorm.sql
). - Update the app to the latest release (latest).