[MediaWiki-commits] [Gerrit] marvin[master]: Chore: rename endpoint to module

2017-09-26 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/380661 )

Change subject: Chore: rename endpoint to module
..


Chore: rename endpoint to module

Rename `Endpoint` to `PageModule` and `endpoint` to `module` to more
closely model today's usage. Approximately:

  find src -type f|
  xargs -rd\\n sed -ri 's%Endpoint%Page^Cdule%g; s%endpoint%module%g'

For Route.endpoint(), rename to importModule() since that's what it
always does currently.

Change-Id: I5a4fcb746339275d3edf1aa3625d49de55a165f0
---
M src/common/routers/api.ts
M src/common/routers/route.ts
M src/common/routers/router.test.ts
M src/common/routers/router.ts
4 files changed, 25 insertions(+), 17 deletions(-)

Approvals:
  Jhernandez: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/common/routers/api.ts b/src/common/routers/api.ts
index f12bcec..873ae7c 100644
--- a/src/common/routers/api.ts
+++ b/src/common/routers/api.ts
@@ -4,26 +4,28 @@
 
 export const home: Route = newRoute({
   path: "/",
-  endpoint: () => import(/* webpackChunkName: "pages/home" */ "../pages/home"),
+  importModule: () =>
+import(/* webpackChunkName: "pages/home" */ "../pages/home"),
   chunkName: "pages/home"
 });
 
 export const about: Route = newRoute({
   path: "/about",
-  endpoint: () =>
+  importModule: () =>
 import(/* webpackChunkName: "pages/about" */ "../pages/about"),
   chunkName: "pages/about"
 });
 
 export const wiki: Route = newRoute({
   path: "/wiki/:title",
-  endpoint: () => import(/* webpackChunkName: "pages/wiki" */ "../pages/wiki"),
+  importModule: () =>
+import(/* webpackChunkName: "pages/wiki" */ "../pages/wiki"),
   chunkName: "pages/wiki"
 });
 
 export const styleGuide: Route = newRoute({
   path: "/dev/style-guide",
-  endpoint: () =>
+  importModule: () =>
 import(/* webpackChunkName: "pages/style-guide" */ "../pages/style-guide"),
   chunkName: "pages/style-guide"
 });
@@ -32,7 +34,7 @@
   // `(.*)` is the new `*`. See
   // https://github.com/pillarjs/path-to-regexp/issues/37.
   path: "(.*)",
-  endpoint: () =>
+  importModule: () =>
 import(/* webpackChunkName: "pages/not-found" */ "../pages/not-found"),
   chunkName: "pages/not-found",
   status: 404
diff --git a/src/common/routers/route.ts b/src/common/routers/route.ts
index c812356..639adcf 100644
--- a/src/common/routers/route.ts
+++ b/src/common/routers/route.ts
@@ -5,7 +5,13 @@
   [name: string]: string;
 }
 
