chore: add mock license server

This commit is contained in:
Ali BARIN
2023-09-29 21:09:06 +03:00
parent 174240a220
commit f79fc29203
5 changed files with 111 additions and 9 deletions

View File

@@ -0,0 +1,28 @@
const fs = require('node:fs');
const https = require('node:https');
const path = require('node:path');
const { run, send } = require('micro');
const options = {
key: fs.readFileSync(path.join(__dirname, './automatisch.io+4-key.pem')),
cert: fs.readFileSync(path.join(__dirname, './automatisch.io+4.pem')),
};
const microHttps = (fn) =>
https.createServer(options, (req, res) => run(req, res, fn));
const server = microHttps(async (req, res) => {
const data = {
id: '7f22d7dd-1fda-4482-83fa-f35bf974a21f',
name: 'Mocked license',
expireAt: '2030-08-09T10:56:54.144Z',
};
send(res, 200, data);
});
server
.once('listening', () => {
console.log('The mock server is up.');
})
.listen(443);