Skip to content

Commit

Permalink
Merge pull request #718 from elmadev/upgrade-deps
Browse files Browse the repository at this point in the history
Upgrade deps
  • Loading branch information
sunehs authored Nov 16, 2024
2 parents 5d1c53a + 1a2506b commit d4ef1ea
Show file tree
Hide file tree
Showing 24 changed files with 2,161 additions and 2,559 deletions.
24 changes: 22 additions & 2 deletions .cz-config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,27 @@ module.exports = {
},
],

scopes: [{ name: ' ' }, { name: 'other' }, { name: 'deps' }, { name: 'config' }, { name: 'home' }, { name: 'battles' }, { name: 'cups' }, { name: 'levels' }, { name: 'levelpacks' }, { name: 'kuskis' }, { name: 'search' }, { name: 'chat' }, { name: 'login' }, { name: 'replays' }, { name: 'teams' }, { name: 'settings' }, { name: 'help' }, { name: 'ranking' }, { name: 'admin' }],
scopes: [
{ name: ' ' },
{ name: 'other' },
{ name: 'deps' },
{ name: 'config' },
{ name: 'home' },
{ name: 'battles' },
{ name: 'cups' },
{ name: 'levels' },
{ name: 'levelpacks' },
{ name: 'kuskis' },
{ name: 'search' },
{ name: 'chat' },
{ name: 'login' },
{ name: 'replays' },
{ name: 'teams' },
{ name: 'settings' },
{ name: 'help' },
{ name: 'ranking' },
{ name: 'admin' },
],

allowTicketNumber: false,
isTicketNumberRequired: false,
Expand All @@ -40,5 +60,5 @@ module.exports = {
allowBreakingChanges: ['feat', 'fix'],
skipQuestions: ['body', 'customScope', 'breaking'],
subjectLimit: 100,
footerPrefix : 'Closes:'
footerPrefix: 'Closes:',
};
33 changes: 0 additions & 33 deletions .eslintrc.json

This file was deleted.