-export interface Endpoint {
+/**
+ * A file that exposes a Preact UI component and optionally a function to
+ * request properties needed to construct the component. Modules within the
+ * pages/ subdirectory should implicitly implement this interface or typing 
will
+ * fail in routers/api.
+ */
+export interface PageModule {
   /** A Preact view component. */
   Component: AnyComponent;
 
@@ -18,7 +24,7 @@
 
 export interface RouteConfiguration {
   path: string;
-  endpoint: () => Promise>;
+  importModule: () => Promise>;
   chunkName: string;
   status?: number;
 }
@@ -35,12 +41,12 @@
 
 export const newRoute = ({
   path,
-  endpoint,
+  importModule,
   chunkName,
   status = 200
 }: RouteConfiguration): Route => ({
   path,
-  endpoint,
+  importModule,
   chunkName,
   status,
   url: pathToRegExp.compile(path)
diff --git a/src/common/routers/router.test.ts 
b/src/common/routers/router.test.ts
index 23d552e..865f7bf 100644
--- a/src/common/routers/router.test.ts
+++ b/src/common/routers/router.test.ts
@@ -9,7 +9,7 @@
 const routes = [
   newRoute({
 path: "/",
-endpoint: () => Promise.resolve(HomeModule),
+importModule: () => Promise.resolve(HomeModule),
 chunkName: "components/pages/home"
   })
 ];
diff --git a/src/common/routers/router.ts b/src/common/routers/router.ts
index 2446e10..2de064b 100644
--- a/src/common/routers/router.ts
+++ b/src/common/routers/router.ts
@@ -1,6 +1,6 @@
 import * as pathToRegExp from "path-to-regexp";
 import { AnyComponent } from "../components/preact-utils";
-import { AnyRoute, Endpoint, RouteParams } from "../../common/routers/route";
+import { AnyRoute, PageModule, RouteParams } from "../../common/routers/route";
 
 export interface RouteResponse {
   chunkName: string;
@@ -46,11 +46,11 @@
   );
 
 function requestInitialProps(
-  endpoint: Endpoint,
+  module: PageModule,
   params: RouteParams
 ): Promise {
-  if (endpoint.initialProps) {
-return endpoint.initialProps(params);
+  if (module.initialProps) {
+return module.initialProps(params);
   }
   return Promise.resolve({});
 }
@@ -60,11 +60,11 @@
   url: string,
   params: RouteParams
 ): Promise> =>
-  route.endpoint().then((endpoint: Endpoint) =>
-

[MediaWiki-commits] [Gerrit] marvin[master]: Chore: rename endpoint to module

2017-09-25 Thread Niedzielski (Code Review)
Niedzielski has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/380661 )

Change subject: Chore: rename endpoint to module
..

Chore: rename endpoint to module

Rename `Endpoint` to `PageModule` and `endpoint` to `module` to more
closely model today's usage. Approximately:

  find src -type f|
  xargs -rd\\n sed -ri 's%Endpoint%Page^Cdule%g; s%endpoint%module%g'

For Route.endpoint(), rename to importModule() since that's what it
always does currently.

Change-Id: I5a4fcb746339275d3edf1aa3625d49de55a165f0
---
M src/common/routers/api.ts
M src/common/routers/route.ts
M src/common/routers/router.test.ts
M src/common/routers/router.ts
4 files changed, 25 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/marvin refs/changes/61/380661/1

diff --git a/src/common/routers/api.ts b/src/common/routers/api.ts
index f12bcec..873ae7c 100644
--- a/src/common/routers/api.ts
+++ b/src/common/routers/api.ts
@@ -4,26 +4,28 @@
 
 export const home: Route = newRoute({
   path: "/",
-  endpoint: () => import(/* webpackChunkName: "pages/home" */ "../pages/home"),
+  importModule: () =>
+import(/* webpackChunkName: "pages/home" */ "../pages/home"),
   chunkName: "pages/home"
 });
 
 export const about: Route = newRoute({
   path: "/about",
-  endpoint: () =>
+  importModule: () =>
 import(/* webpackChunkName: "pages/about" */ "../pages/about"),
   chunkName: "pages/about"
 });
 
 export const wiki: Route = newRoute({
   path: "/wiki/:title",
-  endpoint: () => import(/* webpackChunkName: "pages/wiki" */ "../pages/wiki"),
+  importModule: () =>
+import(/* webpackChunkName: "pages/wiki" */ "../pages/wiki"),
   chunkName: "pages/wiki"
 });
 
 export const styleGuide: Route = newRoute({
   path: "/dev/style-guide",
-  endpoint: () =>
+  importModule: () =>
 import(/* webpackChunkName: "pages/style-guide" */ "../pages/style-guide"),
   chunkName: "pages/style-guide"
 });
@@ -32,7 +34,7 @@
   // `(.*)` is the new `*`. See
   // https://github.com/pillarjs/path-to-regexp/issues/37.
   path: "(.*)",
-  endpoint: () =>
+  importModule: () =>
 import(/* webpackChunkName: "pages/not-found" */ "../pages/not-found"),
   chunkName: "pages/not-found",
   status: 404
diff --git a/src/common/routers/route.ts b/src/common/routers/route.ts
index c812356..639adcf 100644
--- a/src/common/routers/route.ts
+++ b/src/common/routers/route.ts
@@ -5,7 +5,13 @@
   [name: string]: string;
 }
 
-export interface Endpoint {
+/**
+ * A file that exposes a Preact UI component and optionally a function to
+ * request properties needed to construct the component. Modules within the
+ * pages/ subdirectory should implicitly implement this interface or typing 
will
+ * fail in routers/api.
+ */
+export interface PageModule {
   /** A Preact view component. */
   Component: AnyComponent;
 
@@ -18,7 +24,7 @@
 
 export interface RouteConfiguration {
   path: string;
-  endpoint: () => Promise>;
+  importModule: () => Promise>;
   chunkName: string;
   status?: number;
 }
@@ -35,12 +41,12 @@
 
 export const newRoute = ({
   path,
-  endpoint,
+  importModule,
   chunkName,
   status = 200
 }: RouteConfiguration): Route => ({
   path,
-  endpoint,
+  importModule,
   chunkName,
   status,
   url: pathToRegExp.compile(path)
diff --git a/src/common/routers/router.test.ts 
b/src/common/routers/router.test.ts
index 23d552e..865f7bf 100644
--- a/src/common/routers/router.test.ts
+++ b/src/common/routers/router.test.ts
@@ -9,7 +9,7 @@
 const routes = [
   newRoute({
 path: "/",
-endpoint: () => Promise.resolve(HomeModule),
+importModule: () => Promise.resolve(HomeModule),
 chunkName: "components/pages/home"
   })
 ];
diff --git a/src/common/routers/router.ts b/src/common/routers/router.ts
index 2446e10..2de064b 100644
--- a/src/common/routers/router.ts
+++ b/src/common/routers/router.ts
@@ -1,6 +1,6 @@
 import * as pathToRegExp from "path-to-regexp";
 import { AnyComponent } from "../components/preact-utils";
-import { AnyRoute, Endpoint, RouteParams } from "../../common/routers/route";
+import { AnyRoute, PageModule, RouteParams } from "../../common/routers/route";
 
 export interface RouteResponse {
   chunkName: string;
@@ -46,11 +46,11 @@
   );
 
 function requestInitialProps(
-  endpoint: Endpoint,
+  module: PageModule,
   params: RouteParams
 ): Promise {
-  if (endpoint.initialProps) {
-return endpoint.initialProps(params);
+  if (module.initialProps) {
+return module.initialProps(params);
   }
   return Promise.resolve({});
 }
@@ -60,11 +60,11 @@
   url: string,
   params: RouteParams
 ): Promise> =>
-  route.endpoint().then((endpoint: Endpoint) =>
-