diff --git a/server/controller/domain.js b/server/controller/domain.js new file mode 100644 index 0000000..a257df5 --- /dev/null +++ b/server/controller/domain.js @@ -0,0 +1,9 @@ +const Domain = require('../models/Domain'); + +const exists = async (domainName) => (await Domain.findOne({where: {domainName}})) !== null; + +module.exports.getDomains = async () => (await Domain.findAll()).map(domain => (domain.domainName)); + +module.exports.deleteDomain = async (domainName) => await exists(domainName) ? await Domain.destroy({where: {domainName}}) : null; + +module.exports.createDomain = async (domainName) => !await exists(domainName) ? await Domain.create({domainName}) : null; \ No newline at end of file