CrazyDoctor 1 month ago
parent
commit
6407373c77

+ 6 - 1
.eslintrc

@@ -1,10 +1,15 @@
 {
 	"root": true,
 	"parser": "@typescript-eslint/parser",
-	"ignorePatterns": ["build", "static", "node_scripts"],
+	"ignorePatterns": ["build/", "static/", "node_scripts/", "target/"],
 	"parserOptions": {
 		"ecmaVersion": 2020
 	},
+	"overrides": [
+		{
+			"files": ["src/**/*.ts"]
+		}
+	],
 	"rules": {
 		"indent": ["error", "tab"],
 		"semi": ["error", "always"],

+ 1 - 1
docker.gradle

@@ -21,7 +21,7 @@ import com.bmuschko.gradle.docker.tasks.image.Dockerfile
 import com.github.dockerjava.api.exception.NotFoundException
 
 if (!project.hasProperty('dockerBaseImage'))
-	ext.dockerBaseImage = 'node:alpine'
+	ext.dockerBaseImage = 'node:18-alpine'
 
 if (!project.hasProperty('dockerImageId'))
 	ext.dockerImageId = 'crazydoctor/crazydoctor-dzjsdocs:latest'

+ 1 - 2
src/routes/GetClass.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import { HttpMethod, Route, StatusCodes, Request, Response } from 'org.crazydoctor.expressts';
 import { ClassMapEntity, Sources } from '../sources/Sources';
 import fs from 'fs';
 import ServerApp from '..';

+ 1 - 2
src/routes/GetCommentsXml.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import { HttpMethod, Route, StatusCodes, Request, Response } from 'org.crazydoctor.expressts';
 import XmlWriter from '../util/XmlWriter';
 import fs from 'fs';
 import * as path from 'path';

+ 1 - 2
src/routes/GetDataStatistics.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import {HttpMethod, Route, StatusCodes, Request, Response} from 'org.crazydoctor.expressts';
 import ServerApp from '..';
 import { ISession } from '../session/ISession';
 import DBEvents from '../db/DBEvents';

+ 1 - 2
src/routes/GetDataStatisticsClass.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import {HttpMethod, Route, StatusCodes, Request, Response} from 'org.crazydoctor.expressts';
 import ServerApp from '..';
 import { ISession } from '../session/ISession';
 import DBEvents from '../db/DBEvents';

+ 1 - 2
src/routes/GetDataStatisticsUser.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import {HttpMethod, Route, StatusCodes, Request, Response} from 'org.crazydoctor.expressts';
 import ServerApp from '..';
 import { ISession } from '../session/ISession';
 import DBEvents from '../db/DBEvents';

+ 1 - 2
src/routes/GetFaq.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import {HttpMethod, Route, StatusCodes, Request, Response} from 'org.crazydoctor.expressts';
 import ServerApp from '..';
 
 class GetFaq extends Route {

+ 1 - 2
src/routes/GetIndex.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import {HttpMethod, Route, StatusCodes, Request, Response} from 'org.crazydoctor.expressts';
 import { Sources } from '../sources/Sources';
 import ServerApp from '..';
 import { ISession } from '../session/ISession';

+ 1 - 2
src/routes/GetLogin.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import {HttpMethod, Route, StatusCodes, Request, Response} from 'org.crazydoctor.expressts';
 import ServerApp from '..';
 import { ISession } from '../session/ISession';
 

+ 1 - 2
src/routes/GetPackage.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import {HttpMethod, Route, StatusCodes, Request, Response} from 'org.crazydoctor.expressts';
 import { PackageEntity, Sources } from '../sources/Sources';
 import ServerApp from '..';
 import { ISession } from '../session/ISession';

+ 1 - 2
src/routes/GetStatistics.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import {HttpMethod, Route, StatusCodes, Request, Response} from 'org.crazydoctor.expressts';
 import ServerApp from '..';
 import { ISession } from '../session/ISession';
 import { Sources } from '../sources/Sources';

+ 1 - 2
src/routes/GetStatisticsUser.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import {HttpMethod, Route, StatusCodes, Request, Response} from 'org.crazydoctor.expressts';
 import ServerApp from '..';
 import { ISession } from '../session/ISession';
 import { Sources } from '../sources/Sources';

+ 1 - 2
src/routes/PostAuthorize.ts

@@ -1,5 +1,4 @@
-import { HttpMethod, Route, StatusCodes } from 'org.crazydoctor.expressts';
-import { Request, Response } from 'express';
+import { HttpMethod, Route, StatusCodes, Request, Response } from 'org.crazydoctor.expressts';
 import { ISession } from '../session/ISession';
 import SHA256 from '../util/SHA256';
 import ServerApp from '..';

+ 11 - 12
src/routes/PostDocumentedInfo.ts

@@ -1,8 +1,7 @@
-import { Request, Response } from "express";
-import { HttpMethod, Route, StatusCodes } from "org.crazydoctor.expressts";
-import ServerApp from "..";
-import { ClassMapEntity, PackageEntity, Sources } from "../sources/Sources";
-import { CommentsManager } from "../comments/CommentsManager";
+import { HttpMethod, Route, StatusCodes, Request, Response } from 'org.crazydoctor.expressts';
+import ServerApp from '..';
+import { ClassMapEntity, PackageEntity, Sources } from '../sources/Sources';
+import { CommentsManager } from '../comments/CommentsManager';
 
 type DocumentedClassInfo = {
 	documentable: number,
@@ -14,7 +13,7 @@ type DocumentedPackageInfo = DocumentedClassInfo & {
 };
 
 class GetDocumentedInfo extends Route {
-	protected action = (req: Request, res: Response) => {
+	protected action = (req: Request, res: Response): any => {
 		const params = req.body;
 
 		if(ServerApp.SourcesUpdating) {
@@ -51,7 +50,7 @@ class GetDocumentedInfo extends Route {
 		const roots = Sources.getRepoNames();
 		const result: { [key: string]: DocumentedClassInfo } = {};
 
-		for(let root of roots) {
+		for(const root of roots) {
 			let sumDocumentable = 0;
 			let sumDocumented = 0;
 			const classes = Sources.findClassesByRoot(root);
@@ -59,7 +58,7 @@ class GetDocumentedInfo extends Route {
 			if(!classes)
 				continue;
 
-			for(let cls of classes) {
+			for(const cls of classes) {
 				const res = await this.getClassDocumentedInfo(cls);
 				sumDocumentable += res.documentable;
 				sumDocumented += res.documented;
@@ -72,7 +71,7 @@ class GetDocumentedInfo extends Route {
 	}
 
 	private async getPackageDocumentedInfo(pck: PackageEntity): Promise<DocumentedPackageInfo> {
-    const results: Map<string, DocumentedPackageInfo> = new Map();
+		const results: Map<string, DocumentedPackageInfo> = new Map();
 
 		let sumDocumentable = 0;
 		let sumDocumented = 0;
@@ -89,12 +88,12 @@ class GetDocumentedInfo extends Route {
 
 		await Promise.all(promises);
 
-    return { documented: sumDocumented, documentable: sumDocumentable, children: Object.fromEntries(results) };
+		return { documented: sumDocumented, documentable: sumDocumentable, children: Object.fromEntries(results) };
 	}
 
 	private async getClassDocumentedInfo(cls: ClassMapEntity): Promise<DocumentedClassInfo> {
 		const excludeList = ['callParent', 'newInstance'];
-		let documentable = cls.documentableProperties;
+		const documentable = cls.documentableProperties;
 		let documented = 0;
 		
 		const commentsResult = await CommentsManager.getCommentsByClass(cls.root, cls.name);
@@ -107,7 +106,7 @@ class GetDocumentedInfo extends Route {
 				documented++;
 		});
 
-		return { documentable, documented }
+		return { documentable, documented };
 	}
 
 	protected method = HttpMethod.POST;

+ 1 - 2
src/routes/PostInheritedComments.ts

@@ -1,5 +1,4 @@
-import { HttpMethod, Route, StatusCodes } from 'org.crazydoctor.expressts';
-import { Request, Response } from 'express';
+import { HttpMethod, Route, StatusCodes, Request, Response } from 'org.crazydoctor.expressts';
 import ServerApp from '..';
 import { CommentsManager } from '../comments/CommentsManager';
 

+ 1 - 2
src/routes/PostLogout.ts

@@ -1,5 +1,4 @@
-import { HttpMethod, Route, StatusCodes } from 'org.crazydoctor.expressts';
-import { Request, Response } from 'express';
+import { HttpMethod, Route, StatusCodes, Request, Response } from 'org.crazydoctor.expressts';
 import { ISession } from '../session/ISession';
 
 class PostLogout extends Route {

+ 1 - 2
src/routes/PostUpdateComment.ts

@@ -1,5 +1,4 @@
-import { HttpMethod, Route, StatusCodes } from 'org.crazydoctor.expressts';
-import { Request, Response } from 'express';
+import { HttpMethod, Route, StatusCodes, Request, Response } from 'org.crazydoctor.expressts';
 import { ISession } from '../session/ISession';
 import { CommentUpdateStatus, CommentsManager } from '../comments/CommentsManager';
 import ServerApp from '..';

+ 1 - 2
src/routes/PostUpdateSources.ts

@@ -1,5 +1,4 @@
-import {HttpMethod, Route, StatusCodes} from 'org.crazydoctor.expressts';
-import {Request, Response} from 'express';
+import {HttpMethod, Route, StatusCodes, Request, Response} from 'org.crazydoctor.expressts';
 import { spawn } from 'child_process';
 import * as path from 'path';
 import ServerApp from '..';

+ 1 - 1
src/sources/Sources.ts

@@ -125,7 +125,7 @@ class Sources {
 
 		const classes = [];
 
-		for(let key of keys)
+		for(const key of keys)
 			classes.push(Sources.ClassMap[key]);
 
 		return classes;