lint: Require semicolons

This commit is contained in:
Cohee
2023-12-02 21:11:06 +02:00
parent 2ec14a59ee
commit c63cd87cc0
67 changed files with 1554 additions and 1552 deletions

View File

@@ -73,7 +73,7 @@ function registerEndpoints(app, jsonParser) {
*/
app.post('/api/assets/get', jsonParser, async (_, response) => {
const folderPath = path.join(DIRECTORIES.assets);
let output = {}
let output = {};
//console.info("Checking files into",folderPath);
try {
@@ -150,8 +150,8 @@ function registerEndpoints(app, jsonParser) {
if (safe_input == '')
return response.sendStatus(400);
const temp_path = path.join(DIRECTORIES.assets, 'temp', safe_input)
const file_path = path.join(DIRECTORIES.assets, category, safe_input)
const temp_path = path.join(DIRECTORIES.assets, 'temp', safe_input);
const file_path = path.join(DIRECTORIES.assets, category, safe_input);
console.debug('Request received to download', url, 'to', file_path);
try {
@@ -209,7 +209,7 @@ function registerEndpoints(app, jsonParser) {
if (safe_input == '')
return response.sendStatus(400);
const file_path = path.join(DIRECTORIES.assets, category, safe_input)
const file_path = path.join(DIRECTORIES.assets, category, safe_input);
console.debug('Request received to delete', category, file_path);
try {
@@ -248,10 +248,10 @@ function registerEndpoints(app, jsonParser) {
const inputCategory = request.query.category;
// Check category
let category = null
let category = null;
for (let i of VALID_CATEGORIES)
if (i == inputCategory)
category = i
category = i;
if (category === null) {
console.debug('Bad request: unsuported asset category.');
@@ -266,7 +266,7 @@ function registerEndpoints(app, jsonParser) {
// Live2d assets
if (category == 'live2d') {
const folders = fs.readdirSync(folderPath)
const folders = fs.readdirSync(folderPath);
for (let modelFolder of folders) {
const live2dModelPath = path.join(folderPath, modelFolder);
if (fs.statSync(live2dModelPath).isDirectory()) {
@@ -326,4 +326,4 @@ function registerEndpoints(app, jsonParser) {
module.exports = {
registerEndpoints,
}
};

View File

@@ -39,10 +39,10 @@ function convertClaudePrompt(messages, addHumanPrefix, addAssistantPostfix, with
switch (v.role) {
case 'assistant':
prefix = '\n\nAssistant: ';
break
break;
case 'user':
prefix = '\n\nHuman: ';
break
break;
case 'system':
// According to the Claude docs, H: and A: should be used for example conversations.
if (v.name === 'example_assistant') {
@@ -52,7 +52,7 @@ function convertClaudePrompt(messages, addHumanPrefix, addAssistantPostfix, with
} else {
prefix = '\n\n';
}
break
break;
}
return prefix + v.content;
}).join('');
@@ -74,4 +74,4 @@ function convertClaudePrompt(messages, addHumanPrefix, addAssistantPostfix, with
module.exports = {
convertClaudePrompt,
}
};

View File

@@ -138,4 +138,4 @@ module.exports = {
UNSAFE_EXTENSIONS,
UPLOADS_PATH,
PALM_SAFETY,
}
};

View File

@@ -153,7 +153,7 @@ function parseChubUrl(str) {
if (part === 'www.chub.ai' || part === 'chub.ai') {
domainIndex = index;
}
})
});
const lastTwo = domainIndex !== -1 ? splitStr.slice(domainIndex + 1) : splitStr;
@@ -192,7 +192,7 @@ async function downloadJannyCharacter(uuid) {
if (result.ok) {
const downloadResult = await result.json();
if (downloadResult.status === 'ok') {
const imageResult = await fetch(downloadResult.downloadUrl)
const imageResult = await fetch(downloadResult.downloadUrl);
const buffer = await imageResult.buffer();
const fileName = `${sanitize(uuid)}.png`;
const fileType = result.headers.get('content-type');
@@ -216,7 +216,7 @@ function parseJannyUrl(url) {
// Check if UUID is found
const uuid = matches ? matches[0] : null;
return uuid
return uuid;
}
/**
@@ -235,7 +235,7 @@ function registerEndpoints(app, jsonParser) {
let result;
let type;
const isJannnyContent = url.includes('janitorai')
const isJannnyContent = url.includes('janitorai');
if (isJannnyContent) {
const uuid = parseJannyUrl(url);
if (!uuid) {
@@ -261,7 +261,7 @@ function registerEndpoints(app, jsonParser) {
}
}
if (result.fileType) response.set('Content-Type', result.fileType)
if (result.fileType) response.set('Content-Type', result.fileType);
response.set('Content-Disposition', `attachment; filename="${result.fileName}"`);
response.set('X-Custom-Content-Type', type);
return response.send(result.buffer);
@@ -275,4 +275,4 @@ function registerEndpoints(app, jsonParser) {
module.exports = {
checkForNewContent,
registerEndpoints,
}
};

View File

@@ -14,4 +14,4 @@ async function getTransformersVector(text) {
module.exports = {
getTransformersVector,
}
};

View File

@@ -247,4 +247,4 @@ function registerEndpoints(app, jsonParser) {
module.exports = {
registerEndpoints,
}
};

View File

@@ -177,7 +177,7 @@ function registerEndpoints(app, jsonParser) {
console.error(error);
return response.sendStatus(500);
}
})
});
app.post('/api/horde/generate-image', jsonParser, async (request, response) => {
if (!request.body.prompt) {

View File

@@ -32,6 +32,6 @@ const basicAuthMiddleware = function (request, response, callback) {
} else {
return unauthorizedResponse(response);
}
}
};
module.exports = basicAuthMiddleware;

View File

@@ -10,7 +10,7 @@ const API_NOVELAI = 'https://api.novelai.net';
const badWordsList = [
[3], [49356], [1431], [31715], [34387], [20765], [30702], [10691], [49333], [1266],
[19438], [43145], [26523], [41471], [2936], [85, 85], [49332], [7286], [1115]
]
];
const hypeBotBadWordsList = [
[58], [60], [90], [92], [685], [1391], [1782], [2361], [3693], [4083], [4357], [4895],
@@ -37,16 +37,16 @@ const repPenaltyAllowList = [
1096, 2919, 2072, 7379, 1259, 2110, 620, 526, 487, 16562, 603, 805, 761, 2681, 942, 8917, 653, 3513, 506, 5301,
562, 5010, 614, 10942, 539, 2976, 462, 5189, 567, 2032, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 588,
803, 1040, 49209, 4, 5, 6, 7, 8, 9, 10, 11, 12]
]
];
// Ban the dinkus and asterism
const logitBiasExp = [
{ 'sequence': [23], 'bias': -0.08, 'ensure_sequence_finish': false, 'generate_once': false },
{ 'sequence': [21], 'bias': -0.08, 'ensure_sequence_finish': false, 'generate_once': false }
]
];
function getBadWordsList(model) {
let list = []
let list = [];
if (model.includes('hypebot')) {
list = hypeBotBadWordsList;
@@ -176,7 +176,7 @@ function registerEndpoints(app, jsonParser) {
}
};
console.log(util.inspect(data, { depth: 4 }))
console.log(util.inspect(data, { depth: 4 }));
const args = {
body: JSON.stringify(data),
@@ -317,7 +317,7 @@ function registerEndpoints(app, jsonParser) {
return response.send(upscaledBase64);
} catch (error) {
console.warn('NovelAI generated an image, but upscaling failed. Returning original image.');
return response.send(originalBase64)
return response.send(originalBase64);
}
} catch (error) {
console.log(error);

View File

@@ -108,4 +108,4 @@ function registerEndpoints(app, jsonParser) {
module.exports = {
registerEndpoints,
}
};

View File

@@ -23,7 +23,7 @@ const SECRET_KEYS = {
DEEPLX_URL: 'deeplx_url',
PALM: 'api_key_palm',
SERPAPI: 'api_key_serpapi',
}
};
/**
* Writes a secret to the secrets file
@@ -199,10 +199,10 @@ function registerEndpoints(app, jsonParser) {
return response.sendStatus(403);
}
const key = request.body.key
const key = request.body.key;
try {
const secret = readSecret(key)
const secret = readSecret(key);
if (!secret) {
response.sendStatus(404);

View File

@@ -264,4 +264,4 @@ function registerEndpoints(app, jsonParser, urlencodedParser) {
module.exports = {
registerEndpoints,
importRisuSprites,
}
};

View File

@@ -244,7 +244,7 @@ function registerEndpoints(app, jsonParser) {
for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
const progressState = await getProgress();
const progress = progressState['progress']
const progress = progressState['progress'];
const jobCount = progressState['state']['job_count'];
if (progress == 0.0 && jobCount === 0) {
break;
@@ -360,7 +360,7 @@ function registerEndpoints(app, jsonParser) {
app.post('/api/sd/comfy/ping', jsonParser, async (request, response) => {
try {
const url = new URL(request.body.url);
url.pathname = '/system_stats'
url.pathname = '/system_stats';
const result = await fetch(url);
if (!result.ok) {
@@ -377,7 +377,7 @@ function registerEndpoints(app, jsonParser) {
app.post('/api/sd/comfy/samplers', jsonParser, async (request, response) => {
try {
const url = new URL(request.body.url);
url.pathname = '/object_info'
url.pathname = '/object_info';
const result = await fetch(url);
if (!result.ok) {
@@ -395,7 +395,7 @@ function registerEndpoints(app, jsonParser) {
app.post('/api/sd/comfy/models', jsonParser, async (request, response) => {
try {
const url = new URL(request.body.url);
url.pathname = '/object_info'
url.pathname = '/object_info';
const result = await fetch(url);
if (!result.ok) {
@@ -412,7 +412,7 @@ function registerEndpoints(app, jsonParser) {
app.post('/api/sd/comfy/schedulers', jsonParser, async (request, response) => {
try {
const url = new URL(request.body.url);
url.pathname = '/object_info'
url.pathname = '/object_info';
const result = await fetch(url);
if (!result.ok) {
@@ -430,7 +430,7 @@ function registerEndpoints(app, jsonParser) {
app.post('/api/sd/comfy/vaes', jsonParser, async (request, response) => {
try {
const url = new URL(request.body.url);
url.pathname = '/object_info'
url.pathname = '/object_info';
const result = await fetch(url);
if (!result.ok) {
@@ -503,7 +503,7 @@ function registerEndpoints(app, jsonParser) {
app.post('/api/sd/comfy/generate', jsonParser, async (request, response) => {
try {
const url = new URL(request.body.url);
url.pathname = '/prompt'
url.pathname = '/prompt';
const promptResult = await fetch(url, {
method: 'POST',

View File

@@ -53,7 +53,7 @@ function getOriginalFolder(type) {
*/
function invalidateThumbnail(type, file) {
const folder = getThumbnailFolder(type);
if (folder === undefined) throw new Error('Invalid thumbnail type')
if (folder === undefined) throw new Error('Invalid thumbnail type');
const pathToThumbnail = path.join(folder, file);
@@ -69,9 +69,9 @@ function invalidateThumbnail(type, file) {
* @returns
*/
async function generateThumbnail(type, file) {
let thumbnailFolder = getThumbnailFolder(type)
let originalFolder = getOriginalFolder(type)
if (thumbnailFolder === undefined || originalFolder === undefined) throw new Error('Invalid thumbnail type')
let thumbnailFolder = getThumbnailFolder(type);
let originalFolder = getOriginalFolder(type);
if (thumbnailFolder === undefined || originalFolder === undefined) throw new Error('Invalid thumbnail type');
const pathToCachedFile = path.join(thumbnailFolder, file);
const pathToOriginalFile = path.join(originalFolder, file);
@@ -199,4 +199,4 @@ module.exports = {
invalidateThumbnail,
registerEndpoints,
ensureThumbnailCache,
}
};

View File

@@ -324,7 +324,7 @@ function createTiktokenEncodingHandler(modelId) {
console.log(error);
return response.send({ ids: [], count: 0, chunks: [] });
}
}
};
}
/**
@@ -348,7 +348,7 @@ function createTiktokenDecodingHandler(modelId) {
console.log(error);
return response.send({ text: '' });
}
}
};
}
/**
@@ -546,5 +546,5 @@ module.exports = {
registerEndpoints,
getSentencepiceTokenizer,
sentencepieceTokenizers,
}
};

View File

@@ -222,7 +222,7 @@ function registerEndpoints(app, jsonParser) {
const text = request.body.text;
let lang = request.body.lang;
if (request.body.lang === 'zh-CN') {
lang = 'ZH'
lang = 'ZH';
}
if (!text || !lang) {
@@ -268,7 +268,7 @@ function registerEndpoints(app, jsonParser) {
let lang = request.body.lang;
if (request.body.lang === 'zh-CN') {
lang = 'zh-Hans'
lang = 'zh-Hans';
}
if (!text || !lang) {

View File

@@ -124,4 +124,4 @@ class TavernCardValidator {
}
}
module.exports = {TavernCardValidator}
module.exports = { TavernCardValidator };