Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattjoh committed Jun 21, 2018
1 parent a3e3d93 commit 6f80a24
Show file tree
Hide file tree
Showing 48 changed files with 1,291 additions and 1,300 deletions.
12 changes: 9 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
trim_trailing_whitespace = true
insert_final_newline = true

[*.json]
insert_final_newline = false

[*.ts]
max_line_length = 80
1 change: 0 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
108 changes: 54 additions & 54 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
{
"name": "@coralproject/talk",
"version": "1.0.0",
"description": "A better commenting experience from Mozilla, The Washington Post, and The New York Times.",
"scripts": {
"start": "node dist/index.js",
"build": "tsc",
"watch": "nodemon --config .nodemonrc.json src/index.ts",
"lint": "prettier --write src/**/*.ts"
},
"author": "",
"license": "Apache-2.0",
"dependencies": {
"apollo-server-express": "^1.3.6",
"bunyan": "^1.8.12",
"convict": "^4.3.0",
"dataloader": "^1.4.0",
"dotenv": "^6.0.0",
"dotize": "^0.2.0",
"express": "^4.16.3",
"express-static-gzip": "^0.3.2",
"graphql": "^0.13.2",
"graphql-config": "^2.0.1",
"graphql-redis-subscriptions": "^1.5.0",
"graphql-tools": "^3.0.2",
"ioredis": "^3.2.2",
"joi": "^13.4.0",
"lodash": "^4.17.10",
"luxon": "^1.2.1",
"mongodb": "^3.0.10",
"performance-now": "^2.1.0",
"subscriptions-transport-ws": "^0.9.11",
"uuid": "^3.2.1"
},
"devDependencies": {
"@types/bunyan": "^1.8.4",
"@types/convict": "^4.2.0",
"@types/dotenv": "^4.0.3",
"@types/express": "^4.16.0",
"@types/graphql": "^0.13.1",
"@types/ioredis": "^3.2.8",
"@types/joi": "^13.0.8",
"@types/lodash": "^4.14.109",
"@types/luxon": "^0.5.3",
"@types/mongodb": "^3.0.19",
"@types/uuid": "^3.4.3",
"@types/ws": "^5.1.2",
"graphql-playground-middleware-express": "^1.7.0",
"nodemon": "^1.17.5",
"prettier": "^1.13.4",
"ts-node": "^6.1.1",
"tsconfig-paths": "^3.4.0",
"typescript": "^2.9.1"
}
}
"name": "@coralproject/talk",
"version": "1.0.0",
"description": "A better commenting experience from Mozilla, The Washington Post, and The New York Times.",
"scripts": {
"start": "node dist/index.js",
"build": "tsc",
"watch": "nodemon --config .nodemonrc.json src/index.ts",
"lint": "prettier --write \"src/**/*.ts\""
},
"author": "",
"license": "Apache-2.0",
"dependencies": {
"apollo-server-express": "^1.3.6",
"bunyan": "^1.8.12",
"convict": "^4.3.0",
"dataloader": "^1.4.0",
"dotenv": "^6.0.0",
"dotize": "^0.2.0",
"express": "^4.16.3",
"express-static-gzip": "^0.3.2",
"graphql": "^0.13.2",
"graphql-config": "^2.0.1",
"graphql-redis-subscriptions": "^1.5.0",
"graphql-tools": "^3.0.2",
"ioredis": "^3.2.2",
"joi": "^13.4.0",
"lodash": "^4.17.10",
"luxon": "^1.2.1",
"mongodb": "^3.0.10",
"performance-now": "^2.1.0",
"subscriptions-transport-ws": "^0.9.11",
"uuid": "^3.2.1"
},
"devDependencies": {
"@types/bunyan": "^1.8.4",
"@types/convict": "^4.2.0",
"@types/dotenv": "^4.0.3",
"@types/express": "^4.16.0",
"@types/graphql": "^0.13.1",
"@types/ioredis": "^3.2.8",
"@types/joi": "^13.0.8",
"@types/lodash": "^4.14.109",
"@types/luxon": "^0.5.3",
"@types/mongodb": "^3.0.19",
"@types/uuid": "^3.4.3",
"@types/ws": "^5.1.2",
"graphql-playground-middleware-express": "^1.7.0",
"nodemon": "^1.17.5",
"prettier": "^1.13.4",
"ts-node": "^6.1.1",
"tsconfig-paths": "^3.4.0",
"typescript": "^2.9.1"
}
}
2 changes: 1 addition & 1 deletion src/core/common/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type Diff<T extends keyof any, U extends keyof any> = ({ [P in T]: P } &
{ [P in U]: never } & { [x: string]: never })[T];
{ [P in U]: never } & { [x: string]: never })[T];

export type Omit<U, K extends keyof U> = Pick<U, Diff<keyof U, K>>;

Expand Down
8 changes: 4 additions & 4 deletions src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Server, { ServerOptions } from './server';
import Server, { ServerOptions } from "./server";

/**
* Create a Talk Server.
*
* @param options ServerOptions that will be used to configure Talk.
*/
export default async function createTalk(
options: ServerOptions = {}
options: ServerOptions = {}
): Promise<Server> {
// Create the server with the provided options.
return new Server(options);
// Create the server with the provided options.
return new Server(options);
}
92 changes: 46 additions & 46 deletions src/core/server/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
import { Express } from 'express';
import { Db } from 'mongodb';
import http from 'http';
import { Redis } from 'ioredis';
import { Express } from "express";
import { Db } from "mongodb";
import http from "http";
import { Redis } from "ioredis";

