Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update folder names to remove "v2" #687

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
node-version: 16
- uses: bahmutov/npm-install@v1
- run: yarn lint
run-api-v2-tests:
run-api-tests:
runs-on: ubuntu-latest
name: API V2 Tests
name: API Tests
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -26,7 +26,7 @@ jobs:
node-version: "16"
- run: yarn install --immutable
- name: Run Jest Tests
run: yarn packages/api-v2 test
run: yarn packages/api test
build-frontend-image:
runs-on: ubuntu-latest
steps:
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ GraduateNU aims to empower Northeastern students to customize their plan of stud

1. Make sure you run the dev postgres database using `yarn dev:db:up`. Run `yarn dev:db:down` when you're done.

2. Make a copy of the packages/api-v2/.env.development and name it .env.development.local. Fill in placeholder secrets.
2. Make a copy of the packages/api/.env.development and name it .env.development.local. Fill in placeholder secrets.

3. Make a copy of the packages/api-v2/.env.testing and name it .env.testing.local. for running BE tests
3. Make a copy of the packages/api/.env.testing and name it .env.testing.local. for running BE tests

4. If you haven't run migrations in a while or this is a fresh repo, then run the migrations for the the api using `yarn packages/api-v2 dev:migration:run`. See packages/API-V2/README for more info.
4. If you haven't run migrations in a while or this is a fresh repo, then run the migrations for the the api using `yarn packages/api dev:migration:run`. See packages/API/README for more info.

