import * as dotenv from 'dotenv';
dotenv.config();
import pkg from 'express';
const { Express } = pkg;
import { login } from 'masto';
import * as fspkg from 'fs';
const { fs } = fspkg;

const masto = await login({
    url: process.env.URL,
    accessToken: process.env.ACCESS_TOKEN,
});

console.log("selfcarebot starting...");

const data1 = fspkg.readFile('dataset1.json', 'utf8', (error, data) => {
    if (error){
        console.log(error);
        return;
    }
    console.log(JSON.parse(data));
})

const status = await masto.v1.statuses.create ({
    status: `${data1} selfcare! 🌸`,
    visibility: 'public',
  });

console.log('masto.v1.statuses', 'utf8', (error, data) => {
    if (error) {
        console.error(error);
    } else {
        fspkg.writeFileSync(data.json);
        console.log(data);
    }
    }
);