Skip to content

Commit 11ca474

Browse files
authored
Merge pull request #4632 from alanorth/modern-node
Use several modern Node.js patterns
2 parents 1193413 + 4d70510 commit 11ca474

File tree

11 files changed

+36
-159
lines changed

11 files changed

+36
-159
lines changed

.eslintrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@
253253
"forceSingleLine": true
254254
}
255255
],
256+
"import/enforce-node-protocol-usage": [
257+
"error",
258+
"always"
259+
],
256260

257261
"unused-imports/no-unused-imports": "error",
258262
"lodash/import-scope": [

cypress/plugins/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fs = require('fs');
1+
const fs = require('node:fs');
22

33
// These two global variables are used to store information about the REST API used
44
// by these e2e tests. They are filled out prior to running any tests in the before()

lint/generate-docs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212
readFileSync,
1313
rmSync,
1414
writeFileSync,
15-
} from 'fs';
16-
import { join } from 'path';
15+
} from 'node:fs';
16+
import { join } from 'node:path';
1717

1818
import { default as htmlPlugin } from './src/rules/html';
1919
import { default as tsPlugin } from './src/rules/ts';

lint/src/util/theme-support.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
* http://www.dspace.org/license/
77
*/
88

9+
import { readFileSync } from 'node:fs';
10+
import { basename } from 'node:path';
11+
912
import { TSESTree } from '@typescript-eslint/utils';
1013
import { RuleContext } from '@typescript-eslint/utils/ts-eslint';
11-
import { readFileSync } from 'fs';
12-
import { basename } from 'path';
1314
import ts, { Identifier } from 'typescript';
1415

1516
import {

package-lock.json

Lines changed: 7 additions & 134 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
"version": "10.0.0-next",
44
"scripts": {
55
"ng": "ng",
6-
"config:watch": "nodemon",
76
"test:rest": "ts-node --project ./tsconfig.ts-node.json scripts/test-rest.ts",
87
"start": "npm run start:prod",
9-
"start:dev": "nodemon --exec \"cross-env NODE_ENV=development npm run serve\"",
8+
"start:dev": "cross-env NODE_ENV=development npm run serve --watch",
109
"start:prod": "npm run build:prod && cross-env NODE_ENV=production npm run serve:ssr",
1110
"start:mirador:prod": "npm run build:mirador && npm run start:prod",
1211
"preserve": "npm run base-href",
@@ -19,7 +18,7 @@
1918
"build:ssr": "ng build --configuration production && ng run dspace-angular:server:production",
2019
"build:lint": "rimraf 'lint/dist/**/*.js' 'lint/dist/**/*.js.map' && tsc -b lint/tsconfig.json",
2120
"test": "ng test --source-map=true --watch=false --configuration test",
22-
"test:watch": "nodemon --exec \"ng test --source-map=true --watch=true --configuration test\"",
21+
"test:watch": "ng test --source-map=true --watch=true --configuration test",
2322
"test:headless": "ng test --source-map=true --watch=false --configuration test --browsers=ChromeHeadless --code-coverage",
2423
"test:lint": "npm run build:lint && npm run test:lint:nobuild",
2524
"test:lint:nobuild": "jasmine --config=lint/jasmine.json",
@@ -117,7 +116,6 @@
117116
"@terraformer/wkt": "^2.2.1",
118117
"altcha": "^0.9.0",
119118
"angulartics2": "^12.2.0",
120-
"axios": "^1.11.0",
121119
"bootstrap": "^5.3",
122120
"cerialize": "0.1.18",
123121
"cli-progress": "^3.12.0",
@@ -226,7 +224,6 @@
226224
"karma-mocha-reporter": "2.2.5",
227225
"ng-mocks": "^14.13.5",
228226
"ngx-mask": "14.2.4",
229-
"nodemon": "^2.0.22",
230227
"postcss": "^8.5",
231228
"postcss-import": "^14.0.0",
232229
"postcss-loader": "^4.0.3",

server.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import * as ejs from 'ejs';
2525
import * as compression from 'compression';
2626
import expressStaticGzip from 'express-static-gzip';
2727
/* eslint-enable import/no-namespace */
28-
import axios from 'axios';
2928
import LRU from 'lru-cache';
3029
import { isbot } from 'isbot';
3130
import { createCertificate } from 'pem';
@@ -648,9 +647,9 @@ function isExcludedFromSsr(path: string, excludePathPattern: SsrExcludePatterns[
648647
*/
649648
function healthCheck(req, res) {
650649
const baseUrl = `${REST_BASE_URL}${environment.actuators.endpointPath}`;
651-
axios.get(baseUrl)
650+
fetch(baseUrl)
652651
.then((response) => {
653-
res.status(response.status).send(response.data);
652+
res.status(response.status).send(response);
654653
})
655654
.catch((error) => {
656655
res.status(error.response.status).send({

src/app/core/services/server-xhr.service.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
* http://www.dspace.org/license/
77
*/
88

9-
import { XhrFactory } from '@angular/common';
10-
import { Injectable } from '@angular/core';
119
import {
1210
Agent as HttpAgent,
1311
AgentOptions as HttpAgentOptions,
14-
} from 'http';
15-
import { Agent as HttpsAgent } from 'https';
12+
} from 'node:http';
13+
import { Agent as HttpsAgent } from 'node:https';
14+
15+
import { XhrFactory } from '@angular/common';
16+
import { Injectable } from '@angular/core';
1617
import {
1718
prototype,
1819
XMLHttpRequest,

src/backend/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import ITEMS from './data/items.json';
88
import { fakeDataBase } from './db';
99

1010
const { Router } = require('express');
11-
const util = require('util');
11+
const util = require('node:util');
1212

1313
// you would use cookies/token etc
1414
const USER_ID = 'f9d98cf1-1b96-464e-8755-bcc2a5c09077'; // hardcoded as an example

0 commit comments

Comments
 (0)