Skip to content

Commit

Permalink
[kiworkshop#22] Rename NextApp to NextApplication
Browse files Browse the repository at this point in the history
  • Loading branch information
myeongjae-kim committed Oct 27, 2019
1 parent c5762b2 commit 737c637
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions server/main/common/api/CommonController.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Request, Response } from "express";
import { inject } from "inversify";
import { controller, httpGet, interfaces, request, response } from "inversify-express-utils";
import { NextApp } from "server/main/common/nextjs/NextApp";
import { NextApplication } from "server/main/common/nextjs/NextApplication";

const PATH = "/"

@controller(PATH)
export class CommonController implements interfaces.Controller {

constructor(@inject("NextApp") private nextApp: NextApp) { }
constructor(@inject("NextApp") private nextApp: NextApplication) { }

@httpGet("/")
public get(
Expand Down
4 changes: 2 additions & 2 deletions server/main/common/inversify/createApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Optional from 'optional-js';
import I18NService from 'src/common/service/I18NService';
import "../../mother/notice/api/NoticeController";
import { defaultErrorHandler } from "../error/DefaultErrorHandler";
import { NextApp } from '../nextjs/NextApp';
import { NextApplication } from '../nextjs/NextApplication';

export const createApp = (container: Container, errorHandlers?: ErrorRequestHandler[]) => new InversifyExpressServer(container)
.setConfig((theApp) => {
Expand All @@ -23,7 +23,7 @@ export const createApp = (container: Container, errorHandlers?: ErrorRequestHand
Optional.ofNullable(errorHandlers)
.map(handlers => handlers.forEach(h => theApp.use(h)));

const handle = new NextApp().get().getRequestHandler();
const handle = new NextApplication().get().getRequestHandler();

theApp.use(defaultErrorHandler);
})
Expand Down
4 changes: 2 additions & 2 deletions server/main/common/inversify/createContainer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Container } from 'inversify';
import { NextApp } from '../nextjs/NextApp';
import { NextApplication } from '../nextjs/NextApplication';

import "../../common/api/CommonController";
import "../../mother/api/MotherController";
import "../../mother/notice/api/NoticeController";

export const createContainer = () => {
const container = new Container();
container.bind<NextApp>('NextApp').to(NextApp);
container.bind<NextApplication>('NextApp').to(NextApplication);
return container;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const APP = next({ dev: process.env.NODE_ENV !== 'production' });
const preparedApp = APP.prepare();

@injectable()
export class NextApp {
export class NextApplication {
public get() { return APP; }

public getPreparedApp() {
public run() {
return preparedApp;
}
}
6 changes: 3 additions & 3 deletions server/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import "reflect-metadata";

import { createApp } from "./common/inversify/createApp";
import { createContainer } from "./common/inversify/createContainer";
import { NextApp } from "./common/nextjs/NextApp";
import { NextApplication } from "./common/nextjs/NextApplication";
import { logger } from "./common/utils";
import { errorHandlers } from "./errorHandlers";

const PORT = 3000;

const nextApp = new NextApp();
const nextApp = new NextApplication();

nextApp.getPreparedApp().then(() => {
nextApp.run().then(() => {
createApp(createContainer(), errorHandlers).listen(PORT);
logger.log("info", `server is running on port:${PORT}`);
});
4 changes: 2 additions & 2 deletions server/main/mother/api/MotherController.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Request, Response } from "express";
import { inject } from "inversify";
import { controller, httpGet, interfaces, request, response } from "inversify-express-utils";
import { NextApp } from "server/main/common/nextjs/NextApp";
import { NextApplication } from "server/main/common/nextjs/NextApplication";

const PATH = "/mother"

@controller(PATH)
export class MotherController implements interfaces.Controller {

constructor(@inject("NextApp") private nextApp: NextApp) { }
constructor(@inject("NextApp") private nextApp: NextApplication) { }

@httpGet("/")
public get(
Expand Down
4 changes: 2 additions & 2 deletions server/main/mother/notice/api/NoticeController.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Request, Response } from "express";
import { inject } from "inversify";
import { controller, httpGet, interfaces, request, requestParam, response } from "inversify-express-utils";
import { NextApp } from "server/main/common/nextjs/NextApp";
import { NextApplication } from "server/main/common/nextjs/NextApplication";

const PATH = "/mother/notice";

@controller(PATH)
export class ImageController implements interfaces.Controller {

constructor(@inject("NextApp") private nextApp: NextApp) { }
constructor(@inject("NextApp") private nextApp: NextApplication) { }

@httpGet("/add")
public add(
Expand Down

0 comments on commit 737c637

Please sign in to comment.