Skip to content

Commit

Permalink
Move codebase to use single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
talyssonoc committed Sep 30, 2021
1 parent c049697 commit ce9164d
Show file tree
Hide file tree
Showing 87 changed files with 506 additions and 506 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"arrowParens": "always",
"printWidth": 120,
"semi": true,
"singleQuote": false
"singleQuote": true
}
14 changes: 7 additions & 7 deletions bin/replClient.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { connect } from "net";
import { connect } from 'net';

const main = () => {
const { argv } = process;

let host = "127.0.0.1";
let host = '127.0.0.1';
let port = 2580;

if (argv.length === 4) {
Expand All @@ -12,26 +12,26 @@ const main = () => {
} else if (argv.length === 3) {
port = Number(argv[2]);
} else {
throw new Error("The command is supposed to be used as: yarn remote [server address] [REPL port]");
throw new Error('The command is supposed to be used as: yarn remote [server address] [REPL port]');
}

const sock = connect(port, host);

process.stdin.pipe(sock);
sock.pipe(process.stdout);

sock.on("connect", function () {
sock.on('connect', function () {
process.stdin.resume();
process.stdin.setRawMode(true);
});

sock.on("close", function done() {
sock.on('close', function done() {
process.stdin.setRawMode(false);
process.stdin.pause();
sock.removeListener("close", done);
sock.removeListener('close', done);
});

process.stdin.on("end", function () {
process.stdin.on('end', function () {
sock.destroy();
console.log();
});
Expand Down
12 changes: 6 additions & 6 deletions src/__tests__/TestControls.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Container, container } from "@/container";
import { withContext } from "@/context";
import { main } from "@/_boot";
import { Db } from "mongodb";
import supertest, { SuperTest, Test } from "supertest";
import { Container, container } from '@/container';
import { withContext } from '@/context';
import { main } from '@/_boot';
import { Db } from 'mongodb';
import supertest, { SuperTest, Test } from 'supertest';

type Dependencies = {
mongo: Db;
Expand All @@ -13,7 +13,7 @@ type TestControls = Readonly<{
clearDatabase: () => Promise<void>;
cleanUp: () => Promise<void>;
container: Container;
registry: Container["cradle"];
registry: Container['cradle'];
}>;

const appRunning = withContext(
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
process.env.NODE_ENV = "test";
process.env.NODE_ENV = 'test';

const catchAll = new Proxy(
{},
Expand All @@ -9,6 +9,6 @@ const catchAll = new Proxy(
}
);

jest.mock("pino", () => () => catchAll);
jest.mock('pino', () => () => catchAll);

console = catchAll;
6 changes: 3 additions & 3 deletions src/_boot/appModules.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { articleModule, ArticleRegistry } from "@/article";
import { ArticleMessages } from "@/article/messages";
import { commentModule, CommentRegistry } from "@/comment";
import { articleModule, ArticleRegistry } from '@/article';
import { ArticleMessages } from '@/article/messages';
import { commentModule, CommentRegistry } from '@/comment';

type AppModulesMessages = ArticleMessages;

Expand Down
10 changes: 5 additions & 5 deletions src/_boot/database.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { makeModule } from "@/context";
import { makeMongoProvider, MongoProvider } from "@/_lib/MongoProvider";
import { asValue } from "awilix";
import { Db, MongoClient } from "mongodb";
import { makeModule } from '@/context';
import { makeMongoProvider, MongoProvider } from '@/_lib/MongoProvider';
import { asValue } from 'awilix';
import { Db, MongoClient } from 'mongodb';

type DatabaseConfig = {
mongodb: {
Expand All @@ -12,7 +12,7 @@ type DatabaseConfig = {
};
};

const database = makeModule("database", async ({ container: { register }, config: { mongodb } }) => {
const database = makeModule('database', async ({ container: { register }, config: { mongodb } }) => {
const client = new MongoClient(mongodb.host, {
auth: { username: mongodb.username, password: mongodb.password },
});
Expand Down
22 changes: 11 additions & 11 deletions src/_boot/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { server } from "@/_boot/server";
import { appModules } from "@/_boot/appModules";
import { asValue } from "awilix";
import { database } from "@/_boot/database";
import { repl } from "@/_boot/repl";
import { withContext } from "@/context";
import { Configuration } from "@/config";
import { Logger } from "pino";
import { pubSub } from "@/_boot/pubSub";
import { MessageBundle } from "@/messages";
import { swagger } from "@/_boot/swagger";
import { server } from '@/_boot/server';
import { appModules } from '@/_boot/appModules';
import { asValue } from 'awilix';
import { database } from '@/_boot/database';
import { repl } from '@/_boot/repl';
import { withContext } from '@/context';
import { Configuration } from '@/config';
import { Logger } from 'pino';
import { pubSub } from '@/_boot/pubSub';
import { MessageBundle } from '@/messages';
import { swagger } from '@/_boot/swagger';

const main = withContext(async ({ app, container, config, bootstrap, logger, messageBundle }) => {
container.register({
Expand Down
12 changes: 6 additions & 6 deletions src/_boot/pubSub.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { makeModule } from "@/context";
import { makeEventEmitterPubSub } from "@/_lib/pubSub/EventEmitterPubSub";
import { asValue } from "awilix";
import { Subscriber } from "@/_lib/events/Subscriber";
import { Publisher } from "@/_lib/events/Publisher";
import { makeModule } from '@/context';
import { makeEventEmitterPubSub } from '@/_lib/pubSub/EventEmitterPubSub';
import { asValue } from 'awilix';
import { Subscriber } from '@/_lib/events/Subscriber';
import { Publisher } from '@/_lib/events/Publisher';

const pubSub = makeModule("pubSub", async ({ container: { build, register }, app: { onReady } }) => {
const pubSub = makeModule('pubSub', async ({ container: { build, register }, app: { onReady } }) => {
const eventEmitterPubSub = build(makeEventEmitterPubSub);

register({
Expand Down
22 changes: 11 additions & 11 deletions src/_boot/repl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import REPL, { REPLEval, ReplOptions, REPLServer } from "repl";
import vm from "vm";
import { createServer, Server } from "net";
import { makeModule } from "@/context";
import REPL, { REPLEval, ReplOptions, REPLServer } from 'repl';
import vm from 'vm';
import { createServer, Server } from 'net';
import { makeModule } from '@/context';

type REPLConfig = {
appName: string;
Expand All @@ -12,7 +12,7 @@ type REPLConfig = {
};

const repl = makeModule(
"repl",
'repl',
async ({
app: { onReady, terminate },
container,
Expand All @@ -34,7 +34,7 @@ const repl = makeModule(
return callback(null, result);
};

const isPromise = (value) => value && typeof value.then === "function" && typeof value.catch === "function";
const isPromise = (value) => value && typeof value.then === 'function' && typeof value.catch === 'function';

const createREPL = (
config: Partial<ReplOptions> = { input: process.stdin, output: process.stdout }
Expand All @@ -57,21 +57,21 @@ const repl = makeModule(
if (cli) {
const repl = createREPL();

repl.on("close", terminate);
} else if (!["production", "test"].includes(environment)) {
repl.on('close', terminate);
} else if (!['production', 'test'].includes(environment)) {
server = createServer((socket) => {
const repl = createREPL({
input: socket,
output: socket,
terminal: true,
});

repl.on("close", () => {
repl.on('close', () => {
socket.end();
});

socket.on("error", (err) => {
logger.error("[REPL] Connection error");
socket.on('error', (err) => {
logger.error('[REPL] Connection error');
logger.error(err);
socket.end();
});
Expand Down
26 changes: 13 additions & 13 deletions src/_boot/server.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import express, { Router, Application, json, urlencoded } from "express";
import { asValue } from "awilix";
import httpLogger from "pino-http";
import { createServer } from "http";
import { requestId } from "@/_lib/http/middlewares/requestId";
import { requestContainer } from "@/_lib/http/middlewares/requestContainer";
import { errorHandler } from "@/_lib/http/middlewares/errorHandler";
import { makeModule } from "@/context";
import { gracefulShutdown } from "@/_lib/http/middlewares/gracefulShutdown";
import { errorConverters } from "@/_sharedKernel/interface/http/ErrorConverters";
import express, { Router, Application, json, urlencoded } from 'express';
import { asValue } from 'awilix';
import httpLogger from 'pino-http';
import { createServer } from 'http';
import { requestId } from '@/_lib/http/middlewares/requestId';
import { requestContainer } from '@/_lib/http/middlewares/requestContainer';
import { errorHandler } from '@/_lib/http/middlewares/errorHandler';
import { makeModule } from '@/context';
import { gracefulShutdown } from '@/_lib/http/middlewares/gracefulShutdown';
import { errorConverters } from '@/_sharedKernel/interface/http/ErrorConverters';

type ServerConfig = {
http: {
Expand All @@ -17,7 +17,7 @@ type ServerConfig = {
};

const server = makeModule(
"server",
'server',
async ({ app: { onBooted, onReady }, container, config: { cli, http, environment }, logger }) => {
const { register } = container;
const server = express();
Expand All @@ -36,7 +36,7 @@ const server = makeModule(
const rootRouter = Router();
const apiRouter = Router();

rootRouter.use("/api", apiRouter);
rootRouter.use('/api', apiRouter);

server.use(rootRouter);

Expand All @@ -48,7 +48,7 @@ const server = makeModule(
server.use(errorHandler(errorConverters, { logger }));
});

if (!cli && environment !== "test") {
if (!cli && environment !== 'test') {
onReady(
async () =>
new Promise<void>((resolve) => {
Expand Down
12 changes: 6 additions & 6 deletions src/_boot/swagger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { makeModule } from "@/context";
import { resolve } from "path";
import swaggerJSDoc from "swagger-jsdoc";
import swaggerUi from "swagger-ui-express";
import { makeModule } from '@/context';
import { resolve } from 'path';
import swaggerJSDoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';

type SwaggerConfig = {
swagger: {
Expand All @@ -12,7 +12,7 @@ type SwaggerConfig = {
};
};

const swagger = makeModule("swagger", async ({ container: { build }, config: { http, swagger } }) => {
const swagger = makeModule('swagger', async ({ container: { build }, config: { http, swagger } }) => {
const options = {
swaggerDefinition: {
info: {
Expand All @@ -22,7 +22,7 @@ const swagger = makeModule("swagger", async ({ container: { build }, config: { h
host: `${http.host}:${http.port}`,
basePath: swagger.basePath,
},
apis: [resolve(__dirname, "../**/interface/http/**/*.yaml"), resolve(__dirname, "../**/interface/http/**/*.ts")],
apis: [resolve(__dirname, '../**/interface/http/**/*.yaml'), resolve(__dirname, '../**/interface/http/**/*.ts')],
};

// Initialize swagger-jsdoc -> returns validated swagger spec in json format
Expand Down
Loading

0 comments on commit ce9164d

Please sign in to comment.