3 changes: 2 additions & 1 deletion .prettierrc.json → .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"printWidth": 80,
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "avoid"
"arrowParens": "avoid",
"endOfLine": "auto"
}
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Node JS based backend for the [elmaonline site](https://elma.online). The fronte

## Get started

1. Install if needed nodejs (v16.15 or later, tested with up to v20.12) and yarn (3.x)
1. Install if needed nodejs (v18 or later, tested with up to v22)

- If you install node using nvm you might need to install corepack manually
`npm install -g corepack`

2. run `corepack enable`
2. run `corepack enable` to enable yarn v3
3. Clone this repo
4. Run `yarn` in terminal to install depedencies
5. Run `yarn start` in terminal to start development server
Expand Down Expand Up @@ -64,6 +64,7 @@ Node JS based backend for the [elmaonline site](https://elma.online). The fronte
## Imports

Be aware of newer nodejs versions requiring imports done with file extensions.

- Importing a relative path should always have the extensions: `import { func } from '../utils/funcs.js'`
- index files have to be written explicitly: `import { func } from '../utils/index.js`
- Imports done using aliases doesn't require this as the file extension is added in the alias: `import { func } from '#utils/funcs'`
Expand Down
34 changes: 34 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import js from '@eslint/js';
import globals from 'globals';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

export default [
{
files: ['**/*.{js,jsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.node,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
rules: {
...js.configs.recommended.rules,
'import/no-anonymous-default-export': 'off',
'no-console': 'warn',
'no-param-reassign': 'warn',
'no-unused-vars': ['error', { caughtErrors: 'none' }],
},
},
{
ignores: ['.yarn/**'],
},
eslintPluginPrettierRecommended,
{
rules: {
'prettier/prettier': 'warn',
},
},
];
61 changes: 32 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
{
"name": "nodejs-express-api-starter-kit",
"name": "elmaonline-site",
"type": "module",
"private": true,
"packageManager": "[email protected]",
"main": "src/index.js",
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"start": "nodemon --no-warnings",
"lint": "eslint --ignore-path .gitignore --ignore-pattern \"!**/.*\" .",
"lint": "eslint .",
"commit": "git-cz"
},
"dependencies": {
"apisauce": "^2.1.6",
"archiver": "^5.3.1",
"aws-sdk": "^2.1209.0",
"apisauce": "^3.1.0",
"archiver": "^7.0.1",
"aws-sdk": "^2.1692.0",
"body-parser": "^1.20.3",
"commitizen": "^4.2.5",
"cookie-parser": "^1.4.6",
"commitizen": "^4.3.1",
"cookie-parser": "^1.4.7",
"cors": "^2.8.5",
"cz-customizable": "6.9.1",
"date-fns": "^2.29.2",
"cz-customizable": "^7.2.1",
"date-fns": "^4.1.0",
"disco-oauth": "^5.1.1",
"elma-js": "https://github.com/ville-j/elma-js",
"elmajs": "^1.2.0",
"express": "^4.20.0",
"express-fileupload": "^1.4.0",
"express-validator": "^6.14.2",
"elmajs": "^1.2.2",
"express": "^4.21.1",
"express-fileupload": "^1.5.1",
"express-validator": "^7.2.0",
"husky": "^8.0.1",
"jimp": "^0.16.1",
"jimp": "^1.6.0",
"jws": "^4.0.0",
"lint-staged": "^13.0.3",
"lint-staged": "^15.2.10",
"lodash-contrib": "^4.1200.1",
"lodash-es": "^4.17.21",
"mysql2": "^3.9.8",
"nanoid": "^4.0.0",
"mysql2": "^3.11.4",
"nanoid": "^5.0.8",
"neo-async": "^2.6.2",
"read-chunk": "^4.0.3",
"read-chunk": "4.0.3",
"request": "^2.88.2",
"sequelize": "^6.29.0",
"sequelize": "^6.37.5",
"sharp": "^0.33.5",
"sib-api-v3-sdk": "^8.4.2"
"sib-api-v3-sdk": "^8.5.0"
},
"devDependencies": {
"@babel/core": "^7.23.3",
"@babel/eslint-parser": "^7.23.3",
"@babel/plugin-syntax-import-assertions": "^7.20.0",
"eslint": "^8.54.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"nodemon": "^2.0.19",
"prettier": "2.7.1"
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.25.9",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.12.0",
"nodemon": "^3.1.7",
"prettier": "^3.3.3"
},
"imports": {
"#api/*": "./src/api/*.js",
Expand All @@ -73,7 +76,7 @@
}
},
"lint-staged": {
"*.js": "eslint --cache --fix"
"*.js": "eslint . --cache --fix"
},
"nodemonConfig": {
"env": {
Expand Down
2 changes: 0 additions & 2 deletions src/api/besttime.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ const getBestRecordsDrivenRecently = async (
],
});

// eslint-disable-next-line no-underscore-dangle
const _kuskis = groupBy(kuskis, 'KuskiIndex');

const levels = await Level.findAll({
Expand All @@ -268,7 +267,6 @@ const getBestRecordsDrivenRecently = async (
},
});

// eslint-disable-next-line no-underscore-dangle
const _levels = groupBy(levels, 'LevelIndex');

records = records.map(r => {
Expand Down
4 changes: 1 addition & 3 deletions src/api/cups.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import {
Team,
} from '#data/models';
import sequelize from '#data/sequelize';
import {
log,
} from '#utils/database';
import { log } from '#utils/database';

const router = express.Router();

Expand Down
10 changes: 4 additions & 6 deletions src/api/level.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,8 @@ const getLevels = async (
return [];
}

const levelIndexesByFinishedBy = await getLevelIndexesByFinishedBy(
finishedBy,
);
const levelIndexesByFinishedBy =
await getLevelIndexesByFinishedBy(finishedBy);

return levelIndexesByFinishedBy;
};
Expand All @@ -272,9 +271,8 @@ const getLevels = async (
true,
);

const levelIndexesByFinishedBy = await getFinishedByFinishedLevels(
finishedBy,
);
const levelIndexesByFinishedBy =
await getFinishedByFinishedLevels(finishedBy);

const includeFinishedByLevelIndexes = finishedBy && finished === 'true';
const excludeFinishedByLevelIndexes = finishedBy && finished === 'false';
Expand Down
1 change: 0 additions & 1 deletion src/api/levelpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ const getPersonalWithMulti = async (LevelPackName, KuskiIndex, eolOnly = 0) => {
}).then(data => data.map(r => r.LevelIndex));

const multiTimesByLevel = [];
// eslint-disable-next-line
const allMultiTimes = await BestMultitime.findAll({
where: {
[Op.and]: [
Expand Down
13 changes: 5 additions & 8 deletions src/api/levelstats.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,16 @@ router
res.json(payload);
})
.get('/collection/:type/:value', async (req, res) => {

let ids = [];

if ( req.params.type === 'ids' ) {
if (req.params.type === 'ids') {
ids = req.params.value.split(',').map(Number);
}

if ( req.params.type === 'cup' ) {
}
// if (req.params.type === 'cup') {}

// if (req.params.type === 'pack') {}

if ( req.params.type === 'pack' ) {
}

const stats = await Level.findAll({
where: { LevelIndex: ids },
attributes: ['LevelIndex', 'LevelName', 'LongName', 'Locked', 'Hidden'],
Expand All @@ -137,7 +134,7 @@ router
const payload = {
ids,
stats,
}
};

res.json(payload);
});
Expand Down
1 change: 1 addition & 0 deletions src/api/taswr.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export const getDatInfo = async (datFile, filename, LevelIndex) => {
file: filename,
};
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
return {
error,
Expand Down
2 changes: 0 additions & 2 deletions src/config.defaults.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable max-len */

if (process.env.BROWSER) {
throw new Error(
'Do not import `config.js` from inside the client-side code.',
Expand Down
2 changes: 0 additions & 2 deletions src/config.local.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable max-len */

if (process.env.BROWSER) {
throw new Error(
'Do not import `config.js` from inside the client-side code.',
Expand Down
4 changes: 2 additions & 2 deletions src/data/models/LevelStats.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Sequelize, { Model } from 'sequelize';
import { includes, range, toPairs, uniqBy, isEmpty, omit } from 'lodash-es';
import { includes, range, toPairs, uniqBy, isEmpty } from 'lodash-es';
import * as PlayStats from './PlayStats.js';
import sequelize from '../sequelize.js';
import { getPerfTracker } from '#utils/perf';
Expand Down Expand Up @@ -168,7 +168,7 @@ export const getColsForCollectionStats = () => {
return cols.filter(col => {
return !includes(['LeaderHistory', 'KuskiIdsF', 'KuskiIdsAll'], col);
});
}
};

class LevelStats extends Model {
// map an array of ids to existing instances or null
Expand Down
3 changes: 0 additions & 3 deletions src/data/models/PlayStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ export const filterTimes = times => {

export const mapTimeDriven = times => {
return times.map(t => {
// eslint-disable-next-line no-param-reassign
t.Driven = parseTimeDriven(t.Driven);
return t;
});
Expand Down Expand Up @@ -521,8 +520,6 @@ export const getTopTimes = (times, n) => {
* @returns {Array<Object>}
*/
export const getTopFinishes = (times, n) => {
// eslint-disable-next-line no-underscore-dangle

const finishes = times.filter(t => t.Finished === 'F');
return getTopTimes(finishes, n);
};
Expand Down
2 changes: 2 additions & 0 deletions src/data/sequelize.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ const sequelize = new Sequelize(uri, {
sequelize
.authenticate()
.then(() => {
// eslint-disable-next-line no-console
console.info(`MySQL connection established at ${uri}`);
})
.catch(err => {
// eslint-disable-next-line no-console
console.error(`Unable to connect to MySQL database at ${uri}:`, err);
});

Expand Down
1 change: 1 addition & 0 deletions src/okevalidator/okevalidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export async function getPigData(datFilePath, tempDir) {
cwd: tempDir,
});
if (stderr) {
// eslint-disable-next-line no-console
console.log(`okev error: ${stderr}`);
}

Expand Down
Loading

0 comments on commit d4ef1ea

Please sign in to comment.