10/3/24
This commit is contained in:
@@ -18,15 +18,15 @@ type asyncDatabaseVoidCallbackFunction = () => any;
|
||||
* @param {asyncDatabaseRowsCallbackFunction} callback callback to perform further operations on each row
|
||||
* @returns {Promise<Type>} Promise for database operation
|
||||
*/
|
||||
const asyncDatabaseRead = <Type>(
|
||||
const asyncDatabaseRead = async <Type>(
|
||||
database: sqlite3.Database,
|
||||
sqlQuery: string,
|
||||
callback: asyncDatabaseRowsCallbackFunction
|
||||
): Promise<Type> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
database.all(sqlQuery, (err: any, rows) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
database.all(sqlQuery, (error: Error, rows: any) => {
|
||||
if (error !== null) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(callback(rows));
|
||||
}
|
||||
@@ -42,15 +42,15 @@ const asyncDatabaseRead = <Type>(
|
||||
* @param {asyncDatabaseVoidCallbackFunction} callback callback to perform after the operation
|
||||
* @returns {Promise<Type>} Promise for database operation
|
||||
*/
|
||||
const asyncDatabaseWrite = <Type>(
|
||||
const asyncDatabaseWrite = async <Type>(
|
||||
database: sqlite3.Database,
|
||||
sqlQuery: string,
|
||||
callback: asyncDatabaseVoidCallbackFunction
|
||||
): Promise<Type> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
database.run(sqlQuery, (err: any) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
database.run(sqlQuery, (error: Error) => {
|
||||
if (error !== null) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(callback());
|
||||
}
|
||||
|
||||
20
utils/linkCard.ts
Normal file
20
utils/linkCard.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Type for LinkCard component
|
||||
* @module utils/linkCard
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface that defines property for LinkCard component
|
||||
* @property {string} title title of link
|
||||
* @property {string} description description of link
|
||||
* @property {string} link link itself
|
||||
* @property {string=} imagePath optional path to image to display with
|
||||
*/
|
||||
interface LinkCardProperty {
|
||||
title: string;
|
||||
description: string;
|
||||
link: string;
|
||||
imagePath?: string;
|
||||
}
|
||||
|
||||
export type { LinkCardProperty };
|
||||
@@ -8,7 +8,7 @@
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
*/
|
||||
export const enum EntryType {
|
||||
const enum EntryType {
|
||||
Article,
|
||||
Tweet,
|
||||
}
|
||||
@@ -47,3 +47,4 @@ interface NewsEntry {
|
||||
}
|
||||
|
||||
export type { ArticleInfo, NewsEntry };
|
||||
export { EntryType };
|
||||
|
||||
Reference in New Issue
Block a user