From c1c77efaf0998f5de46d2a706c13cc57f6588817 Mon Sep 17 00:00:00 2001 From: thompsonjd85 Date: Wed, 19 Mar 2025 15:02:42 -0500 Subject: [PATCH] updated exports --- server/index.js | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/server/index.js b/server/index.js index abdb413..068df04 100644 --- a/server/index.js +++ b/server/index.js @@ -1,26 +1,12 @@ -// server/index.js -const express = require('express'); +// license-lib/server/index.js const { generateLicenseKey, hashLicenseKey } = require('./keygen'); -const { saveLicense } = require('./models/license'); +const { saveLicense, getLicense } = require('./models/license'); const { verifyLicenseKey } = require('./verify'); -const app = express(); -app.use(express.json()); - -app.post('/generate-license', async (req, res) => { - const { userId, licenseType, tier, validUntil } = req.body; - const licenseKey = generateLicenseKey(userId, licenseType, tier); - const hashedKey = hashLicenseKey(JSON.parse(Buffer.from(licenseKey.split('.')[1], 'base64')).rawKey); - - await saveLicense(userId, hashedKey, licenseType, tier, validUntil); - - res.json({ licenseKey }); -}); - -app.post('/validate-license', async (req, res) => { - const { userId, licenseKey } = req.body; - const valid = await verifyLicenseKey(userId, licenseKey); - res.json({ valid }); -}); - -app.listen(3000, () => console.log('License server running on port 3000')); \ No newline at end of file +module.exports = { + generateLicenseKey, + hashLicenseKey, + saveLicense, + getLicense, + verifyLicenseKey +};