Skip to content

Commit

Permalink
refactor: use nx
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrastopoulos committed Aug 27, 2024
1 parent 93ea82e commit be6eb66
Show file tree
Hide file tree
Showing 104 changed files with 122 additions and 28,436 deletions.
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@
# Local Netlify folder
.netlify

node_modules/
node_modules/


.nx/cache
.nx/workspace-data

# Next.js
.next
out
File renamed without changes.
File renamed without changes.
20 changes: 7 additions & 13 deletions backend/package.json → apps/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
{
"name": "course-tool-backend",
"version": "1.0.0",
"description": "",
"main": "src/app.ts",
"name": "@cmucourses/backend",
"type": "module",
"scripts": {
"start": "npm run serve",
"dev": "tsx src/app.ts",
"build": "tsc",
"serve": "node build/app.js",
"start": "bun run start",
"dev": "dotenv -e ../.env -- bun --watch src/app.ts",
"build": "bun build ./src/app.ts --target=bun --outdir=build",
"format": "prettier --write . --ignore-path .gitignore",
"lint": "./node_modules/.bin/eslint ./src/**"
},
"author": "",
"license": "ISC",
"dependencies": {
"@cmucourses/db": "workspace:*",
"axios": "^0.27.1",
"cors": "^2.8.5",
"express": "^4.18.0",
Expand All @@ -30,8 +25,7 @@
"@types/morgan": "^1.9.5",
"@types/node": "^18.15.3",
"@types/node-cron": "^3.0.7",
"eslint-config-prettier": "^8.7.0",
"nodemon": "^2.0.15",
"tsx": "^4.18.0"
"bun": "^1.1.26",
"eslint-config-prettier": "^8.7.0"
}
}
1 change: 0 additions & 1 deletion backend/src/app.ts → apps/backend/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "dotenv/config";
import morgan from "morgan";
import express, { ErrorRequestHandler } from "express";
import cors from "cors";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import {
standardizeID,
} from "~/util";
import { RequestHandler } from "express";
import prisma from "~/models/prisma";
import { Prisma } from "@prisma/client";
import db, { Prisma } from "@cmucourses/db";

const projection = { _id: false, __v: false };
const MAX_LIMIT = 10;
Expand All @@ -21,7 +20,7 @@ export interface GetCourseById {
query: {
schedules?: BoolLiteral;
};
resBody: PrismaReturn<typeof prisma.courses.findFirstOrThrow>;
resBody: PrismaReturn<typeof db.courses.findFirstOrThrow>;
reqBody: unknown;
}

Expand All @@ -33,7 +32,7 @@ export const getCourseByID: RequestHandler<
> = async (req, res, next) => {
const id = standardizeID(req.params.courseID);
try {
const course = await prisma.courses.findFirstOrThrow({
const course = await db.courses.findFirstOrThrow({
where: {
courseID: id,
},
Expand All @@ -50,7 +49,7 @@ export const getCourseByID: RequestHandler<

export interface GetCourses {
params: unknown;
resBody: PrismaReturn<typeof prisma.courses.findMany>;
resBody: PrismaReturn<typeof db.courses.findMany>;
reqBody: unknown;
query: {
courseID: SingleOrArray<string>;
Expand All @@ -67,7 +66,7 @@ export const getCourses: RequestHandler<
const courseIDs = singleToArray(req.query.courseID).map(standardizeID);

try {
const courses = await prisma.courses.findMany({
const courses = await db.courses.findMany({
where: {
courseID: { in: courseIDs },
},
Expand Down Expand Up @@ -216,7 +215,7 @@ export const getFilteredCourses: RequestHandler<
});

try {
const result = (await prisma.courses.aggregateRaw({ pipeline }))[0] as unknown as GetFilteredCoursesResult;
const result = (await db.courses.aggregateRaw({ pipeline }))[0] as unknown as GetFilteredCoursesResult;
const totalDocs = result.metadata[0]?.totalDocs ?? 0;

res.json({
Expand Down Expand Up @@ -247,7 +246,7 @@ const getAllCoursesDbQuery = {

export interface GetAllCourses {
params: unknown;
resBody: PrismaReturn<typeof prisma.courses.findMany<typeof getAllCoursesDbQuery>>;
resBody: PrismaReturn<typeof db.courses.findMany<typeof getAllCoursesDbQuery>>;
reqBody: unknown;
query: unknown;
}
Expand All @@ -260,7 +259,7 @@ export const getAllCourses: RequestHandler<
> = async (req, res, next) => {
if (new Date().valueOf() - allCoursesEntry.lastCached.valueOf() > 1000 * 60 * 60 * 24) {
try {
const courses = await prisma.courses.findMany(getAllCoursesDbQuery);
const courses = await db.courses.findMany(getAllCoursesDbQuery);

allCoursesEntry.lastCached = new Date();
allCoursesEntry.allCourses = courses;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ElemType, exclude, PrismaReturn, singleToArray, standardizeID } from "~/util";
import { RequestHandler } from "express";
import prisma from "~/models/prisma";
import db from "@cmucourses/db";

type fce = ElemType<PrismaReturn<typeof prisma.fces.findMany>>;
type fce = ElemType<PrismaReturn<typeof db.fces.findMany>>;

export interface GetFces {
params: unknown;
Expand All @@ -21,7 +21,7 @@ export const getFCEs: RequestHandler<
const courseIDs = singleToArray(req.query.courseID).map(standardizeID);

try {
const results = await prisma.fces.findMany({
const results = await db.fces.findMany({
where: {
courseID: { in: courseIDs },
},
Expand All @@ -36,7 +36,7 @@ export const getFCEs: RequestHandler<
} else {
const instructor = req.query.instructor;
try {
const results = await prisma.fces.findMany({
const results = await db.fces.findMany({
where: {
instructor,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RequestHandler } from "express";
import { PrismaReturn } from "~/util";
import prisma from "~/models/prisma";
import prisma from "@cmucourses/db";

const getAllInstructorsDbQuery = {
select: {
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions backend/tsconfig.json → apps/backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"moduleResolution": "Bundler",
"noEmit": true,

"experimentalDecorators": true,
"emitDecoratorMetadata": true,

"outDir": "./build",

"baseUrl": ".",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions frontend/package.json → apps/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@cmucourses/frontend",
"private": true,
"scripts": {
"dev": "next dev -p 3010",
"build": "next build",
"start": "next start",
"dev": "nx next:dev -p 3010",
"build": "nx next:build",
"start": "nx next:start",
"type-check": "tsc",
"test": "jest",
"lint": "next lint",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import PulseLoader from "react-spinners/PulseLoader";
import PulseLoader from "react-spinners/PulseLoader.js";

import resolveConfig from "tailwindcss/resolveConfig";
import resolveConfig from "tailwindcss/resolveConfig.js";
import tailwindConfig from "../../tailwind.config.js";
import { useAppSelector } from "../app/hooks";
import { useAppSelector } from "../app/hooks.js";

/* eslint-disable-next-line */
const fullConfig: any = resolveConfig(tailwindConfig);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions backend/nodemon.json

This file was deleted.

Loading

0 comments on commit be6eb66

Please sign in to comment.