Skip to content

Commit

Permalink
fix(reverts): revert a few changes that caused issues (#45)
Browse files Browse the repository at this point in the history
* Revert "feat(app): rename app to server (#44)"

This reverts commit aa279f4.

* Revert "fix(generated): refactor generated files (#43)"

This reverts commit 533d838.
  • Loading branch information
goldcaddy77 authored Jan 26, 2019
1 parent aa279f4 commit 7c4eb90
Show file tree
Hide file tree
Showing 17 changed files with 135 additions and 263 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ export class UserResolver extends BaseResolver<User> {

import 'reflect-metadata';
import { Container } from 'typedi';
import { Server } from 'warthog';
import { App } from 'warthog';

async function bootstrap() {
const server = new Server({ container: Container });
return server.start();
const app = new App({ container: Container });
return app.start();
}

bootstrap()
Expand Down
6 changes: 3 additions & 3 deletions examples/1-simple-model/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { Container } from 'typedi';

dotenv.config();

import { Server } from '../../../src/';
import { App } from '../../../src/';

async function bootstrap() {
const server = new Server({
const app = new App({
container: Container,
warthogImportPath: '../../../src' // Path written in generated classes
});

return server.start();
return app.start();
}

bootstrap().catch((error: Error) => {
Expand Down
1 change: 0 additions & 1 deletion examples/2-complex-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"db:create": "createdbjs $(dotenv -p TYPEORM_DATABASE) 2>&1 || :",
"db:drop": "dropdbjs $(dotenv -p TYPEORM_DATABASE) 2>&1 || :",
"db:seed:dev": "dotenv -- ts-node tools/seed.ts",
"generate:code": "dotenv -- ts-node tools/generate.ts",
"lint": "tslint --fix -c ./tslint.json -p ./tsconfig.json",
"playground:open": "open http://localhost:$(dotenv -p APP_PORT)/playground",
"start": "yarn start:ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'reflect-metadata';

import { Container } from 'typedi';

import { BaseContext, Server } from '../../../src/';
import { App, BaseContext } from '../../../src/';

// import { User } from './modules/user/user.model';

Expand All @@ -14,8 +14,8 @@ interface Context extends BaseContext {
};
}

export function getServer(AppOptions = {}, dbOptions = {}) {
return new Server<Context>(
export function getApp(AppOptions = {}, dbOptions = {}) {
return new App<Context>(
{
container: Container,
// Inject a fake user. In a real app you'd parse a JWT to add the user
Expand Down
10 changes: 5 additions & 5 deletions examples/2-complex-example/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import 'reflect-metadata';

import { Binding } from '../generated/binding';

import { getApp } from './app';
import { User } from './modules/user/user.model';
import { getServer } from './server';

const server = getServer({}, { logging: false });
const app = getApp({}, { logging: false });
let binding: Binding;
let testUser: User;

beforeAll(async done => {
console.error = jest.fn();

await server.start();
binding = ((await server.getBinding()) as unknown) as Binding; // TODO: clean this up
await app.start();
binding = ((await app.getBinding()) as unknown) as Binding; // TODO: clean this up

const key = new Date().getTime();

Expand All @@ -34,7 +34,7 @@ beforeAll(async done => {

afterAll(async done => {
(console.error as any).mockRestore();
await server.stop();
await app.stop();
done();
});

Expand Down
6 changes: 3 additions & 3 deletions examples/2-complex-example/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import 'reflect-metadata';

import * as dotenv from 'dotenv';

import { getServer } from './server';
import { getApp } from './app';

dotenv.config();

async function bootstrap() {
const server = getServer();
await server.start();
const app = getApp();
await app.start();
}

bootstrap().catch((error: Error) => {
Expand Down
19 changes: 0 additions & 19 deletions examples/2-complex-example/tools/generate.ts

This file was deleted.

16 changes: 7 additions & 9 deletions examples/2-complex-example/tools/seed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Debug from 'debug';
import * as Faker from 'faker';

import { getServer } from '../src/server';
import { getApp } from '../src/app';

if (process.env.NODE_ENV !== 'development') {
throw 'Seeding only available in development environment';
Expand All @@ -12,10 +12,10 @@ const logger = Debug('warthog:seed');
const NUM_USERS = 100;

async function seedDatabase() {
const server = getServer();
await server.start();
const app = getApp();
await app.start();

const binding = await server.getBinding();
const binding = await app.getBinding();

for (let index = 0; index < NUM_USERS; index++) {
const random = new Date()
Expand All @@ -24,9 +24,7 @@ async function seedDatabase() {
.substring(8, 13);
const firstName = Faker.name.firstName();
const lastName = Faker.name.lastName();
const email = `${firstName
.substr(0, 1)
.toLowerCase()}${lastName.toLowerCase()}-${random}@fakeemail.com`;
const email = `${firstName.substr(0, 1).toLowerCase()}${lastName.toLowerCase()}-${random}@fakeemail.com`;

try {
const user = await binding.mutation.createUser(
Expand All @@ -45,7 +43,7 @@ async function seedDatabase() {
}
}

return server.stop();
return app.stop();
}

seedDatabase()
Expand All @@ -54,6 +52,6 @@ seedDatabase()
return process.exit(0);
})
.catch(err => {
console.log(err);
logger(err);
return process.exit(1);
});
Empty file.
8 changes: 4 additions & 4 deletions examples/3-one-to-many-relationship/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import * as dotenv from 'dotenv';
import 'reflect-metadata';
import * as dotenv from 'dotenv';
import { Container } from 'typedi';

dotenv.config();

import { Server } from '../../../src/';
import { App } from '../../../src/';

async function bootstrap() {
const server = new Server({
const app = new App({
container: Container,
warthogImportPath: '../../../src' // Path written in generated classes
});

await server.start();
await app.start();
}

bootstrap().catch((error: Error) => {
Expand Down
8 changes: 4 additions & 4 deletions examples/4-many-to-many-relationship/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import * as dotenv from 'dotenv';
import 'reflect-metadata';
import * as dotenv from 'dotenv';
import { Container } from 'typedi';

dotenv.config();

import { Server } from '../../../src/';
import { App } from '../../../src/';

async function bootstrap() {
const server = new Server({
const app = new App({
container: Container,
warthogImportPath: '../../../src' // Path written in generated classes
});

await server.start();
await app.start();
}

bootstrap().catch((error: Error) => {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
"pg": "^7.7.1",
"reflect-metadata": "^0.1.12",
"shortid": "^2.2.14",
"sqlite3": "^4.0.6",
"ts-node": "^7.0.1",
"type-graphql": "^0.16.0",
"typedi": "^0.8.0",
Expand Down
Loading

0 comments on commit 7c4eb90

Please sign in to comment.