Skip to content

Commit

Permalink
merge refactor and get server to compile again
Browse files Browse the repository at this point in the history
  • Loading branch information
Essential Randomness committed Oct 22, 2023
2 parents 2addde9 + 6e2bbd7 commit dab1c8c
Show file tree
Hide file tree
Showing 45 changed files with 156 additions and 451 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
command: ls -la
- run:
name: stop everything
command: docker-compose -f docker-compose.test.yml down
command: docker-compose -f .docker/docker-compose.test.yml down
- run:
name: run test
command: docker-compose -f docker-compose.test.yml run --rm test
command: docker-compose -f .docker/docker-compose.test.yml run --rm test
- run:
name: database logs
command: docker-compose logs database
Expand All @@ -47,10 +47,10 @@ jobs:
command: ls -la
- run:
name: stop everything
command: docker-compose -f docker-compose.open-api.test.yml down
command: docker-compose -f .docker/docker-compose.open-api.test.yml down
- run:
name: run test
command: docker-compose -f docker-compose.open-api.test.yml run --rm test
command: docker-compose -f .docker/docker-compose.open-api.test.yml run --rm test

workflows:
build-and-test:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ services:
test:
image: "bobaserver"
build:
context: .
context: ..
dockerfile: ./.docker/Dockerfile
environment:
TZ: "America/Los_Angeles"
command: yarn run open-api:validate
volumes:
- .:/usr/src/app
- ..:/usr/src/app
# Below line prevents Docker from mapping the host's node_modules/
# folder into the container. We don't want cross-contamination.
- /usr/src/app/node_modules
11 changes: 6 additions & 5 deletions docker-compose.test.yml → .docker/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@ services:
database:
image: "postgres:12"
env_file:
- .env
- ../.env
ports:
- "35432:5432"
volumes:
- ./db:/docker-entrypoint-initdb.d
- ../db:/docker-entrypoint-initdb.d
environment:
TZ: "America/Los_Angeles"
test:
image: "bobaserver"
network_mode: "host"
build:
context: .
context: ..
dockerfile: ./.docker/Dockerfile
environment:
TZ: "America/Los_Angeles"
JEST_JUNIT_OUTPUT_DIR: ./reports/junit/
JEST_JUNIT_OUTPUT_DIR: ../reports/junit/
command: >
sh -c "/usr/src/git/wait-for-it/wait-for-it.sh 127.0.0.1:35432 -t 60 -- sleep 10 && \
yarn run test --ci --testNamePattern='^((?!ci\-disable).)*$$' --reporters=default --reporters=jest-junit && \
yarn run test --ci --testNamePattern='^ci\-disable.*$$' --reporters=default --reporters=jest-junit"
volumes:
- .:/usr/src/app
- ..:/usr/src/app
# Below line prevents Docker from mapping the host's node_modules/
# folder into the container. We don't want cross-contamination.
- /usr/src/app/node_modules
Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yml → .docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ services:
database:
image: "postgres:12"
env_file:
- .env
- ../.env
ports:
- "35432:5432"
volumes:
# - database-data:/var/lib/postgresql/data/ # persist data even if container shuts down
- ./db:/docker-entrypoint-initdb.d
- ../db:/docker-entrypoint-initdb.d
cache:
image: "redis"
ports:
- "6379:6379"
volumes:
- ./cache:/docker-entrypoint-initdb.d
2 changes: 2 additions & 0 deletions queries.sql → db/extra/queries.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- A set of queries usually run manually since we don't have API endpoints for them yet --

--- DELETE BOARD ---
drop index boards_string_id;
DELETE FROM comments WHERE id IN (SELECT id FROM comments WHERE comments.parent_thread IN (SELECT id FROM threads WHERE parent_board = 3));
Expand Down
File renamed without changes.
133 changes: 0 additions & 133 deletions db_identitites_dump_pre_2020_halloween.sql

This file was deleted.

Binary file removed documentation/db_er_diagram.png
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion handlers/errors.ts → handlers/api-errors/handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextFunction, Request, Response } from "express";

import { ApiError } from "types/errors/api";
import { ApiError } from "handlers/api-errors/codes";
import { ZodError } from "zod";
import debug from "debug";

Expand Down
2 changes: 1 addition & 1 deletion handlers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CacheKeys, cache } from "server/cache";
import { NextFunction, Request, Response } from "express";
import firebaseAuth, { auth } from "firebase-admin";

import { Internal500Error } from "types/errors/api";
import { Internal500Error } from "handlers/api-errors/codes";
import { SettingEntry } from "../types/settings";
import debug from "debug";
import { getUserSettings } from "server/users/queries";
Expand Down
4 changes: 2 additions & 2 deletions handlers/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
} from "server/threads/queries";

import { BoardByExternalId } from "server/boards/sql/types";
import { Internal500Error } from "types/errors/api";
import { ZodDbThreadType } from "zodtypes";
import { Internal500Error } from "handlers/api-errors/codes";
import { ZodDbThreadType } from "types/db/schemas";
import { getBoardByExternalId } from "server/boards/queries";
import { getPostByExternalId } from "server/posts/queries";

Expand Down
6 changes: 0 additions & 6 deletions nodemon.json

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"main": "dist/server/index.js",
"scripts": {
"build": "yarn run server:build",
"db:start": "docker compose down && docker compose up",
"db:start": "docker compose -f .docker/docker-compose.yml down && docker compose -p boba-db -f .docker/docker-compose.yml up",
"deploy": "gcloud config set project bobaboard && gcloud app deploy --version live",
"dev": "yarn run db:start & yarn run server:dev",
"dev:watch": "node -e \"console.error('This command has been deprecated. Use server:dev now.')\"",
"open-api:docker": "docker compose -f docker-compose.open-api.test.yml run --rm test",
"open-api:docker": "docker compose -f .docker/docker-compose.open-api.test.yml -p boba-open-api-validate run --rm test",
"open-api:generate": "node -r dotenv/config -r ts-node/register -r tsconfig-paths/register utils/generate-spec-file.ts dotenv_config_path=./.env.prod",
"open-api:typescript": "yarn run open-api:generate && openapi-zod-client ./open-api-spec.json -o ./types/open-api/generated/schemas.ts --export-schemas --template ./types/open-api/generated/schemas.hbs --with-alias && openapi-zod-client ./open-api-spec.json -o ./types/open-api/generated/types.ts --export-schemas --template ./types/open-api/generated/types.hbs --with-alias",
"open-api:validate": "yarn run open-api:generate && validate-api open-api-spec.json && openapi-examples-validator open-api-spec.json --ignore-formats color quill-delta && openapi lint open-api-spec.json --skip-rule=no-ambiguous-paths",
Expand All @@ -31,7 +31,7 @@
"test": "cross-env DEBUG=bobaserver:*,-*info jest --runInBand --no-cache",
"test:changed": "yarn run test --watch",
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand --no-cache",
"test:docker": "docker compose down && docker compose -f docker-compose.test.yml run --rm test",
"test:docker": "docker compose -f .docker/docker-compose.test.yml down && docker compose -p boba-server-test -f .docker/docker-compose.test.yml run --rm test",
"test:watch": "yarn run test --watchAll"
},
"dependencies": {
Expand Down
Loading

0 comments on commit dab1c8c

Please sign in to comment.