Skip to content

Commit

Permalink
Add simple logging to API
Browse files Browse the repository at this point in the history
  • Loading branch information
abbyfour committed Nov 3, 2024
1 parent 5546a65 commit 5089a82
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@sentry/node": "^7.72.0",
"@types/absinthe__socket": "^0.2.3",
"@types/absinthe__socket-apollo-link": "^0.2.1",
"@types/morgan": "^1.9.9",
"@types/phoenix": "^1.5.4",
"@typescript-eslint/eslint-plugin": "^5.44.0",
"apollo-server-express": "^2.17.0",
Expand All @@ -49,10 +50,11 @@
"hangul-romanization": "^1.0.0",
"js-md5": "^0.7.3",
"mathjs": "^7.1.0",
"morgan": "^1.10.0",
"node-fetch": "^2.6.7",
"pg": "^8.3.2",
"pg-hstore": "^2.3.3",
"phoenix": "^1.6.8",
"phoenix": "^1.7.12",
"prom-client": "^14.0.0",
"querystring": "^0.2.0",
"react": "^18.2.0",
Expand Down
3 changes: 3 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ApolloServer, Config, CorsOptions } from "apollo-server-express";
import bodyParser from "body-parser";
import express from "express";
import morgan from "morgan";
import gowonConfig from "../../config.json";
import { AnalyticsCollector } from "../analytics/AnalyticsCollector";
import { GowonClient } from "../lib/GowonClient";
Expand Down Expand Up @@ -42,6 +43,8 @@ export class GraphQLAPI {
async init() {
const app = express();

app.use(morgan("tiny"));

const corsOptions: CorsOptions = {
origin: gowonConfig.gowonWebsiteURL,
};
Expand Down
3 changes: 3 additions & 0 deletions src/lib/Lilac/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ import config from "../../../config.json";
const absintheSocket = createAbsintheSocket(
new PhoenixSocket(config.lilacWebsocket, {
transport: WebSocket,
sessionStorage: global.sessionStorage,
})
);

absintheSocket.phoenixSocket.onError((e) => console.log(e));

const websocketLink = createAbsintheSocketLink(absintheSocket);
const httpLink = createHttpLink({
uri: config.lilacURL,
Expand Down
46 changes: 44 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,13 @@
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca"
integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==

"@types/morgan@^1.9.9":
version "1.9.9"
resolved "https://registry.yarnpkg.com/@types/morgan/-/morgan-1.9.9.tgz#d60dec3979e16c203a000159daa07d3fb7270d7f"
integrity sha512-iRYSDKVaC6FkGSpEVVIvrRGw0DfJMiQzIn3qr2G5B3C//AWkulhXgaBd7tS9/J79GWSYMTHGs7PfI5b3Y8m+RQ==
dependencies:
"@types/node" "*"

"@types/node-fetch@^2.5.7", "@types/node-fetch@^2.6.3":
version "2.6.11"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.11.tgz#9b39b78665dae0e82a08f02f4967d62c66f95d24"
Expand Down Expand Up @@ -1981,6 +1988,13 @@ base64-js@^1.3.1:
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==

basic-auth@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-2.0.1.tgz#b998279bf47ce38344b4f3cf916d4679bbf51e3a"
integrity sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==
dependencies:
safe-buffer "5.1.2"

binary-extensions@^2.0.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522"
Expand Down Expand Up @@ -2480,7 +2494,7 @@ delayed-stream@~1.0.0:
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==

[email protected]:
[email protected], depd@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df"
integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==
Expand Down Expand Up @@ -4492,6 +4506,17 @@ mkdirp@^2.1.3:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-2.1.6.tgz#964fbcb12b2d8c5d6fbc62a963ac95a273e2cc19"
integrity sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==

morgan@^1.10.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/morgan/-/morgan-1.10.0.tgz#091778abc1fc47cd3509824653dae1faab6b17d7"
integrity sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==
dependencies:
basic-auth "~2.0.1"
debug "2.6.9"
depd "~2.0.0"
on-finished "~2.3.0"
on-headers "~1.0.2"

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
Expand Down Expand Up @@ -4631,6 +4656,18 @@ [email protected]:
dependencies:
ee-first "1.1.1"

on-finished@~2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947"
integrity sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==
dependencies:
ee-first "1.1.1"

on-headers@~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.2.tgz#772b0ae6aaa525c399e489adfad90c403eb3c28f"
integrity sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==

once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
Expand Down Expand Up @@ -4843,7 +4880,7 @@ [email protected]:
dependencies:
split2 "^4.1.0"

phoenix@^1.6.8:
phoenix@^1.7.12:
version "1.7.14"
resolved "https://registry.yarnpkg.com/phoenix/-/phoenix-1.7.14.tgz#2661c59dc39f0c0c00f4a4f5e5a9dfad22783810"
integrity sha512-3tZ76PiH/2g+Kyzhz8+GIFYrnx3lRnwi/Qt3ZUH04xpMxXL7Guerd5aaxtpWal73X+H8iLAjo2c+AgRy2KYQcQ==
Expand Down Expand Up @@ -5166,6 +5203,11 @@ safe-array-concat@^1.0.0, safe-array-concat@^1.1.2:
has-symbols "^1.0.3"
isarray "^2.0.5"

[email protected]:
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==

[email protected], safe-buffer@^5.0.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
Expand Down

0 comments on commit 5089a82

Please sign in to comment.