Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
04121c7
Manually added locations
Aug 3, 2025
259e8d1
cleaned up a bit
Aug 3, 2025
612d35f
latest
Aug 3, 2025
af470c8
seperated locations
Aug 3, 2025
5992b16
Merge pull request #187 from ScottyLabs/flex_only
cirex-web Aug 3, 2025
d15c0fe
Revert "Manually added off campus flex only locations"
laasyaaki Aug 3, 2025
6901972
Merge pull request #188 from ScottyLabs/revert-187-flex_only
laasyaaki Aug 3, 2025
12cbaf6
Revert "Manually added off campus flex only locations"
laasyaaki Aug 3, 2025
fd1d118
Merge branch 'staging' of https://github.com/ScottyLabs/dining-api in…
cirex-web Aug 4, 2025
b41a6eb
fix: coalesce intervals if gap is 1 min, and do wrap-around coalescin…
cirex-web Aug 11, 2025
510cd17
SQL dashboard phase 2 completed-basic ability to overread scrapes wit…
JackHurew Aug 12, 2025
e3437b9
Everyone Loves Drizzle
JackHurew Aug 16, 2025
e9ff386
feat: capital grains override
cirex-web Aug 22, 2025
1e4c2d0
chore: remove console.log
cirex-web Aug 22, 2025
9ad006d
fix: fix existing tests
cirex-web Aug 22, 2025
54fd9b2
tests: add tests for overwrites
cirex-web Aug 23, 2025
56b33b7
fix: notify when response date header becomes unparseable
cirex-web Aug 23, 2025
ee2dafb
Merge branch 'staging' of https://github.com/ScottyLabs/dining-api in…
cirex-web Aug 23, 2025
ff507be
Merge branch 'main' into staging
cirex-web Aug 26, 2025
9e27cb5
fix: tests
cirex-web Aug 26, 2025
e2e18ec
refactor: rework the entire parsing algorithm to better accomodate ti…
cirex-web Sep 5, 2025
b1ea9a9
chore: update time slot overwrite description
cirex-web Sep 5, 2025
63e016c
Dockerfile (Sorry this took so long)
JackHurew Sep 12, 2025
b6a710a
fix: change original Dockerfile to match Railway version, upd readme
cirex-web Sep 15, 2025
60ff9b5
feat: automatic db migrations, move overwrite logic directly under ap…
cirex-web Sep 16, 2025
ebb0ac2
chore: finalize migration from bun to pnpm
cirex-web Sep 20, 2025
563a80c
fix: dependabot
cirex-web Sep 20, 2025
91113db
Merge branch 'staging' into SQL_Dashboard
cirex-web Sep 20, 2025
53f1060
fix: env test file
cirex-web Sep 20, 2025
18c3256
Merge pull request #192 from ScottyLabs/SQL_Dashboard
cirex-web Sep 20, 2025
3f90658
chore: rename dockerfile
cirex-web Sep 20, 2025
3588c5b
fix: remove env variable reference
cirex-web Sep 20, 2025
58f284f
fix: prefix cache id with project id
cirex-web Sep 20, 2025
cb71bbf
fix: prefix cache id with project id
cirex-web Sep 20, 2025
baa893c
fix: prefix cache id with project id
cirex-web Sep 20, 2025
f3cfadf
chore: empty commit
cirex-web Sep 21, 2025
c196e80
Merge branch 'staging' into feat/time-overwrites
cirex-web Oct 4, 2025
4821b33
chore: fix cheerio element typechecking
cirex-web Oct 4, 2025
078a5eb
chore: add luxon types
cirex-web Oct 4, 2025
b39a02c
feat: complete database integration with overwriting any field (exclu…
cirex-web Nov 8, 2025
771a107
chore: remove time overwrites file
cirex-web Nov 8, 2025
ca24b72
tests: fix a good number of tests
cirex-web Nov 8, 2025
c8d7722
style: add empty openapi endpoint and pretty-print all json
cirex-web Nov 9, 2025
7f290e2
test: fix all tests
cirex-web Nov 9, 2025
10d12dd
fix: typecheck
cirex-web Nov 9, 2025
eac9ca6
chore: move from jest to vitest
cirex-web Nov 10, 2025
2d06aad
fix: tests
cirex-web Nov 10, 2025
fd00731
tests: add 2 mock db tests
cirex-web Nov 10, 2025
ac79f07
fix: give more startup time for tests
cirex-web Nov 10, 2025
2507234
test: run all tests
cirex-web Nov 10, 2025
cc1c3f6
tests: test on dst times and specials
cirex-web Nov 12, 2025
1bf7b1b
fix: make the 'today' param required for scrape result
cirex-web Nov 13, 2025
c5d45c9
test: parallel tests
cirex-web Nov 13, 2025
07ad8c4
test: run all tests
cirex-web Nov 13, 2025
f8d6878
test: make tests more readable
cirex-web Nov 13, 2025
687ed6f
test: add a few more tests
cirex-web Nov 13, 2025
e93638d
chore: rename variable
cirex-web Nov 13, 2025
4ecf5cb
chore: bundle writes into single transaction and add coverage reporting
cirex-web Nov 13, 2025
7f6d7ef
chore: uncomment reload function
cirex-web Nov 13, 2025
079587d
chore: upd readme
cirex-web Nov 13, 2025
4ac144b
Initial plan
Copilot Nov 13, 2025
76891b8
Refactor timestamps in database.test.ts to use timeToUnixTimestamp fu…
Copilot Nov 13, 2025
fdaa26e
chore: upd readme
cirex-web Nov 22, 2025
9f7901d
chore: add column names to some columns in the schema
cirex-web Nov 22, 2025
85bafd1
chore: remove redundant paren
cirex-web Nov 22, 2025
b9d747c
Merge pull request #213 from ScottyLabs/copilot/sub-pr-195-again
cirex-web Nov 22, 2025
8be7e44
test: add two more tests
cirex-web Nov 22, 2025
d9b38ef
chore: add additional today param check
cirex-web Nov 22, 2025
a40b010
fix: date timezone thing for tests
cirex-web Nov 22, 2025
30f44f8
Merge pull request #195 from ScottyLabs/feat/time-overwrites
cirex-web Nov 22, 2025
1252a57
Add /api/report-location endpoint
aalmuhan Dec 4, 2025
fca929a
Add bun.lock after installing dependencies for report-location feature
aalmuhan Dec 4, 2025
5dc9e40
Add location reports table and admin endpoint
sabualha Dec 4, 2025
256f658
Fix conceptId lookup in report-location endpoint and add tests
sabualha Dec 9, 2025
45bb6d0
Add migration for location_reports table
sabualha Dec 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# placeholder variables used for running tests
AXIOS_RETRY_INTERVAL_MS=0
IN_TEST_MODE=true
SLACK_BACKEND_WEBHOOK_URL=/
SLACK_FRONTEND_WEBHOOK_URL=/
DATABASE_URL=/
12 changes: 6 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
version: 2
updates:
# Enable version updates for npm
- package-ecosystem: 'npm'
- package-ecosystem: "npm"
# Look for `package.json` and `lock` files in the `root` directory
directory: '/'
directory: "/"
# Check the npm registry for updates every day (weekdays)
schedule:
interval: 'daily'
- package-ecosystem: 'github-actions'
directory: '/'
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: 'daily'
interval: "daily"
22 changes: 17 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [24]
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2 # Setup bun
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
bun-version: latest
- run: bun install
- name: Run bun test
run: bun run test
version: 10
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: run tests
run: pnpm test:coverage
- name: "Report Coverage"
uses: davelosert/vitest-coverage-report-action@v2
22 changes: 16 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
FROM oven/bun:latest
# this is the file that railway will run
FROM node:24-slim AS base
ENV PNPM_HOME="/pnpm"
# ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app

WORKDIR /runtime
COPY . /runtime
FROM base AS prod-deps
RUN --mount=type=cache,id=s/8ced5fd2-dd3a-4a6d-9429-f4bcf2553871-/pnpm/store,target=/pnpm/store pnpm install --prod --frozen-lockfile

RUN bun install
RUN bun run build
FROM base AS build
RUN --mount=type=cache,id=s/8ced5fd2-dd3a-4a6d-9429-f4bcf2553871-/pnpm/store,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
EXPOSE 5010
CMD bun run start
CMD ["sh","./run-pnpm.sh"]
12 changes: 12 additions & 0 deletions Dockerfile.pnpm.simple
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:24-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install
RUN pnpm run build

EXPOSE 5010
CMD ["sh","./run-pnpm.sh"]
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Dining API

> [!IMPORTANT]
> Make sure `bun` is on the latest version! (Earlier versions are rather buggy) Run `bun upgrade` to update.
This Dining API scrapes location data from the CMU dining sites and distributes it as a RESTful API. Access the API [here](https://dining.apis.scottylabs.org/).

This Dining API scrapes location data from the CMU dining sites and distributes it as a RESTful API. Access the API [here](https://apis.scottylabs.org/dining/).

To build and deploy the service, you'll need [Bun](https://bun.sh),
To build and deploy the service, you'll need [pnpm](https://pnpm.io/),
which you should install beforehand.

Then, clone this repository to your computer by running
Expand All @@ -27,24 +24,32 @@ If you already have the node_modules folder or package-lock.json from previous v
Now install the API's dependencies by 'cd'-ing into the root of the repository and running:

```
bun install
pnpm install
```

Then, you can run the server with `bun dev` and it should work! You can also use
`bun run dev` since `bun dev` is its shorthand version.
Start your local database with `pnpm db:start`, `pnpm db:push` (if this is your first time) and then start the server with `pnpm dev` and it should work, assuming you have the correct env variables. (To see the contents of the database, I recommend using DBeaver. You can also run `pnpm db:studio` to start up drizzle studio)

## Database schema changes (important!)

When you make changes to the database schema, be sure to run `pnpm db:push` to keep your local db in sync.

Note: To add new dependencies, use `bun add dependency-name`. To remove dependencies, use `bun remove dependency-name`. Run `bun outdated` to see what dependencies are outdated and `bun update` to update all outdated dependencies to the latest version.
Before merging your PR, be sure to run `pnpm db:generate` to generate a migration file, which will then be automatically applied to the staging and production databases when deployed. (You should do this before running tests as well!)

## Testing the Dockerfile
To test if the migration files work, you can run `pnpm run-prod`, which will spin up a production version of the server and a postgres database mounted on a new volume. The server is created using the same Dockerfile used in our Railway deployments, so if it works locally, it (probably) works in production as well.

Build: `docker build -f Dockerfile . -t dining`
Run the server: `docker run -p 127.0.0.1:5010:5010 dining`
Run bash inside it (for debugging): `docker run --rm -it --entrypoint bash -p 127.0.0.1:5010:5010 dining`
## Extra docker commands

Run bash inside it (for debugging): `docker run --rm -it --entrypoint bash dining-api-server`
Close dockerfile + delete volumes: `docker-compose down --volumes`

## Under the hood

We get the entire list of locations from `DINING_URL`, fetch location specifics under their corresponding `CONCEPT_BASE_LINK`, and retrieve soups and specials from `DINING_SOUPS_URL` and `DINING_SPECIALS_URL`, respectively. See the `process()` method in `diningParser.ts` for more details.

## Before submitting a PR

- Make sure all tests pass with `bun run test` or `bun run test --watch` for watch mode. (NOTE! `bun test` does something different and does NOT work!)
- Make sure all tests pass with `pnpm test` or `pnpm test --watch` for watch mode.

## Random notes

the "cheerio" package is pinned at version "1.0.0-rc.12" because newer versions seem to be incompatible with jest.
Loading