Skip to content

Commit

Permalink
Fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
carolynzhang18 committed May 22, 2024
1 parent c3f8ec2 commit 5149720
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 85 deletions.
47 changes: 6 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Extend-A-Family

## Stack Choices
**Frontend Language:** React
**Frontend Language:** React<br>
**Backend Language:** Node (Express)<br>
**Backend API:** REST<br>
**Database:** MongoDB<br>
Expand All @@ -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
```
Expand Down
5 changes: 2 additions & 3 deletions backend/typescript/rest/entityRoutes.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions backend/typescript/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = [
{
Expand Down Expand Up @@ -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<string, string> = {};
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);
});
});
});

0 comments on commit 5149720

Please sign in to comment.