2023-08-10 15:28:48 +00:00
import { db } from "./db.mjs"
2023-08-12 10:05:24 +00:00
import { isoDate } from "../utilities.mjs"
import logger from "../logger.mjs"
2023-08-10 15:28:48 +00:00
const sampleRes = {
2023-08-12 14:55:25 +00:00
createdNote : {
id : '9i8urek4jtzhmtuh' ,
createdAt : '2023-08-10T15:02:35.380Z' ,
userId : '9i5z5o9zy11l3skl' ,
user : {
id : '9i5z5o9zy11l3skl' ,
name : null ,
username : 'micro365' ,
host : null ,
avatarUrl : 'https://localhost:3000/files/thumbnail-4e0e8b82-df72-48f7-8100-b7515173da9d' ,
avatarBlurhash : 'ySPjGct7xu%M-;xu-;%MRjWBoffQofWB~qRjRjayRjfQM{M{t7ofWBt7ayfQ~qj[WBj[M{WBof?bofayfQM{WBfQt7xuofWBofofM{' ,
avatarColor : null ,
isLocked : false ,
speakAsCat : true ,
2023-08-10 15:28:48 +00:00
emojis : [ ] ,
2023-08-12 14:55:25 +00:00
onlineStatus : 'active' ,
driveCapacityOverrideMb : null
} ,
text : "Today's #micro365 prompt is:\n" +
'<small><small><small># </small></small></small>$[x2 $[font.serif **marmalade**]]\n' +
'/mˈ ɑ ː mɐlˌe ɪ d/\n' +
'<small>**noun**:\n' +
'- A kind of jam made with citrus fruit, distinguished by being made slightly bitter by the addition of the peel and by partial caramelisation during manufacture. Most commonly made with Seville oranges, and usually qualified by the name of the fruit when made with other types of fruit.\n' +
'- A kind of jam made with citrus fruit, distinguished by being made slightly bitter by the addition of the peel and by partial caramelisation during manufacture. Most commonly made with Seville oranges, and usually qualified by the name of the fruit when made with other types of fruit. Ellipsis of orange marmalade.\n' +
'- quince jam\n' +
'**verb**:\n' +
'- To spread marmalade on.\n' +
'</small>#writing #microfiction #vss #marmalade' ,
cw : null ,
visibility : 'public' ,
renoteCount : 0 ,
repliesCount : 0 ,
reactions : { } ,
reactionEmojis : [ ] ,
emojis : [ ] ,
tags : [ 'micro365' , 'writing' , 'microfiction' , 'vss' , 'marmalade' ] ,
fileIds : [ ] ,
files : [ ] ,
replyId : null ,
renoteId : null
2023-08-10 15:28:48 +00:00
}
2023-08-12 14:55:25 +00:00
}
2023-08-10 15:28:48 +00:00
2023-08-12 14:55:25 +00:00
export default async function insertPublished ( res , word ) {
logger . trace ( "insertPublished called" )
try {
2023-08-10 15:28:48 +00:00
return db ( 'published' )
2023-08-12 14:55:25 +00:00
. insert ( {
2023-08-10 15:28:48 +00:00
id : res . createdNote . id ,
word ,
2023-08-10 18:18:23 +00:00
date : isoDate ( sampleRes . createdNote . createdAt )
2023-08-12 14:55:25 +00:00
} )
} catch ( error ) {
throw error
}
2023-08-10 15:28:48 +00:00
}
//console.log(await insertPublished(sampleRes,'marmalade'))