1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-08-09 23:45:25 +02:00

Renamed uploadFavicon to downLoadFavicon, removed log in locals.ts

This commit is contained in:
slaveeks 2022-07-06 12:38:23 +03:00
parent 2f8e362a52
commit 21829fc190
3 changed files with 6 additions and 8 deletions

View file

@ -9,7 +9,7 @@ import * as dotenv from 'dotenv';
import config from 'config'; import config from 'config';
import os from 'os'; import os from 'os';
import appConfig from 'config'; import appConfig from 'config';
import { uploadFavicon } from './utils/uploadFavicon'; import { downloadFavicon } from './utils/downloadFavicon';
dotenv.config(); dotenv.config();
const app = express(); const app = express();
@ -25,7 +25,7 @@ app.set('view engine', 'twig');
require('./utils/twig'); require('./utils/twig');
// Upload favicon by url, it's path on server is '/temp/favicon.{format}' // Upload favicon by url, it's path on server is '/temp/favicon.{format}'
uploadFavicon(faviconURL).then((res) => { downloadFavicon(faviconURL).then((res) => {
app.locals.favicon = res; app.locals.favicon = res;
console.log('Favicon successfully uploaded'); console.log('Favicon successfully uploaded');
}) })

View file

@ -1,7 +1,5 @@
import { NextFunction, Request, Response } from 'express'; import { NextFunction, Request, Response } from 'express';
console.log('Initiated');
/** /**
* Middleware for checking locals.isAuthorized property, which allows to edit/create pages * Middleware for checking locals.isAuthorized property, which allows to edit/create pages
* *

View file

@ -26,12 +26,12 @@ function checkIsUrl(str: string): boolean {
} }
/** /**
* Upload favicon by url * Upload favicon by url, or get it by path
* *
* @param destination - url for uploading favicon * @param destination - url or path of favicon
* @returns { Promise<string> } - Promise with format of saved file * @returns { Promise<FaviconData> } - Promise with data about favicon
*/ */
export async function uploadFavicon(destination: string): Promise<FaviconData> { export async function downloadFavicon(destination: string): Promise<FaviconData> {
// Check of destination is empty // Check of destination is empty
if (!destination) { if (!destination) {
throw Error('Favicon destination is empty'); throw Error('Favicon destination is empty');