5. Then run the new version of the application by running `yarn dev:v2` at the root of the project. This starts up a NestJS server + a NextJS frontend + a Proxy. The proxy listens on port [3002](http://localhost:3002/), forwards /api requests to the NestJS server running on port 3001, and all other requests to the frontend running on port 3000.
5. Then run the new version of the application by running `yarn dev` at the root of the project. This starts up a NestJS server + a NextJS frontend + a Proxy. The proxy listens on port [3002](http://localhost:3002/), forwards /api requests to the NestJS server running on port 3001, and all other requests to the frontend running on port 3000.

6. Visit [http://localhost:3002](http://localhost:3002/) to view the app.

To run the two separately, visit the frontend and api-v2 packages(sub directories of the monorepo).
To run the two separately, visit the frontend and api packages(sub directories of the monorepo).

## Running the prod builds in prod docker configurations locally

Expand All @@ -43,9 +43,9 @@ Example: `yarn packages/frontend lint`

The workspaces within this monorepo are:

1. **frontend-v2**: A Next.js web UI. It is what users see when they visit our application.
1. **frontend**: A Next.js web UI. It is what users see when they visit our application.

2. **api-v2**: A Nest.js API reponsible for storing and managing Graduate's data. Our frontend leans on our api for data related services.
2. **api**: A Nest.js API reponsible for storing and managing Graduate's data. Our frontend leans on our api for data related services.

3. **api-client:** A typescript client responsible for providing a streamlined and typed interface to interact with our API. The frontend uses this client to send request to our API.

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/develop/docker-compose.api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
ports:
- 4001:3001
env_file:
- "../../packages/api-v2/.env.development"
- "../../packages/api/.env.development"
# env vars here override the env vars in the env_file above
environment:
# we are no longer connecting to the db on localhost, the host is the name of the container
Expand Down
12 changes: 6 additions & 6 deletions infrastructure/prod/Dockerfile.app
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ WORKDIR /app
# package.json of root and of needed packages
COPY package.json yarn.lock babel.config.js .yarnrc.yml ./
COPY .yarn .yarn
COPY packages/frontend-v2/package.json packages/frontend-v2/package.json
COPY packages/frontend/package.json packages/frontend/package.json
COPY packages/api-client/package.json packages/api-client/package.json
COPY packages/common/package.json packages/common/package.json

# Install at root level
RUN yarn install > /dev/null

# Get src files
COPY packages/frontend-v2 packages/frontend-v2
COPY packages/frontend packages/frontend
COPY packages/api-client packages/api-client
COPY packages/common packages/common

Expand All @@ -32,7 +32,7 @@ ENV NEXT_PUBLIC_BUILD_TIMESTAMP $BUILD_TIMESTAMP

RUN yarn packages/api-client build
RUN yarn packages/common build
RUN yarn packages/frontend-v2 build
RUN yarn packages/frontend build

# Production image
FROM node:16-alpine AS runner
Expand All @@ -44,9 +44,9 @@ RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nextjs:nodejs /app/packages/frontend-v2/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/packages/frontend-v2/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/packages/frontend-v2/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/packages/frontend/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/packages/frontend/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/packages/frontend/.next/static ./.next/static

USER nextjs

Expand Down
6 changes: 3 additions & 3 deletions infrastructure/prod/Dockerfile.server
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ WORKDIR /server
# package.json of root and of needed packages
COPY package.json yarn.lock babel.config.js .yarnrc.yml ./
COPY .yarn .yarn
COPY packages/api-v2/package.json packages/api-v2/package.json
COPY packages/api/package.json packages/api/package.json
COPY packages/common/package.json packages/common/package.json

# Install at root level
RUN yarn install > /dev/null

# Get src files
COPY packages/api-v2 packages/api-v2
COPY packages/api packages/api
COPY packages/common packages/common

# Build server and common dependency
RUN yarn packages/common build
RUN yarn packages/api-v2 build
RUN yarn packages/api build

FROM node:16-alpine AS runner
WORKDIR /server
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/prod/entrypoint.server.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

cd packages/api-v2
cd packages/api
echo "Running on commit: $COMMIT_HASH"
yarn typeorm migration:run
exec "$@"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
]
},
"scripts": {
"dev:v2": "concurrently \"yarn foreach '@graduate/(common|api-v2|frontend-v2|api-client)' run dev\" \"yarn dev:proxy\"",
"prod:v2": "concurrently \"yarn foreach '@graduate/(common|api-v2|frontend-v2|api-client)' run prod\" \"yarn dev:proxy\"",
"dev": "concurrently \"yarn foreach '@graduate/(common|api|frontend|api-client)' run dev\" \"yarn dev:proxy\"",
"prod": "concurrently \"yarn foreach '@graduate/(common|api|frontend|api-client)' run prod\" \"yarn dev:proxy\"",
"foreach": "yarn workspaces foreach --parallel --verbose --interlaced --include",
"dev:proxy": "node infrastructure/develop/dev-proxy.js",
"dev:db:up": "docker compose -f infrastructure/develop/docker-compose.db.yml up -d",
Expand Down
14 changes: 0 additions & 14 deletions packages/api-v2/migrations/1678404621776-EmailConfirmation.ts

This file was deleted.

16 changes: 0 additions & 16 deletions packages/api-v2/migrations/1680386712510-OptionalMajorInPlan.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/api-v2/README.md → packages/api/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# GraduateNU API V2
# GraduateNU API

## Running the API

1. Run `yarn dev:db:up` from the project root to run the database in docker. You can run `yarn dev:db:down` from the project root to take down the database when you're done.

2. Run `yarn dev` from within the api-v2 directory to run the server in watch mode.
2. Run `yarn dev` from within the api directory to run the server in watch mode.

## Testing

Expand Down
17 changes: 17 additions & 0 deletions packages/api/migrations/1678404621776-EmailConfirmation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class EmailConfirmation1678404621776 implements MigrationInterface {
name = "EmailConfirmation1678404621776";

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "student" ADD "isEmailConfirmed" boolean NOT NULL DEFAULT false`
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "student" DROP COLUMN "isEmailConfirmed"`
);
}
}
23 changes: 23 additions & 0 deletions packages/api/migrations/1680386712510-OptionalMajorInPlan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class OptionalMajorInPlan1680386712510 implements MigrationInterface {
name = "OptionalMajorInPlan1680386712510";

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "plan" ALTER COLUMN "major" DROP NOT NULL`
);
await queryRunner.query(
`ALTER TABLE "plan" ALTER COLUMN "catalogYear" DROP NOT NULL`
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "plan" ALTER COLUMN "catalogYear" SET NOT NULL`
);
await queryRunner.query(
`ALTER TABLE "plan" ALTER COLUMN "major" SET NOT NULL`
);
}
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/api-v2/package.json → packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@graduate/api-v2",
"name": "@graduate/api",
"version": "0.0.1",
"description": "",
"author": "",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ import {
weakPasswordError,
} from "@graduate/common";
import { Response } from "express";
import EmailConfirmationService from "../../src/emailConfirmation/emailConfirmation.service";
import EmailConfirmationService from "../emailConfirmation/emailConfirmation.service";
import {
EmailAlreadyExists,
EmailNotConfirmed,
NoSuchEmail,
WeakPassword,
} from "../../src/student/student.errors";
} from "../student/student.errors";
import { BadToken, InvalidPayload, TokenExpiredError } from "./auth.errors";
import { Throttle } from "@nestjs/throttler";
import { COOKIE_DOMAIN } from "../../src/constants";
import { COOKIE_DOMAIN } from "../constants";

