CI / Docker image (push) Successful in 12s
CI / Server (push) Successful in 25s
CI / CLI (push) Successful in 13s
Development image / Development image (push) Successful in 21s
CI / CLI (windows) (push) Successful in 57s
CI / CLI (linux-arm64, static) (push) Successful in 1m37s
Release / Prepare release (push) Successful in 2s
Release / Server (linux-x64) (push) Successful in 53s
Release / CLI (linux-arm64, static) (push) Successful in 1m32s
Release / Docker image (push) Successful in 2m48s
Release / Server (windows-x64) (push) Successful in 6m20s
Release / CLI (windows-x64) (push) Successful in 6m48s
Release / CLI (linux-x64) (push) Successful in 7m8s
Release / Publish release (push) Successful in 1s
Squash the tree into one commit, drop docs/architecture.html, reset the version line to 0.3.0, consolidate the changelog, enable Renovate automerge for non-major updates and add AGENTS.md.
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
const Acme = require("../../models/Acme");
|
|
const Certificate = require("../../models/Certificate");
|
|
|
|
const DEFAULTS = { email: null, provider: "manual", credential: null, accountKey: null };
|
|
|
|
const settings = async () => {
|
|
const row = await Acme.findOne();
|
|
return row ? { ...DEFAULTS, ...row } : { ...DEFAULTS };
|
|
};
|
|
|
|
const saveSettings = async values => {
|
|
const row = await Acme.findOne();
|
|
if (row) return Acme.update(values, { where: { id: row.id } });
|
|
return Acme.create({ ...DEFAULTS, ...values });
|
|
};
|
|
|
|
const certificate = domain => Certificate.findOne({ where: { domain } });
|
|
|
|
const certificates = () => Certificate.findAll();
|
|
|
|
const saveCertificate = async ({ domain, altNames, privateKey, chain, expiresAt }) => {
|
|
const values = {
|
|
domain, altNames: JSON.stringify(altNames), privateKey, chain,
|
|
issuedAt: new Date(), expiresAt,
|
|
};
|
|
const row = await Certificate.findOne({ where: { domain } });
|
|
if (row) return Certificate.update(values, { where: { id: row.id } });
|
|
return Certificate.create(values);
|
|
};
|
|
|
|
const forgetCertificate = domain => Certificate.destroy({ where: { domain } });
|
|
|
|
module.exports = { settings, saveSettings, certificate, certificates, saveCertificate, forgetCertificate };
|