Skip to content

Commit 4313fa0

Browse files
committed
remove remaining mocked data, wire in API
1 parent b278612 commit 4313fa0

File tree

18 files changed

+144
-1771
lines changed

18 files changed

+144
-1771
lines changed

config/apisix/apisix.yaml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ upstreams:
33
nodes:
44
"nginx:${{NGINX_PORT}}": 1
55
type: roundrobin
6+
- id: 2
7+
nodes:
8+
"192.168.1.50:8013": 1
9+
type: roundrobin
610

711
routes:
812
- id: 1
@@ -22,7 +26,9 @@ routes:
2226
ssl_verify: false
2327
session:
2428
secret: ${{APISIX_SESSION_SECRET_KEY}}
25-
cookie: { lifetime = 1209600 }
29+
cookie:
30+
lifetime: 1209600
31+
domain: ".c4103.com"
2632
logout_path: "/logout/oidc"
2733
post_logout_redirect_uri: ${{APISIX_LOGOUT_URL}}
2834
unauth_action: "pass"
@@ -53,7 +59,9 @@ routes:
5359
ssl_verify: false
5460
session:
5561
secret: ${{APISIX_SESSION_SECRET_KEY}}
56-
cookie: { lifetime = 1209600 }
62+
cookie:
63+
lifetime: 1209600
64+
domain: ".c4103.com"
5765
logout_path: "/logout/oidc"
5866
post_logout_redirect_uri: ${{APISIX_LOGOUT_URL}}
5967
unauth_action: "auth"
@@ -69,4 +77,33 @@ routes:
6977
uris:
7078
- "/admin/login/*"
7179
- "/login"
80+
- id: 3
81+
name: "mitxonline-wildcard"
82+
desc: "General route for the mitxonline application, includes user data if any."
83+
priority: 10
84+
upstream_id: 2
85+
plugins:
86+
openid-connect:
87+
client_id: ${{KEYCLOAK_CLIENT_ID}}
88+
client_secret: ${{KEYCLOAK_CLIENT_SECRET}}
89+
discovery: ${{KEYCLOAK_DISCOVERY_URL}}
90+
realm: ${{KEYCLOAK_REALM_NAME}}
91+
scope: "openid profile ol-profile"
92+
bearer_only: false
93+
introspection_endpoint_auth_method: "client_secret_post"
94+
ssl_verify: false
95+
session:
96+
secret: ${{APISIX_SESSION_SECRET_KEY}}
97+
cookie:
98+
lifetime: 1209600
99+
domain: ".c4103.com"
100+
logout_path: "/logout"
101+
post_logout_redirect_uri: ${{APISIX_LOGOUT_URL}}
102+
unauth_action: "pass"
103+
proxy-rewrite:
104+
regex_uri:
105+
- "/mitxonline/(.*)"
106+
- "/$1"
107+
uris:
108+
- "/mitxonline/*"
72109
#END

frontends/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"ol-test-utilities": "0.0.0"
3131
},
3232
"dependencies": {
33-
"@mitodl/mitxonline-api-axios": "^2025.5.6",
33+
"@mitodl/mitxonline-api-axios": "^2025.5.20",
3434
"@tanstack/react-query": "^5.66.0",
3535
"axios": "^1.6.3"
3636
}

frontends/api/src/mitxonline/clients.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import {
2+
B2bApi,
23
CoursesApi,
34
EnrollmentsApi,
45
ProgramsApi,
6+
UsersApi,
57
} from "@mitodl/mitxonline-api-axios/v1"
68
import axios from "axios"
79

810
const axiosInstance = axios.create({
9-
baseURL: "https://mitxonline.c4103.com/",
11+
baseURL: process.env.NEXT_PUBLIC_MITXONLINE_API_BASE_URL,
1012
xsrfCookieName: process.env.NEXT_PUBLIC_CSRF_COOKIE_NAME,
1113
xsrfHeaderName: "X-CSRFToken",
1214
withXSRFToken: true,
@@ -17,8 +19,17 @@ const axiosInstance = axios.create({
1719
const BASE_PATH =
1820
process.env.NEXT_PUBLIC_MITXONLINE_API_BASE_URL?.replace(/\/+$/, "") ?? ""
1921

22+
const usersApi = new UsersApi(undefined, BASE_PATH, axiosInstance)
23+
const b2bApi = new B2bApi(undefined, BASE_PATH, axiosInstance)
2024
const enrollmentsApi = new EnrollmentsApi(undefined, BASE_PATH, axiosInstance)
2125
const programsApi = new ProgramsApi(undefined, BASE_PATH, axiosInstance)
2226
const coursesApi = new CoursesApi(undefined, BASE_PATH, axiosInstance)
2327

24-
export { enrollmentsApi, programsApi, coursesApi, axiosInstance }
28+
export {
29+
usersApi,
30+
b2bApi,
31+
enrollmentsApi,
32+
programsApi,
33+
coursesApi,
34+
axiosInstance,
35+
}

frontends/api/src/mitxonline/hooks/courses/data.ts

Lines changed: 0 additions & 87 deletions
This file was deleted.

frontends/api/src/mitxonline/hooks/courses/queries.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import type {
55
} from "@mitodl/mitxonline-api-axios/v1"
66
import { coursesApi } from "../../clients"
77

8-
// import * as data from "./data"
9-
108
const coursesKeys = {
119
root: ["mitxonline", "courses"],
1210
coursesList: (opts?: CoursesApiApiV2CoursesListRequest) => [
@@ -22,30 +20,6 @@ const coursesQueries = {
2220
queryKey: coursesKeys.coursesList(opts),
2321
queryFn: async (): Promise<PaginatedCourseWithCourseRunsList> => {
2422
return coursesApi.apiV2CoursesList(opts).then((res) => res.data)
25-
26-
// if (process.env.NODE_ENV === "test") {
27-
// /**
28-
// * For now, only use the API client during tests so we
29-
// * can mock it the way we normally do.
30-
// */
31-
// return coursesApi.apiV2CoursesList(opts).then((res) => res.data)
32-
// }
33-
// const ids = opts?.id ?? []
34-
// const courses =
35-
// ids.length === 0
36-
// ? data.universalAiCourses
37-
// : data.universalAiCourses.filter((c) => ids.includes(c.id))
38-
// if (courses.length === 0) {
39-
// console.error("No mock courses matching the given ids found.", {
40-
// ids,
41-
// })
42-
// }
43-
// return {
44-
// count: courses.length,
45-
// next: null,
46-
// previous: null,
47-
// results: courses,
48-
// }
4923
},
5024
}),
5125
}

0 commit comments

Comments
 (0)