Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,53 +27,53 @@
},
"dependencies": {
"apollo-server-koa": "1.3.6",
"bluebird": "3.5.1",
"chalk": "2.4.1",
"bluebird": "3.5.3",
"chalk": "2.4.2",
"envalid": "4.1.4",
"flashheart": "2.9.0",
"graphql": "0.13.2",
"graphql-cost-analysis": "1.0.1",
"graphql-playground-middleware-koa": "1.4.2",
"graphql-tools": "3.0.2",
"graphql-voyager": "1.0.0-rc.18",
"koa": "2.5.1",
"graphql": "14.0.2",
"graphql-cost-analysis": "1.0.2",
"graphql-playground-middleware-koa": "1.6.8",
"graphql-tools": "4.0.3",
"graphql-voyager": "1.0.0-rc.26",
"koa": "2.6.2",
"koa-bodyparser": "4.2.1",
"koa-convert": "1.2.0",
"koa-cors": "0.0.16",
"koa-heartbeat": "0.1.2",
"koa-router": "7.4.0",
"lodash": "4.17.10",
"moment": "2.22.2",
"source-map-support": "0.5.6",
"winston": "2.4.2"
"lodash": "4.17.11",
"moment": "2.23.0",
"source-map-support": "0.5.9",
"winston": "3.1.0"
},
"devDependencies": {
"@types/bluebird": "3.5.23",
"@types/graphql": "0.13.4",
"@types/jest": "23.3.1",
"@types/koa": "2.0.46",
"@types/koa-router": "7.0.31",
"@types/bluebird": "3.5.25",
"@types/graphql": "14.0.4",
"@types/jest": "23.3.12",
"@types/koa": "2.0.48",
"@types/koa-router": "7.0.37",
"@types/nock": "9.3.0",
"apollo-cache-inmemory": "1.2.7",
"apollo-client": "2.3.8",
"apollo-link-http": "1.5.4",
"apollo-cache-inmemory": "1.3.12",
"apollo-client": "2.4.8",
"apollo-link-http": "1.5.9",
"cash-touch": "0.2.0",
"chokidar-cli": "1.2.0",
"chokidar-cli": "1.2.1",
"cpx": "1.5.0",
"docker-share": "0.0.4",
"graphql-tag": "2.9.2",
"graphql-tag": "2.10.0",
"graphql-to-typescript": "0.1.2",
"isomorphic-fetch": "2.2.1",
"jest": "23.5.0",
"jest-junit": "5.1.0",
"nock": "9.6.1",
"npm-run-all": "4.1.3",
"rimraf": "2.6.2",
"ts-jest": "23.1.3",
"tsc-watch": "1.0.26",
"tslint": "5.11.0",
"tslint-config-airbnb": "5.9.2",
"typescript": "3.0.1"
"jest": "23.6.0",
"jest-junit": "6.0.0",
"nock": "10.0.6",
"npm-run-all": "4.1.5",
"rimraf": "2.6.3",
"ts-jest": "23.10.5",
"tsc-watch": "1.0.31",
"tslint": "5.12.1",
"tslint-config-airbnb": "5.11.1",
"typescript": "3.2.2"
},
"jest-junit": {
"output": "./reports/test/junit.xml"
Expand Down
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const graphqlMiddleware = graphqlKoa(ctx => ({
],
formatError: (error) => {
const { message, locations, path, stack } = error;
logger.error(`GraphQL error`, { message, locations, path }, stack);
logger.error('GraphQL error', { message, locations, path }, stack);
return error;
},
}));
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/__tests__/joke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ beforeAll(() => {
type: 'success',
value: {
id: 2000,
joke: `Chuck Norris can write to an output stream.`,
joke: 'Chuck Norris can write to an output stream.',
categories: [],
},
};
Expand All @@ -25,7 +25,7 @@ beforeAll(() => {
type: 'success',
value: {
id: 1000,
joke: `Mock Chuck Norris's database has only one table, 'Kick', which he DROPs frequently.`,
joke: "Mock Chuck Norris's database has only one table, 'Kick', which he DROPs frequently.",
categories: [
'nerdy',
],
Expand Down
29 changes: 13 additions & 16 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import winston from 'winston';
import { createLogger, transports, format } from 'winston';
import moment from 'moment';

const logger = new (winston.Logger)({
const timestamp = () => moment().format('YYYY-MM-DD HH:mm:ss.SSSS');

const customFormat = format.printf(options =>
`${timestamp()} ${options.level.toUpperCase()} ${(options.message ? options.message : '')}
${(options.meta && Object.keys(options.meta).length
? '\n\t' + JSON.stringify(options.meta) // tslint:disable-line:prefer-template
: '')}`);

const logger = createLogger({
level: process.env.LOG_LEVEL || 'info',
format: customFormat,
transports: [
new (winston.transports.Console)({
timestamp: () => moment().format('YYYY-MM-DD HH:mm:ss.SSSS'),
formatter: options =>
options.timestamp() + ' ' +
options.level.toUpperCase() + ' ' +
(options.message ? options.message : '') +
(
options.meta && Object.keys(options.meta).length
? '\n\t' + JSON.stringify(options.meta)
: ''
),
}),
new (transports.Console)(),
],
});

logger.level = process.env.LOG_LEVEL || 'info';

export default logger;
10 changes: 5 additions & 5 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ const port = process.env.PORT;
app.listen(port, () => {
if (process.env.NODE_ENV === 'development') {
if (process.env.GRAPHIQL) {
console.log(`The GraphiQL App is running at:`);
console.log('The GraphiQL App is running at:');
console.log();
console.log(` ${chalk.cyan(`http://localhost:${port}/${process.env.GRAPHIQL_PATH }`)}`);
} else {
console.log(`The Koa App is running at:`);
console.log('The Koa App is running at:');
console.log();
console.log(` ${chalk.cyan(`http://localhost:${port}`)}`);
}
if (process.env.VOYAGER) {
if (process.env.GRAPHIQL) {
console.log();
}
console.log(`The GraphQL Voyager App is running at:`);
console.log('The GraphQL Voyager App is running at:');
console.log();
console.log(` ${chalk.cyan(`http://localhost:${port}/${process.env.VOYAGER_PATH}`)}`);
}
if (process.env.PLAYGROUND) {
if (process.env.GRAPHIQL || process.env.VOYAGER) {
console.log();
}
console.log(`The GraphQL Plaground App is running at:`);
console.log('The GraphQL Plaground App is running at:');
console.log();
console.log(` ${chalk.cyan(`http://localhost:${port}/${process.env.PLAYGROUND_PATH}`)}`);
}
} else {
console.log(`The Koa App is running`);
console.log('The Koa App is running');
}
});
Loading