From 514972005e81b2a9789a7b9d7b32f4cf7dc43772 Mon Sep 17 00:00:00 2001 From: Carolyn Zhang Date: Wed, 22 May 2024 02:41:43 -0400 Subject: [PATCH] Fix errors --- README.md | 47 +++---------------- backend/typescript/rest/entityRoutes.ts | 5 +- backend/typescript/server.ts | 4 +- .../__tests__/userService.test.ts | 40 +--------------- 4 files changed, 11 insertions(+), 85 deletions(-) diff --git a/README.md b/README.md index 6089bcb..07099b6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Extend-A-Family ## Stack Choices -**Frontend Language:** React +**Frontend Language:** React
**Backend Language:** Node (Express)
**Backend API:** REST
**Database:** MongoDB
@@ -11,61 +11,26 @@ ## Table of Contents * πŸ“ [Documentation](#documentation) * ❗❗ [Reporting Issues](#reporting-issues) -* πŸ‘¨β€πŸ’» [Getting Started: Users](#getting-started-users) -* πŸ‘· [Getting Started: Internal Tools Developers](#getting-started-internal-tools-developers) - * βœ”οΈ [Prerequisites](#prerequisites) - * βš™οΈ [Set up](#set-up) +* βš™οΈ [Set up](#set-up) * πŸš€ [Creating a Release](#creating-a-release) * 🧰 [Useful Commands](#useful-commands) * ℹ️ [Get Names & Statuses of Running Containers](#get-names--statuses-of-running-containers) * ✨ [Linting & Formatting](#linting--formatting) * πŸ§ͺ [Running Tests](#running-tests) -* ✍️ [Updating Documentation](#updating-documentation) * 🌳 [Version Control Guide](#version-control-guide) * 🌿 [Branching](#branching) * πŸ”’ [Commits](#commits) -## Documentation - -https://uwblueprint.github.io/starter-code-v2 - - -## Reporting Issues - -You can open an issue in this GitHub repository, or message the #internal-tools-help channel in UW Blueprint’s Slack workspace. - - -## Getting Started: Users - -Please follow the instructions in this [guide](https://uwblueprint.github.io/starter-code-v2/docs/getting-started) to generate and set up Starter Code. Starter Code must be preprocessed through the [`create-bp-app`](https://www.npmjs.com/package/@uwblueprint/create-bp-app) CLI tool before being used, so **please do not clone and run this repository directly**. - --- -## Getting Started: Internal Tools Developers - -### Prerequisites - -* Install Docker Desktop ([MacOS](https://docs.docker.com/docker-for-mac/install/) | [Windows (Home)](https://docs.docker.com/docker-for-windows/install-windows-home/) | [Windows (Pro, Enterprise, Education)](https://docs.docker.com/docker-for-windows/install/) | [Linux](https://docs.docker.com/engine/install/#server)) and ensure that it is running -```bash -# these commands should give error-free output -docker info -docker-compose --version -``` -* Ask a member of the Internal Tools team to be added to our Firebase and MongoDB Atlas projects -* Set up Vault client for secret management, see instructions [here](https://www.notion.so/uwblueprintexecs/Secret-Management-2d5b59ef0987415e93ec951ce05bf03e) - - -### Set up +## Set up 1. Clone this repository and `cd` into the project folder ```bash -git clone https://github.com/uwblueprint/starter-code-v2.git -cd starter-code-v2 +git clone https://github.com/uwblueprint/extend-a-family.gitt +cd extend-a-family ``` -2. Comment out one of the backend services in `docker-compose.yml` -3. Follow through our [public docs](https://uwblueprint.github.io/starter-code-v2/docs/getting-started) -4. In the root `.env` file, change the name of the MongoDB database according to the backend you're using: either `typescript-test` or `python-test` -5. Run the application +2. Run the application ```bash docker-compose up --build ``` diff --git a/backend/typescript/rest/entityRoutes.ts b/backend/typescript/rest/entityRoutes.ts index 4e54dce..2283a38 100644 --- a/backend/typescript/rest/entityRoutes.ts +++ b/backend/typescript/rest/entityRoutes.ts @@ -1,8 +1,7 @@ import { Router } from "express"; import fs from "fs"; import multer from "multer"; -// import EntityServiceMg from "../services/implementations/EntityServiceMg"; -import EntityServicePg from "../services/implementations/EntityServicePg"; +import EntityServiceMg from "../services/implementations/EntityServiceMg"; import { isAuthorizedByRole } from "../middlewares/auth"; import { EntityResponseDTO, @@ -23,7 +22,7 @@ const defaultBucket = process.env.FIREBASE_STORAGE_DEFAULT_BUCKET || ""; const fileStorageService: IFileStorageService = new FileStorageService( defaultBucket, ); -const entityService: IEntityService = new EntityServicePg(fileStorageService); +const entityService: IEntityService = new EntityServiceMg(fileStorageService); /* Create entity */ entityRouter.post( diff --git a/backend/typescript/server.ts b/backend/typescript/server.ts index 990cf3d..29761e2 100644 --- a/backend/typescript/server.ts +++ b/backend/typescript/server.ts @@ -6,7 +6,7 @@ import * as firebaseAdmin from "firebase-admin"; import swaggerUi from "swagger-ui-express"; import YAML from "yamljs"; -import { mongo, sequelize } from "./models"; +import { mongo } from "./models"; import authRouter from "./rest/authRoutes"; import entityRouter from "./rest/entityRoutes"; import userRouter from "./rest/userRoutes"; @@ -41,7 +41,7 @@ app.use(cookieParser()); app.use(cors(CORS_OPTIONS)); app.use(express.json()); app.use(express.urlencoded({ extended: true })); -// app.use(limiter); +app.use(limiter); app.use("/auth", authRouter); app.use("/entities", entityRouter); diff --git a/backend/typescript/services/implementations/__tests__/userService.test.ts b/backend/typescript/services/implementations/__tests__/userService.test.ts index ed0478b..308042d 100644 --- a/backend/typescript/services/implementations/__tests__/userService.test.ts +++ b/backend/typescript/services/implementations/__tests__/userService.test.ts @@ -1,13 +1,9 @@ -import { snakeCase } from "lodash"; - import MgUser from "../../../models/user.mgmodel"; -import PgUser from "../../../models/user.pgmodel"; import UserService from "../userService"; -import UserServicePg from "../userServicepg"; import { UserDTO } from "../../../types"; -import db, { testSql } from "../../../testUtils/testDb"; +import db from "../../../testUtils/testDb"; const testUsers = [ { @@ -62,37 +58,3 @@ describe("mongo userService", (): void => { }); }); }); - -describe("pg userService", () => { - let userService: UserServicePg; - - beforeEach(async () => { - await testSql.sync({ force: true }); - userService = new UserServicePg(); - }); - - afterAll(async () => { - await testSql.sync({ force: true }); - await testSql.close(); - }); - - it("getUsers", async () => { - const users = testUsers.map((user) => { - const userSnakeCase: Record = {}; - Object.entries(user).forEach(([key, value]) => { - userSnakeCase[snakeCase(key)] = value; - }); - return userSnakeCase; - }); - - await PgUser.bulkCreate(users); - - const res = await userService.getUsers(); - - res.forEach((user: UserDTO, i) => { - expect(user.firstName).toEqual(testUsers[i].firstName); - expect(user.lastName).toEqual(testUsers[i].lastName); - expect(user.role).toEqual(testUsers[i].role); - }); - }); -});