Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions db/generator/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'reflect-metadata';
import { createConnection } from 'typeorm';

(async () => {
const connection = await createConnection();

console.log('Connected');

await connection.close();
})();
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class ModifyUCR1595425069646 implements MigrationInterface {
name = 'ModifyUCR1595425069646';
export class Cleanups1596383400404 implements MigrationInterface {
name = 'Cleanups1596383400404';

public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "id" SERIAL NOT NULL`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_d4726976f7c0d644f1a01cebe6d"`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_41033d3ee61995e854787fc7230" PRIMARY KEY ("user_id", "chapter_id", "role_name", "id")`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "updated_at" TIMESTAMP NOT NULL DEFAULT now()`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "interested" boolean NOT NULL`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_41033d3ee61995e854787fc7230"`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_9daf4841d7ac950bb3c511ad5f2" PRIMARY KEY ("user_id", "chapter_id", "id")`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "role_name"`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "role_name" text NOT NULL`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_9daf4841d7ac950bb3c511ad5f2"`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_41033d3ee61995e854787fc7230" PRIMARY KEY ("user_id", "chapter_id", "id", "role_name")`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP CONSTRAINT "PK_a6668338a373b7a8d914a193f3f"`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD CONSTRAINT "PK_f6aa9d1d5bffdd18382d18729d0" PRIMARY KEY ("user_id")`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP COLUMN "role_name"`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD "role_name" text NOT NULL`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP CONSTRAINT "PK_f6aa9d1d5bffdd18382d18729d0"`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD CONSTRAINT "PK_a6668338a373b7a8d914a193f3f" PRIMARY KEY ("user_id", "role_name")`, undefined);
await queryRunner.query(`ALTER TABLE "rsvps" ALTER COLUMN "canceled" DROP DEFAULT`, undefined);
await queryRunner.query(`ALTER TABLE "rsvps" ALTER COLUMN "interested" DROP DEFAULT`, undefined);
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "id" SERIAL NOT NULL`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_d4726976f7c0d644f1a01cebe6d"`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_41033d3ee61995e854787fc7230" PRIMARY KEY ("user_id", "chapter_id", "role_name", "id")`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "updated_at" TIMESTAMP NOT NULL DEFAULT now()`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "interested" boolean NOT NULL`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_41033d3ee61995e854787fc7230"`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_9daf4841d7ac950bb3c511ad5f2" PRIMARY KEY ("user_id", "chapter_id", "id")`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "role_name"`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "role_name" text NOT NULL`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_9daf4841d7ac950bb3c511ad5f2"`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_41033d3ee61995e854787fc7230" PRIMARY KEY ("user_id", "chapter_id", "id", "role_name")`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP CONSTRAINT "PK_a6668338a373b7a8d914a193f3f"`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD CONSTRAINT "PK_f6aa9d1d5bffdd18382d18729d0" PRIMARY KEY ("user_id")`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP COLUMN "role_name"`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD "role_name" text NOT NULL`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP CONSTRAINT "PK_f6aa9d1d5bffdd18382d18729d0"`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD CONSTRAINT "PK_a6668338a373b7a8d914a193f3f" PRIMARY KEY ("user_id", "role_name")`);
await queryRunner.query(`ALTER TABLE "rsvps" ALTER COLUMN "canceled" DROP DEFAULT`);
await queryRunner.query(`ALTER TABLE "rsvps" ALTER COLUMN "interested" DROP DEFAULT`);
}