import { Config } from 'talk-server/config';
import { Schemas } from 'talk-server/graph/schemas';
import { handleSubscriptions } from 'talk-server/graph/common/subscriptions/middleware';
import { Config } from "talk-server/config";
import { Schemas } from "talk-server/graph/schemas";
import { handleSubscriptions } from "talk-server/graph/common/subscriptions/middleware";

import { createRouter } from './router';
import serveStatic from './middleware/serveStatic';
import { createRouter } from "./router";
import serveStatic from "./middleware/serveStatic";
import {
access as accessLogger,
error as errorLogger,
} from './middleware/logging';
access as accessLogger,
error as errorLogger,
} from "./middleware/logging";

export interface AppOptions {
parent: Express;
config: Config;
mongo: Db;
redis: Redis;
schemas: Schemas;
parent: Express;
config: Config;
mongo: Db;
redis: Redis;
schemas: Schemas;
}

/**
* createApp will create a Talk Express app that can be used to handle requests.
*/
export async function createApp(options: AppOptions): Promise<Express> {
// Pull the parent out of the options.
const { parent } = options;
// Pull the parent out of the options.
const { parent } = options;

// Logging
parent.use(accessLogger);
// Logging
parent.use(accessLogger);

// Static Files
parent.use(serveStatic);
// Static Files
parent.use(serveStatic);

// Mount the router.
parent.use(await createRouter(options));
// Mount the router.
parent.use(await createRouter(options));

// Error Handling
parent.use(errorLogger);
// Error Handling
parent.use(errorLogger);

return parent;
return parent;
}

/**
Expand All @@ -51,13 +51,13 @@ export async function createApp(options: AppOptions): Promise<Express> {
* @param port the port to listen on
*/
export const listenAndServe = (
app: Express,
port: number
app: Express,
port: number
): Promise<http.Server> =>
new Promise(async resolve => {
// Listen on the designated port.
const httpServer = app.listen(port, () => resolve(httpServer));
});
new Promise(async resolve => {
// Listen on the designated port.
const httpServer = app.listen(port, () => resolve(httpServer));
});

/**
* attachSubscriptionHandlers attaches all the handlers to the http.Server to
Expand All @@ -67,18 +67,18 @@ export const listenAndServe = (
* @param server the http.Server to attach the websocket upgraders to
*/
export async function attachSubscriptionHandlers(
schemas: Schemas,
server: http.Server
schemas: Schemas,
server: http.Server
) {
// Setup the Management Subscription endpoint.
handleSubscriptions(server, {
schema: schemas.management,
path: '/api/management/live',
});
// Setup the Management Subscription endpoint.
handleSubscriptions(server, {
schema: schemas.management,
path: "/api/management/live",
});

// Setup the Tenant Subscription endpoint.
handleSubscriptions(server, {
schema: schemas.tenant,
path: '/api/tenant/live',
});
// Setup the Tenant Subscription endpoint.
handleSubscriptions(server, {
schema: schemas.tenant,
path: "/api/tenant/live",
});
}
14 changes: 7 additions & 7 deletions src/core/server/app/middleware/logging.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RequestHandler, ErrorRequestHandler } from 'express';
import logger from '../../logger';
import now from 'performance-now';
import { RequestHandler, ErrorRequestHandler } from "express";
import logger from "../../logger";
import now from "performance-now";

export const access: RequestHandler = (req, res, next) => {
const startTime = now();
Expand All @@ -10,11 +10,11 @@ export const access: RequestHandler = (req, res, next) => {
const responseTime = Math.round(now() - startTime);

// Get some extra goodies from the request.
const userAgent = req.get('User-Agent');
const userAgent = req.get("User-Agent");

// Reattach the old end, and finish.
res.end = end;
if (typeof encodingOrCb === 'function') {
if (typeof encodingOrCb === "function") {
res.end(chunk, encodingOrCb);
} else {
res.end(chunk, encodingOrCb, cb);
Expand All @@ -30,14 +30,14 @@ export const access: RequestHandler = (req, res, next) => {
userAgent,
responseTime,
},
'http request'
"http request"
);
};

next();
};

export const error: ErrorRequestHandler = (err, req, res, next) => {
logger.error({ err }, 'http error');
logger.error({ err }, "http error");
next(err);
};
4 changes: 2 additions & 2 deletions src/core/server/app/middleware/playground.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MiddlewareOptions } from 'graphql-playground-html';
import playground from 'graphql-playground-middleware-express';
import { MiddlewareOptions } from "graphql-playground-html";
import playground from "graphql-playground-middleware-express";

export default (options: MiddlewareOptions) => playground(options);
6 changes: 3 additions & 3 deletions src/core/server/app/middleware/serveStatic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import serveStatic from 'express-static-gzip';
import path from 'path';
import serveStatic from "express-static-gzip";
import path from "path";

export default serveStatic(path.join(__dirname, '..', '..', 'dist'), {});
export default serveStatic(path.join(__dirname, "..", "..", "dist"), {});
Loading

0 comments on commit 6f80a24

Please sign in to comment.