This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "reflect-metadata"; | |
import express = require("express"); | |
import { config as setupDotEnv } from "dotenv"; | |
import { | |
createConnection, | |
Connection, | |
Repository, | |
ConnectionOptions | |
} from "typeorm"; | |
import { Card, Category } from "./entity"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Card } from "../entity"; | |
import { CardInput, CardsUpdatedResponse } from "../generated/graphql"; | |
import { ApolloContext } from "../types/context"; | |
import { DataSource, DataSourceConfig } from "apollo-datasource"; | |
import { DataSourceRepos } from "../"; | |
export class CardAPI extends DataSource { | |
context!: ApolloContext; | |
repos: DataSourceRepos; | |
constructor({ repos }: { repos: DataSourceRepos }) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { CardAPI } from "../card"; | |
import { mockRepos, mockContext } from "../../__tests__/__utils"; | |
import { | |
mockCardsResponse, | |
mockFirstCardResponse, | |
mockFirstCardResponseId, | |
mockReturnCard, | |
mockCardInput, | |
mockSuccessfulAddResponse, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createTestClient } from "apollo-server-testing"; | |
import gql from "graphql-tag"; | |
import { | |
constructTestServer, | |
createTestingConnection, | |
Connection | |
} from "./__utils"; | |
import { | |
mockFirstCardResponse, | |
mockFirstCardResponseId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
GraphQLRequest, | |
Observable, | |
FetchResult, | |
toPromise | |
} from "apollo-link"; | |
import { | |
startTestServer, | |
constructTestServer, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Node Server Test CI | |
on: | |
push: | |
paths: | |
- 'server/**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NODE_ENV=development | |
NODE_HOST=localhost | |
NODE_PORT=4000 | |
NODE_HTTPS=false | |
POSTGRES_HOST=localhost | |
POSTGRES_PORT=5432 | |
POSTGRES_USER=test | |
POSTGRES_PASSWORD=test | |
PGADMIN_DEFAULT_EMAIL=name@domain.com | |
PGADMIN_DEFAULT_PASSWORD=yourpassword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -u | |
function create_user_and_database() { | |
local database=$1 | |
echo " Creating user and database '$database'" | |
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL | |
CREATE USER $database; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.1' | |
services: | |
postgres: | |
image: 'postgres' | |
ports: | |
- '5432:5432' | |
volumes: | |
- ./pg-init-scripts:/docker-entrypoint-initdb.d | |
environment: | |
POSTGRES_MULTIPLE_DATABASES: brainstrike,brainstrike_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createTestingConnection } from "./index"; | |
module.exports = async (): Promise<void> => { | |
// code goes here | |
const connection = await createTestingConnection(); | |
await connection.dropDatabase(); | |
console.log("dropped test db"); | |
await connection.synchronize(true); | |
console.log("sync test db"); | |
await connection.runMigrations(); |
OlderNewer