therootcompany / greenlock.js

🔐 Free SSL, Free Wildcard SSL, and Fully Automated HTTPS for node.js, issued by Let's Encrypt v2 via ACME
https://git.rootprojects.org/root/greenlock.js
Mozilla Public License 2.0
63 stars 16 forks source link

Using greenlock without express module #5

Open mirsahib opened 2 years ago

mirsahib commented 2 years ago

I am trying to use the only the greenlock module with my server so that I have more customization capability The code is given below

const app = require('./app.ts');
const path = require('path');
const pkg = require('../package.json');
const rootdir = path.join(__dirname, '../');
console.log(rootdir);
const Greenlock = require('greenlock');
const greenlock = Greenlock.create({
    packageRoot: rootdir,
    configDir: './greenlock.d/',
    packageAgent: pkg.name + '/' + pkg.version,
    maintainerEmail: 'mir@bonton.app',
    staging: false,
    notify: function (event: any, details: any) {
        if ('error' === event) {
            // `details` is an error object in this case
            console.error('details', details);
        }
    },
});

greenlock.manager
    .defaults({
        agreeToTerms: true,
        subscriberEmail: 'mir@bonton.app'
    })
    .then(function(fullConfig:any) {
        console.log('fullconfig',fullConfig)
    });

const altnames = ['con.getbonton.com'];

greenlock
    .add({
        subject: altnames[0],
        altnames: altnames,
    })
    .then(function (data: any) {
        // saved config to db (or file system)
        console.log('config', data);
    });
app.listen(80)
app.listen(443)

I am getting dry challenge failed error when I try to run the above code