Skip to content

Commit

Permalink
refactor: add shared types (Bruception) (monkeytypegame#4769)
Browse files Browse the repository at this point in the history
* sharing is caring?

* replace 5 year old package with a more modern one

* ignore firebase config

* update import/resolver settings so that we no longer have to ignore @backend imports

---------

Co-authored-by: Miodec <[email protected]>
  • Loading branch information
Bruception and Miodec authored Nov 9, 2023
1 parent 11a49d6 commit e84f9ec
Show file tree
Hide file tree
Showing 22 changed files with 1,319 additions and 720 deletions.
41 changes: 20 additions & 21 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"extends": [
"eslint:recommended",
"plugin:json/recommended",
"plugin:require-path-exists/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
// "plugin:@typescript-eslint/recommended-requiring-type-checking"
Expand All @@ -42,31 +43,29 @@
"semi": ["error", "always"],
"no-empty": ["error", { "allowEmptyCatch": true }],
"no-var": 2,
"require-path-exists/notEmpty": 2,
"require-path-exists/tooManyArguments": 2,
"require-path-exists/exists": [
2,
{
"extensions": [
"",
".js",
".ts",
".tsx",
".es.ts",
".tsx",
".json5",
".es",
".es6",
".coffee"
]
}
],
"no-duplicate-imports": ["error"],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off"
"@typescript-eslint/no-var-requires": "off",
// "@typescript-eslint/no-floating-promises": "error" // consider adding these
// "@typescript-eslint/strict-boolean-expressions": "warn",
// "import/default": "off",
"import/no-unresolved": [
"error",
{
"ignore": ["^./constants/firebase-config$"]
}
],
"import/no-duplicates": "off"
},
"settings": {
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"project": ["frontend/tsconfig.json", "backend/tsconfig.json"]
},
"node": true
}
},
"overrides": [
{
Expand Down
3 changes: 2 additions & 1 deletion backend/src/api/controllers/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import _ from "lodash";
import * as WeeklyXpLeaderboard from "../../services/weekly-xp-leaderboard";
import { UAParser } from "ua-parser-js";
import { canFunboxGetPb } from "../../utils/pb";
import { Configuration } from "../../types/shared";

try {
if (anticheatImplemented() === false) throw new Error("undefined");
Expand Down Expand Up @@ -598,7 +599,7 @@ interface XpResult {

async function calculateXp(
result,
xpConfiguration: MonkeyTypes.Configuration["users"]["xp"],
xpConfiguration: Configuration["users"]["xp"],
uid: string,
currentTotalXp: number,
streak: number
Expand Down
13 changes: 8 additions & 5 deletions backend/src/api/routes/swagger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import _ from "lodash";
import { Application } from "express";
import swaggerStats from "swagger-stats";
import swaggerUi from "swagger-ui-express";
import { getMiddleware as getSwaggerMiddleware } from "swagger-stats";
import {
serve as serveSwagger,
setup as setupSwaggerUi,
} from "swagger-ui-express";
import publicSwaggerSpec from "../../documentation/public-swagger.json";
import internalSwaggerSpec from "../../documentation/internal-swagger.json";

Expand All @@ -12,7 +15,7 @@ const SWAGGER_UI_OPTIONS = {

function addSwaggerMiddlewares(app: Application): void {
app.use(
swaggerStats.getMiddleware({
getSwaggerMiddleware({
name: "Monkeytype API",
uriPath: "/stats",
authentication: process.env.MODE !== "dev",
Expand All @@ -29,8 +32,8 @@ function addSwaggerMiddlewares(app: Application): void {

app.use(
["/documentation", "/docs"],
swaggerUi.serve,
swaggerUi.setup(publicSwaggerSpec, SWAGGER_UI_OPTIONS)
serveSwagger,
setupSwaggerUi(publicSwaggerSpec, SWAGGER_UI_OPTIONS)
);
}

Expand Down
Loading

0 comments on commit e84f9ec

Please sign in to comment.