# @acmucsd/membership-portal

> REST API for ACM UCSD's membership portal.

Latest version **2.11.0** (published 2023-02-17) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install @acmucsd/membership-portal
pnpm add @acmucsd/membership-portal
yarn add @acmucsd/membership-portal
bun add @acmucsd/membership-portal
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.11.0 |
| Published | 2023-02-17 |
| First published | 2020-09-24 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^14.0.0 |
| Dependencies | 31 |
| Unpacked size | 19.7 KB |
| Known vulnerabilities | 0 (+21 in 6 direct dependencies) |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Sumeet Bansal |
| Maintainers | stonet2000, sumeet-bansal, acmucsd_dev |

## Links

- npm: https://www.npmjs.com/package/@acmucsd/membership-portal
- Repository: https://github.com/acmucsd/membership-portal
- Homepage: https://github.com/acmucsd/membership-portal#readme
- Issues: https://github.com/acmucsd/membership-portal/issues
- npm.io page: https://npm.io/package/@acmucsd/membership-portal

## Dependencies (31)

- [pg](https://npm.io/package/pg.md) ^8.6.0
- [ejs](https://npm.io/package/ejs.md) ^3.1.3
- [cors](https://npm.io/package/cors.md) ^2.8.5
- [uuid](https://npm.io/package/uuid.md) ^8.3.1
- [faker](https://npm.io/package/faker.md) ^5.5.3
- [bcrypt](https://npm.io/package/bcrypt.md) ^5.0.0
- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [moment](https://npm.io/package/moment.md) ^2.27.0
- [morgan](https://npm.io/package/morgan.md) ^1.10.0
- [multer](https://npm.io/package/multer.md) ^1.4.2
- [typedi](https://npm.io/package/typedi.md) ^0.8.0
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.906.0
- [express](https://npm.io/package/express.md) ^4.17.1
- [ts-node](https://npm.io/package/ts-node.md) ^9.1.1
- [typeorm](https://npm.io/package/typeorm.md) 0.2.32
- [winston](https://npm.io/package/winston.md) ^3.3.3
- [typescript](https://npm.io/package/typescript.md) ^4.0.0
- [underscore](https://npm.io/package/underscore.md) ^1.13.1
- [body-parser](https://npm.io/package/body-parser.md) ^1.19.0
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [amazon-s3-uri](https://npm.io/package/amazon-s3-uri.md) ^0.1.1
- [@sendgrid/mail](https://npm.io/package/@sendgrid/mail.md) ^7.4.4
- [tsconfig-paths](https://npm.io/package/tsconfig-paths.md) ^3.9.0
- [class-validator](https://npm.io/package/class-validator.md) ^0.12.2
- [datadog-metrics](https://npm.io/package/datadog-metrics.md) ^0.9.3
- [moment-timezone](https://npm.io/package/moment-timezone.md) ^0.5.34
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13
- [class-transformer](https://npm.io/package/class-transformer.md) ^0.3.1
- [routing-controllers](https://npm.io/package/routing-controllers.md) ^0.9.0
- [typeorm-typedi-extensions](https://npm.io/package/typeorm-typedi-extensions.md) ^0.2.3
- [winston-daily-rotate-file](https://npm.io/package/winston-daily-rotate-file.md) ^4.5.0

## Recent versions

- 2.11.0 (latest) — 2023-02-17
- 1.0.4 — 2020-09-29
- 1.0.0 — 2020-09-24

## README

## membership-portal-api &nbsp; [![CircleCI](https://circleci.com/gh/acmucsd/membership-portal/tree/master.svg?style=svg)](https://circleci.com/gh/acmucsd/membership-portal/tree/master)
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](https://github.com/acmucsd/membership-portal/blob/master/.github/CONTRIBUTING.md).

### Build Instructions
`npm install` may not work properly due to version incompatibilities. Feel free to use `yarn ...` instead of `npm run ...`.

1. Clone the repository: `git clone https://github.com/acmucsd/membership-portal`.
2. Navigate to the directory: `cd membership-portal`.
3. Install PostgreSQL. See [installation instructions below](#installing-postgres).

if(`npm install` works fine):

4. Install the necessary dependencies: `npm install`. For Windows users, see [specific build instructions below](#windows-build-instructions).
5. Create a new `.env` file using [`.env.example`](https://github.com/acmucsd/membership-portal/blob/master/.env.example) as a template: `cp .env.example .env`.
6. Fill out the `.env`. See the [example file below](#sample-env).
7. Run the containerized service(s) (e.g. Postgres): `docker-compose up -d`.
8. Initialize the database: `npm run db:migrate`.
9. Populate the database: `npm run db:seed`.
10. Start the Node app: `npm run dev`.

if(`npm install` does not work):

4. Install yarn first, it is a package manager (you can find it at https://yarnpkg.com). After that, install the necessary dependencies using: `yarn install`.
5. Create a new `.env` file using [`.env.example`](https://github.com/acmucsd/membership-portal/blob/master/.env.example) as a template: `cp .env.example .env`.
6. Fill out the `.env`. See the [example file below](#sample-env).
7. Run the containerized service(s) (e.g. Postgres): `docker-compose up -d`.
8. Initialize the database: `yarn run db:migrate`.
9. Populate the database: `yarn run db:seed`.
10. Start the Node app: `yarn dev`.


#### Installing Postgres
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](https://brew.sh), and Linux users can use `apt`. Windows users will need to download the Postgres 17.6 installer，run the installer, and add the Postgres bin to the PATH environment variable.

#### Windows Build Instructions
1. Run the Windows Powershell as administrator.
2. Install build tools to compile [native Node modules](https://www.npmjs.com/package/windows-build-tools#examples-of-modules-supported): `npm install -g windows-build-tools`.
3. Rerun `npm install` in 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:8000
```
**Note**: For Windows users, `localhost` won't work&mdash;you'll need to set `RDS_HOST` to [the Docker Machine's IP address](https://docs.docker.com/machine/reference/ip/).

### Useful Commands
+ `docker-compose up -d` to configure and run any required services
+ `npm install` to install the necessary dependencies
+ `npm run dev` to run the Node app with [Nodemon](https://nodemon.io/) and [ts-node](https://github.com/TypeStrong/ts-node)
+ `npm run build` to compile the code to JavaScript
+ `npm run lint` to lint the Node app with [ESLint](https://eslint.org/) (without `--fix`)
+ `npm run lint:fix` to fix the simple linter issues automatically
+ `npm run test` to run the test suite with [Jest](https://jestjs.io/)
+ `npm run db:migrate` to run any new database migrations
+ `npm run db:rollback` to roll back the last database migration
+ `npm run db:seed` to populate the database with seeds
+ `npm run db:unseed` to completely clear the database
+ `docker 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`](https://github.com/acmucsd/membership-portal/blob/master/package.json) for the actual commands.

### Testing Information
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, `acm@ucsd.edu` can be used for the demo admin account, and any  seed email (e.g. `s3bansal@ucsd.edu`) 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 `acm_store@ucsd.edu`, as the majority of demo orders will be placed with this account.

Some tests may fail if your local PostgreSQL version differs from the CI environment (see .circleci/config.yml).
Try running tests with the Dockerized Postgres image.

### 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](https://github.com/acmucsd/membership-portal/pull/115).

#### API Breaks and Changes
+ `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 by `points?: number`
+ `GET /store/collection/:uuid`: `merchandise` has been renamed in the response body to `items`
+ `GET /store/merchandise`: deleted
+ passwordChange field is breaking change (see Auth/UserControllerRequests)
+ `POST /user/picture/:uuid`: the UUID parameter is optional
+ `GET /attendance/:uuid?`: the `attendance` field in the response body has been renamed `attendances`
+ `POST /attendance/attend`: no longer reachable, requests should be made to `/attendance`
+ merch store has been completely reworked

#### To Upgrade
1. Update the app to the latest release of the first iteration ([`v1-latest`](https://github.com/acmucsd/membership-portal/releases/tag/v1-latest)).
2. Manually run this SQL script ([`0000-sequelize-to-typeorm.sql`](https://github.com/acmucsd/membership-portal/blob/master/migrations/0000-sequelize-to-typeorm.sql)).
3. Update the app to the latest release ([latest](https://github.com/acmucsd/membership-portal/releases/latest)).

---
_Source: https://npm.io/package/@acmucsd/membership-portal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
