Skip to content

Commit

Permalink
Rename all .mjs files to .js
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesshore committed Feb 21, 2023
1 parent e98373f commit ad4dcfc
Show file tree
Hide file tree
Showing 58 changed files with 175 additions and 175 deletions.
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,22 @@ The source code is in the `src/` directory. Test files start with an underscore
* [_smoke_test.js](src/_smoke_test.js): End-to-end smoke test for both servers.
* **[node_modules/](src/node_modules): Code shared by both servers (*not* third-party code)**
* **[http/](src/node_modules/http): HTTP infrastructure wrappers**
* [generic_router.js](src/node_modules/http/generic_router.mjs) [(tests)](src/node_modules/http/_generic_router_test.js) A utility for converting [HttpRequest](src/node_modules/http/http_request.mjs)s to method calls.
* [http_client.js](src/node_modules/http/http_client.mjs) [(tests)](src/node_modules/http/_http_client_test.js): Makes HTTP requests.
* [http_request.js](src/node_modules/http/http_request.mjs) [(tests)](src/node_modules/http/_http_request_test.js): Server-side HTTP request received from the client.
* [http_response.js](src/node_modules/http/http_response.mjs) [(tests)](src/node_modules/http/_http_response_test.js): Server-side HTTP response to be sent to the client.
* [http_server.js](src/node_modules/http/http_server.mjs) [(tests)](src/node_modules/http/_http_server_test.js): An HTTP server.
* [generic_router.js](src/node_modules/http/generic_router.js) [(tests)](src/node_modules/http/_generic_router_test.js) A utility for converting [HttpRequest](src/node_modules/http/http_request.js)s to method calls.
* [http_client.js](src/node_modules/http/http_client.js) [(tests)](src/node_modules/http/_http_client_test.js): Makes HTTP requests.
* [http_request.js](src/node_modules/http/http_request.js) [(tests)](src/node_modules/http/_http_request_test.js): Server-side HTTP request received from the client.
* [http_response.js](src/node_modules/http/http_response.js) [(tests)](src/node_modules/http/_http_response_test.js): Server-side HTTP response to be sent to the client.
* [http_server.js](src/node_modules/http/http_server.js) [(tests)](src/node_modules/http/_http_server_test.js): An HTTP server.
* **[infrastructure/](src/node_modules/infrastructure): Other shared infrastructure wrappers**
* [clock.js](src/node_modules/infrastructure/clock.mjs) [(tests)](src/node_modules/infrastructure/_clock_test.js): Current time, timeouts, etc.
* [command_line.js](src/node_modules/infrastructure/command_line.mjs) [(tests)](src/node_modules/infrastructure/_command_line_test.js): Command-line I/O.
* [log.js](src/node_modules/infrastructure/log.mjs) [(tests)](src/node_modules/infrastructure/_log_test.js): Logger.
* [clock.js](src/node_modules/infrastructure/clock.js) [(tests)](src/node_modules/infrastructure/_clock_test.js): Current time, timeouts, etc.
* [command_line.js](src/node_modules/infrastructure/command_line.js) [(tests)](src/node_modules/infrastructure/_command_line_test.js): Command-line I/O.
* [log.js](src/node_modules/infrastructure/log.js) [(tests)](src/node_modules/infrastructure/_log_test.js): Logger.
* **[util/](src/node_modules/util): Miscellaneous libraries**
* [assert.js](src/node_modules/util/assert.mjs) [(tests)](/src/node_modules/util/_assert_test.js): Assertion library used by tests.
* [configurable_responses.js](src/node_modules/util/configurable_responses.mjs) [(tests)](/src/node_modules/util/_configurable_responses_test.js): Utility library for implementing [Configurable Responses](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#configurable-responses) pattern.
* [ensure.js](src/node_modules/util/ensure.mjs) [(tests)](src/node_modules/util/_ensure_test.js): Runtime assertions for production code. Most notably used for runtime type checking of method signatures.
* [output_tracker.js](src/node_modules/util/output_tracker.mjs) [(tests)](/src/node_modules/util/_output_tracker_test.js): Utility library for implementing [Output Tracking](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#output-tracking) pattern.
* [test_helper.js](src/node_modules/util/test_helper.mjs): Utility library for implementing integration tests.
* [type.js](src/node_modules/util/type.mjs) [(tests)](/src/node_modules/util/_type_test.js): Runtime type checker.
* [assert.js](src/node_modules/util/assert.js) [(tests)](/src/node_modules/util/_assert_test.js): Assertion library used by tests.
* [configurable_responses.js](src/node_modules/util/configurable_responses.js) [(tests)](/src/node_modules/util/_configurable_responses_test.js): Utility library for implementing [Configurable Responses](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#configurable-responses) pattern.
* [ensure.js](src/node_modules/util/ensure.js) [(tests)](src/node_modules/util/_ensure_test.js): Runtime assertions for production code. Most notably used for runtime type checking of method signatures.
* [output_tracker.js](src/node_modules/util/output_tracker.js) [(tests)](/src/node_modules/util/_output_tracker_test.js): Utility library for implementing [Output Tracking](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#output-tracking) pattern.
* [test_helper.js](src/node_modules/util/test_helper.js): Utility library for implementing integration tests.
* [type.js](src/node_modules/util/type.js) [(tests)](/src/node_modules/util/_type_test.js): Runtime type checker.
* **[rot13_service/](src/rot13_service): ROT-13 microservice**
* [rot13_controller.js](src/rot13_service/rot13_controller.js) [(tests)](/src/rot13_service/_rot13_controller_test.js): Controller for `/rot13/transform` endpoint.
* [rot13_logic.js](src/rot13_service/rot13_logic.js) [(tests)](src/rot13_service/_rot13_logic_test.js): ROT-13 encoder.
Expand All @@ -152,7 +152,7 @@ The source code is in the `src/` directory. Test files start with an underscore

Third-party modules are in the top-level `node_modules/` directory (not to be confused with `src/node_modules`). The following modules are used by the production code:

* `@sinonjs/fake-timers`: Used to make [Clock](src/node_modules/infrastructure/clock.mjs) Nullable.
* `@sinonjs/fake-timers`: Used to make [Clock](src/node_modules/infrastructure/clock.js) Nullable.
* `uuid`: Wrapped by [UuidGenerator](src/www/infrastructure/uuid_generator.js), which is used to create correlation IDs.

The remaining modules are used by the build and tests:
Expand Down Expand Up @@ -226,20 +226,20 @@ The code is infrastructure-heavy, with almost no logic, so the A-Frame Architect
=======
* The *Logic* layer is represented by [Rot13Logic](src/rot13_service/rot13_logic.js) and [Rot13View](src/rot13_service/rot13_view.cjs).
>>>>>>> Stashed changes
* The *Infrastructure* layer is represented by [HttpServer](src/node_modules/http/http_server.mjs), [HttpRequest](src/node_modules/http/http_request.mjs), and [HttpResponse](src/node_modules/http/http_response.mjs).
* The *Infrastructure* layer is represented by [HttpServer](src/node_modules/http/http_server.js), [HttpRequest](src/node_modules/http/http_request.js), and [HttpResponse](src/node_modules/http/http_response.js).
* There is no *Values* layer.

#### [Logic Sandwich](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#logic-sandwich)

<<<<<<< Updated upstream
[Rot13Controller.postAsync()](src/rot13_service/rot13_controller.js) is a Logic Sandwich. It reads data from the [HttpRequest](src/node_modules/http/http_request.mjs), calls [Rot13Logic](src/rot13_service/rot13_logic.cjs), renders it with [Rot13View](src/rot13_service/rot13_view.js), and then writes data by returning a [HttpResponse](src/node_modules/http/http_response.mjs) (which is then served by [HttpServer](src/node_modules/http/http_server.mjs)).
[Rot13Controller.postAsync()](src/rot13_service/rot13_controller.js) is a Logic Sandwich. It reads data from the [HttpRequest](src/node_modules/http/http_request.js), calls [Rot13Logic](src/rot13_service/rot13_logic.cjs), renders it with [Rot13View](src/rot13_service/rot13_view.js), and then writes data by returning a [HttpResponse](src/node_modules/http/http_response.js) (which is then served by [HttpServer](src/node_modules/http/http_server.js)).
=======
[Rot13Controller.postAsync()](src/rot13_service/rot13_controller.js) is a Logic Sandwich. It reads data from the [HttpRequest](src/node_modules/http/http_request.mjs), calls [Rot13Logic](src/rot13_service/rot13_logic.js), renders it with [Rot13View](src/rot13_service/rot13_view.cjs), and then writes data by returning a [HttpResponse](src/node_modules/http/http_response.mjs) (which is then served by [HttpServer](src/node_modules/http/http_server.mjs)).
[Rot13Controller.postAsync()](src/rot13_service/rot13_controller.js) is a Logic Sandwich. It reads data from the [HttpRequest](src/node_modules/http/http_request.js), calls [Rot13Logic](src/rot13_service/rot13_logic.js), renders it with [Rot13View](src/rot13_service/rot13_view.cjs), and then writes data by returning a [HttpResponse](src/node_modules/http/http_response.js) (which is then served by [HttpServer](src/node_modules/http/http_server.js)).
>>>>>>> Stashed changes
#### [Traffic Cop](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#traffic-cop)

The [WwwRouter](src/www/www_router.js) and [Rot13Router](src/rot13_service/rot13_router.js) routers are traffic cops. They receive events from the [HttpServer](src/node_modules/http/http_server.mjs) via their `routeAsync()` methods, then turn around and call the appropriate methods on [HomePageController](src/www/home_page/home_page_controller.js) and [Rot13Controller](src/rot13_service/rot13_controller.js). However, because the pattern is spread across multiple classes, it's not very clear in the code.
The [WwwRouter](src/www/www_router.js) and [Rot13Router](src/rot13_service/rot13_router.js) routers are traffic cops. They receive events from the [HttpServer](src/node_modules/http/http_server.js) via their `routeAsync()` methods, then turn around and call the appropriate methods on [HomePageController](src/www/home_page/home_page_controller.js) and [Rot13Controller](src/rot13_service/rot13_controller.js). However, because the pattern is spread across multiple classes, it's not very clear in the code.

#### [Grow Evolutionary Seeds](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#grow-seeds)

Expand All @@ -261,7 +261,7 @@ This program doesn’t use any third-party logic libraries.

#### [Infrastructure Wrappers](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#infrastructure-wrappers)

There are many infrastructure wrappers. [HttpClient](src/node_modules/http/http_client.mjs), [HttpServer](src/node_modules/http/http_server.mjs), [HttpRequest](src/node_modules/http/http_request.mjs), [Clock](src/node_modules/infrastructure/clock.mjs), [CommandLine](src/node_modules/infrastructure/command_line.mjs), and [UuidGenerator](src/www/infrastructure/uuid_generator.js) are all low-level infrastructure wrappers. [Log](src/node_modules/infrastructure/log.mjs) and [Rot13Client](src/www/infrastructure/rot13_client.js) are high-level infrastructure wrappers. (Log uses CommandLine; Rot13Client uses HttpClient.)
There are many infrastructure wrappers. [HttpClient](src/node_modules/http/http_client.js), [HttpServer](src/node_modules/http/http_server.js), [HttpRequest](src/node_modules/http/http_request.js), [Clock](src/node_modules/infrastructure/clock.js), [CommandLine](src/node_modules/infrastructure/command_line.js), and [UuidGenerator](src/www/infrastructure/uuid_generator.js) are all low-level infrastructure wrappers. [Log](src/node_modules/infrastructure/log.js) and [Rot13Client](src/www/infrastructure/rot13_client.js) are high-level infrastructure wrappers. (Log uses CommandLine; Rot13Client uses HttpClient.)

#### [Narrow Integration Tests](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#narrow-integration-tests)

Expand All @@ -288,19 +288,19 @@ The code is written in JavaScript, so thin wrappers aren't needed.

#### [Configurable Responses](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#configurable-responses)

Most of the infrastructure wrappers (listed above) have configurable responses. [UuidGenerator](src/www/infrastructure/uuid_generator.js) and [HttpClient](src/node_modules/http/http_client.mjs) in particular support multiple different responses.
Most of the infrastructure wrappers (listed above) have configurable responses. [UuidGenerator](src/www/infrastructure/uuid_generator.js) and [HttpClient](src/node_modules/http/http_client.js) in particular support multiple different responses.

#### [Output Tracking](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#output-tracking)

Several classes support output tracking: [HttpClient](src/node_modules/http/http_client.mjs), [CommandLine](src/node_modules/infrastructure/command_line.mjs), [Log](src/node_modules/infrastructure/command_line.mjs), [GenericRouter](src/node_modules/http/generic_router.mjs), and [Rot13Client](src/www/infrastructure/rot13_client.js).
Several classes support output tracking: [HttpClient](src/node_modules/http/http_client.js), [CommandLine](src/node_modules/infrastructure/command_line.js), [Log](src/node_modules/infrastructure/command_line.js), [GenericRouter](src/node_modules/http/generic_router.js), and [Rot13Client](src/www/infrastructure/rot13_client.js).

#### [Behavior Simulation](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#behavior-simulation)

[HttpServer](src/node_modules/http/http_server.mjs) allows callers to simulate HTTP requests.
[HttpServer](src/node_modules/http/http_server.js) allows callers to simulate HTTP requests.

#### [Fake It Once You Make It](https://www.jamesshore.com/v2/projects/testing-without-mocks/testing-without-mocks#fake-it)

[Log](src/node_modules/infrastructure/log.mjs), [HomePageController](src/www/home_page/home_page_controller.js), and [Rot13Client](src/www/infrastructure/rot13_client.js) all use nullable dependencies to implement their code and tests. Of the production implementations, Rot13Client is the most interesting, because it has configurable responses.
[Log](src/node_modules/infrastructure/log.js), [HomePageController](src/www/home_page/home_page_controller.js), and [Rot13Client](src/www/infrastructure/rot13_client.js) all use nullable dependencies to implement their code and tests. Of the production implementations, Rot13Client is the most interesting, because it has configurable responses.

### Legacy Code Patterns

Expand Down
6 changes: 3 additions & 3 deletions build/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const lintFiles = memoizedDeglob([
"build/**/*.js",
"src/**/*.js",
"src/**/*.cjs",
"src/**/*.mjs",
"src/**/*.js",
"src/**/*.ts",
], [
"build/util/node_version_checker.js", // ESLint doesn't yet support import assertions
Expand All @@ -40,15 +40,15 @@ export const compilerDependencies = memoizedDeglob([
...sourcePackages(),
"src/**/*.js",
"src/**/*.cjs",
"src/**/*.mjs",
"src/**/*.js",
"src/**/*.ts",
]);

export const testFiles = memoizedDeglob([
"build/**/_*_test.js",
"generated/typescript/**/_*_test.js",
"generated/typescript/**/_*_test.cjs",
"generated/typescript/**/_*_test.mjs",
"generated/typescript/**/_*_test.js",
"generated/typescript/**/_*_test.ts",
]);

Expand Down
2 changes: 1 addition & 1 deletion build/util/assert.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import assert from "../../src/node_modules/util/assert.mjs";
import assert from "../../src/node_modules/util/assert.js";

export default assert;
12 changes: 6 additions & 6 deletions src/_all_servers_test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright Titanium I.T. LLC.
import assert from "util/assert.mjs";
import * as ensure from "util/ensure.mjs";
import assert from "util/assert.js";
import * as ensure from "util/ensure.js";
import { AllServers } from "./all_servers.js";
import { CommandLine } from "infrastructure/command_line.mjs";
import { HttpServer } from "http/http_server.mjs";
import { HttpRequest } from "http/http_request.mjs";
import { Log } from "infrastructure/log.mjs";
import { CommandLine } from "infrastructure/command_line.js";
import { HttpServer } from "http/http_server.js";
import { HttpRequest } from "http/http_request.js";
import { Log } from "infrastructure/log.js";
import { WwwRouter } from "./www/www_router.js";
import { Rot13Router } from "./rot13_service/rot13_router.js";

Expand Down
6 changes: 3 additions & 3 deletions src/_smoke_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Titanium I.T. LLC.
import assert from "util/assert.mjs";
import { forkModule, requestAsync } from "util/test_helper.mjs";
import { pathToFile } from "util/module_paths.mjs";
import assert from "util/assert.js";
import { forkModule, requestAsync } from "util/test_helper.js";
import { pathToFile } from "util/module_paths.js";
// dependency_analysis: ./serve.js

const STARTUP_TIMEOUT_IN_MS = 2000;
Expand Down
8 changes: 4 additions & 4 deletions src/all_servers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright Titanium I.T. LLC.
import * as ensure from "util/ensure.mjs";
import { CommandLine } from "infrastructure/command_line.mjs";
import { HttpServer } from "http/http_server.mjs";
import { Log } from "infrastructure/log.mjs";
import * as ensure from "util/ensure.js";
import { CommandLine } from "infrastructure/command_line.js";
import { HttpServer } from "http/http_server.js";
import { Log } from "infrastructure/log.js";
import { WwwRouter } from "./www/www_router.js";
import { Rot13Router } from "./rot13_service/rot13_router.js";

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ad4dcfc

Please sign in to comment.