updated exports
This commit is contained in:
parent
f56eccefbd
commit
c1c77efaf0
@ -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'));
|
||||
module.exports = {
|
||||
generateLicenseKey,
|
||||
hashLicenseKey,
|
||||
saveLicense,
|
||||
getLicense,
|
||||
verifyLicenseKey
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user