@Controller("auth")
export class AuthController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { StudentModule } from "../student/student.module";
import { AuthController } from "./auth.controller";
import { AuthService } from "./auth.service";
import { JwtStrategy } from "./jwt.strategy";
import { EmailModule } from "../../src/email/email.module";
import { EmailModule } from "../email/email.module";

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { Injectable, Logger } from "@nestjs/common";
import { JwtService } from "@nestjs/jwt";
import { Student } from "../../src/student/entities/student.entity";
import { StudentService } from "../../src/student/student.service";
import { Student } from "../student/entities/student.entity";
import { StudentService } from "../student/student.service";
import {
LoginStudentDto,
ResetPasswordDto,
SignUpStudentDto,
} from "@graduate/common";
import { JwtPayload } from "./interfaces/jwt-payload";
import * as bcrypt from "bcrypt";
import { formatServiceCtx } from "../../src/utils";
import { formatServiceCtx } from "../utils";
import {
EmailAlreadyExists,
EmailNotConfirmed,
NoSuchEmail,
WeakPassword,
} from "../../src/student/student.errors";
} from "../student/student.errors";
import { ConfigService } from "@nestjs/config";
import { EnvironmentVariables } from "../../src/environment-variables";
import EmailService from "../../src/email/email.service";
import { EnvironmentVariables } from "../environment-variables";
import EmailService from "../email/email.service";
import { BadToken, InvalidPayload, TokenExpiredError } from "./auth.errors";

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Student } from "../../../src/student/entities/student.entity";
import { Student } from "../../student/entities/student.entity";

/** Represents an authenticated request using the JwtAuthGuard. */
export interface AuthenticatedRequest extends Request {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { ConfigService } from "@nestjs/config";
import { PassportStrategy } from "@nestjs/passport";
import { Request } from "express";
import { Strategy } from "passport-jwt";
import { EnvironmentVariables } from "../../src/environment-variables";
import { Student } from "../../src/student/entities/student.entity";
import { formatServiceCtx } from "../../src/utils";
import { EnvironmentVariables } from "../environment-variables";
import { Student } from "../student/entities/student.entity";
import { formatServiceCtx } from "../utils";
import { AuthService } from "./auth.service";
import { JwtPayload } from "./interfaces/jwt-payload";

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ConfigModule } from "@nestjs/config";
import EmailService from "./email.service";
import { JwtModule } from "@nestjs/jwt";
import EmailConfirmationService from "../emailConfirmation/emailConfirmation.service";
import { StudentModule } from "../../src/student/student.module";
import { EmailConfirmationController } from "../../src/emailConfirmation/emailConfirmation.controller";
import { StudentModule } from "../student/student.module";
import { EmailConfirmationController } from "../emailConfirmation/emailConfirmation.controller";

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { createTransport } from "nodemailer";
import Mail from "nodemailer/lib/mailer";
import { EnvironmentVariables } from "../../src/environment-variables";
import { EnvironmentVariables } from "../environment-variables";

@Injectable()
export default class EmailService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
emailAlreadyConfirmed,
unableToSendEmail,
} from "@graduate/common";
import { AuthenticatedRequest } from "../../src/auth/interfaces/authenticated-request";
import { JwtAuthGuard } from "../../src/guards/jwt-auth.guard";
import { AuthenticatedRequest } from "../auth/interfaces/authenticated-request";
import { JwtAuthGuard } from "../guards/jwt-auth.guard";
import EmailConfirmationService from "./emailConfirmation.service";
import {
EmailAlreadyConfirmed,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable, Logger } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { JwtService } from "@nestjs/jwt";
import { EnvironmentVariables } from "../../src/environment-variables";
import { StudentService } from "../../src/student/student.service";
import { EnvironmentVariables } from "../environment-variables";
import { StudentService } from "../student/student.service";
import { UpdateResult } from "typeorm";
import EmailService from "../email/email.service";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConsoleLogger, LogLevel } from "@nestjs/common";
import { deepFilter } from "../src/utils";
import { deepFilter } from "./utils";

const DENYLIST = ["password", "passwordConfirm"];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
UnauthorizedException,
Logger,
} from "@nestjs/common";
import { AuthenticatedRequest } from "../../src/auth/interfaces/authenticated-request";
import { formatServiceCtx } from "../../src/utils";
import { AuthenticatedRequest } from "../auth/interfaces/authenticated-request";
import { formatServiceCtx } from "../utils";

@Injectable()
export class EmailConfirmationGuard implements CanActivate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "@nestjs/common";
import { PlanService } from "../plan/plan.service";
import { Student } from "../student/entities/student.entity";
import { formatServiceCtx } from "../../src/utils";
import { formatServiceCtx } from "../utils";

/**
* Used to protect GET/PUT/PATCH :id Plan controller methods from being accessed
Expand Down
2 changes: 1 addition & 1 deletion packages/api-v2/src/main.ts → packages/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { NestFactory, Reflector } from "@nestjs/core";
import { GraduateLogger } from "../src/graduate-logger";
import { GraduateLogger } from "./graduate-logger";
import { AppModule } from "./app.module";
import { EnvironmentVariables } from "./environment-variables";
import * as cookieParser from "cookie-parser";
Expand Down
Loading