Skip to content

Commit

Permalink
feat: Automatically generate API clients from Swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
mathhulk committed Aug 13, 2024
1 parent f32abb7 commit c67806c
Show file tree
Hide file tree
Showing 13 changed files with 5,598 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ build/docker-compose.yml
config.statuspage.json
*.cert
*.key
dist/
db/
mdb.archive
bt_seed.sql
Expand Down
1 change: 0 additions & 1 deletion apps/backend/src/bootstrap/loaders/mongoose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ process.on("SIGINT", async () => {

// Your Mongoose setup goes here
export default async (): Promise<mongoose.Mongoose> => {
console.log(config.mongoDB.uri);
return mongoose.connect(config.mongoDB.uri);
};
2 changes: 0 additions & 2 deletions apps/backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export interface Config {
redisUri: string;
}

console.log(env("MONGODB_URI"));

// All your secrets, keys go here
export const config: Config = {
port: +env("PORT"),
Expand Down
1 change: 1 addition & 0 deletions apps/datapuller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@repo/common": "*",
"@repo/sis-api": "*",
"dotenv": "^16.4.5",
"tslog": "^4.9.3"
}
Expand Down
37 changes: 31 additions & 6 deletions apps/datapuller/src/course.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
import { TermModel } from "@repo/common";
import { ClassesAPI } from "@repo/sis-api/classes";
import { CoursesAPI } from "@repo/sis-api/courses";
import { TermsAPI } from "@repo/sis-api/terms";

import setup from "./shared";

const SIS_COURSE_URL = "https://gateway.api.berkeley.edu/sis/v4/courses";

async function main() {
const { log } = setup();

// 1. pull from MongoDB for active semesters
// 2. pull from SIS API for courses for each active semester
// 3. dump into R2 json file mapping semester to courses
// Terms API example
const termsAPI = new TermsAPI();

await termsAPI.v2.getByTermsUsingGet(
{
"temporal-position": "Current",
},
{
headers: {
app_id: "123",
app_key: "abc",
},
}
);

// Courses API example
const coursesAPI = new CoursesAPI();

await coursesAPI.v4.findCourseCollectionUsingGet({
"last-updated-since": "2021-01-01",
});

// Classes API example
const classesAPI = new ClassesAPI();

await classesAPI.v1.getClassesUsingGet({
"term-id": "123",
});

log.info(SIS_COURSE_URL);
log.info(TermModel);
}

Expand Down
Loading

0 comments on commit c67806c

Please sign in to comment.