public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE "rsvps" ALTER COLUMN "interested" SET DEFAULT true`, undefined);
await queryRunner.query(`ALTER TABLE "rsvps" ALTER COLUMN "canceled" SET DEFAULT false`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP CONSTRAINT "PK_a6668338a373b7a8d914a193f3f"`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD CONSTRAINT "PK_f6aa9d1d5bffdd18382d18729d0" PRIMARY KEY ("user_id")`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP COLUMN "role_name"`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD "role_name" character varying NOT NULL`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP CONSTRAINT "PK_f6aa9d1d5bffdd18382d18729d0"`, undefined);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD CONSTRAINT "PK_a6668338a373b7a8d914a193f3f" PRIMARY KEY ("user_id", "role_name")`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_41033d3ee61995e854787fc7230"`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_9daf4841d7ac950bb3c511ad5f2" PRIMARY KEY ("user_id", "chapter_id", "id")`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "role_name"`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "role_name" character varying NOT NULL`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_9daf4841d7ac950bb3c511ad5f2"`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_41033d3ee61995e854787fc7230" PRIMARY KEY ("user_id", "chapter_id", "role_name", "id")`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "interested"`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "updated_at"`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "created_at"`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_41033d3ee61995e854787fc7230"`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_d4726976f7c0d644f1a01cebe6d" PRIMARY KEY ("user_id", "chapter_id", "role_name")`, undefined);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "id"`, undefined);
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "rsvps" ALTER COLUMN "interested" SET DEFAULT true`);
await queryRunner.query(`ALTER TABLE "rsvps" ALTER COLUMN "canceled" SET DEFAULT false`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP CONSTRAINT "PK_a6668338a373b7a8d914a193f3f"`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD CONSTRAINT "PK_f6aa9d1d5bffdd18382d18729d0" PRIMARY KEY ("user_id")`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP COLUMN "role_name"`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD "role_name" character varying NOT NULL`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" DROP CONSTRAINT "PK_f6aa9d1d5bffdd18382d18729d0"`);
await queryRunner.query(`ALTER TABLE "user_instance_roles" ADD CONSTRAINT "PK_a6668338a373b7a8d914a193f3f" PRIMARY KEY ("user_id", "role_name")`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_41033d3ee61995e854787fc7230"`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_9daf4841d7ac950bb3c511ad5f2" PRIMARY KEY ("user_id", "chapter_id", "id")`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "role_name"`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD "role_name" character varying NOT NULL`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_9daf4841d7ac950bb3c511ad5f2"`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_41033d3ee61995e854787fc7230" PRIMARY KEY ("user_id", "chapter_id", "role_name", "id")`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "interested"`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "updated_at"`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "created_at"`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP CONSTRAINT "PK_41033d3ee61995e854787fc7230"`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" ADD CONSTRAINT "PK_d4726976f7c0d644f1a01cebe6d" PRIMARY KEY ("user_id", "chapter_id", "role_name")`);
await queryRunner.query(`ALTER TABLE "user_chapter_roles" DROP COLUMN "id"`);
}
}
6 changes: 2 additions & 4 deletions ormconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ module.exports = {
synchronize: false,
logging: false,
entities: ['server/models/**/*.ts'],
factories: ['server/factories/**/*.factory.ts'],
migrations: ['server/migrations/**/*.ts'],
seeds: ['server/seeds/**/*.seed.ts'],
migrations: ['db/migrations/**/*.ts'],
subscribers: ['src/subscriber/**/*.ts'],
cli: {
entitiesDir: 'server/models',
migrationsDir: 'server/migrations',
migrationsDir: 'db/migrations',
subscribersDir: 'server/subscriber',
},
};
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
"doc": "docs"
},
"scripts": {
"dev:server": "ts-node --files --transpile-only --project ./tsconfig.server.json -r tsconfig-paths/register ./server/index.ts",
"dev": "cross-env TSC_WATCHFILE=UseFsEventsWithFallbackDynamicPolling npx nodemon --watch 'server/**/*.ts' --exec 'npm run dev:server'",
"lint": "eslint './**/*.{ts,tsx,js,jsx}'",
"lint:fix": "eslint './**/*.{ts,tsx,js,jsx}' --fix",
"next:build": "next build",
"nodemon": "npx nodemon",
"typeorm": "ts-node -P tsconfig.server.json -r tsconfig-paths/register node_modules/typeorm/cli.js",
"pretty": "prettier --write client/**/*.ts* server/**/*.ts",
"prod:server": "NODE_ENV=production ts-node --files --transpile-only -r tsconfig-paths/register ./server/index.ts",
"seed": "ts-node -P tsconfig.server.json -r tsconfig-paths/register ./node_modules/typeorm-seeding/dist/cli.js seed --config ormconfig.js",
"start": "npm run prod:server",
"dev": "ts-node-dev --no-notify -P tsconfig.server.json ./server/app.ts",
"typeorm": "ts-node -P tsconfig.server.json ./node_modules/.bin/typeorm",
"db:generate": "yarn typeorm migration:generate -n",
"db:drop": "yarn typeorm schema:drop",
"db:seed": "ts-node ./db/generator/index.ts",
"db:migrate": "yarn typeorm migration:run",
"db:reset": "yarn db:drop && yarn db:migrate && yarn db:seed",
"start": "ts-node -P tsconfig.server.json ./server/app.ts",
"test": "npx jest --coverage --verbose",
"test:watch": "npx jest --watchAll",
"postinstall": "node scripts/postInstall.js"
"postinstall": "node scripts/postInstall.js",
"lint": "eslint './**/*.{ts,tsx,js,jsx}'",
"lint:fix": "eslint './**/*.{ts,tsx,js,jsx}' --fix",
"pretty": "prettier --write client/**/*.ts* server/**/*.ts"
},
"repository": {
"type": "git",
Expand Down
25 changes: 20 additions & 5 deletions server/app.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import 'reflect-metadata';
import express from 'express';
import cors from 'cors';
import { config } from 'dotenv';
import { Request, Response } from 'express';
import { createConnection } from 'typeorm';
import { ApolloServer } from 'apollo-server-express';
import { buildSchema } from 'type-graphql';
import isDocker from 'is-docker';

config();

import { resolvers } from './controllers';
import { IGQLCtx } from './ts/gql';
import { initDB } from './db';

// Make sure to kill the app if using non docker-compose setup and docker-compose
if (isDocker() && process.env.IS_DOCKER === '') {
console.error(
'\n\n\nUSING LOCAL DB BUT RUNNING IN DOCKER WILL CAUSE IT TO USE DOCKER-COMPOSE DB INSTEAD OF LOCAL',
);
console.error("npm run typeorm WON'T WORK PROPERLY\n\n\n");
process.exit(1);
}

const PORT = process.env.PORT || 4000;

async function main() {
await createConnection();
await initDB();
const app = express();

app.use(cors({ credentials: true, origin: true }));
Expand All @@ -26,10 +41,10 @@ async function main() {
}),
});

server.applyMiddleware({ app, cors: false });
server.applyMiddleware({ app, cors: false, path: '/graphql' });

app.listen(4000, () => {
console.log('Listening on http://localhost:4000/graphql');
app.listen(PORT, () => {
console.log(`Listening on http://localhost:${PORT}/graphql`);
});
}

Expand Down
49 changes: 0 additions & 49 deletions server/index.ts

This file was deleted.

21 changes: 0 additions & 21 deletions server/migrations/1575817257608-SocialProvider.ts

This file was deleted.

27 changes: 0 additions & 27 deletions server/migrations/1575819370018-SocialProviderUser.ts

This file was deleted.

This file was deleted.

Loading