27 lines
635 B
JavaScript
27 lines
635 B
JavaScript
const http = require('https');
|
|
|
|
const data = JSON.stringify({
|
|
"description": "Public search only key",
|
|
"actions": ["documents:search"],
|
|
"collections": ["blogs"]
|
|
});
|
|
|
|
const options = {
|
|
hostname: 'typesense.biss.click', // 不要带 https://
|
|
port: 443,
|
|
path: '/keys',
|
|
method: 'POST',
|
|
headers: {
|
|
'X-TYPESENSE-API-KEY': 'tDPfzkghH3Zy55DHyWOnYkQiijOqN8bx',
|
|
'Content-Type': 'application/json',
|
|
'Content-Length': data.length
|
|
}
|
|
};
|
|
|
|
const req = http.request(options, res => {
|
|
res.on('data', d => { process.stdout.write(d); });
|
|
});
|
|
|
|
req.on('error', error => { console.error(error); });
|
|
req.write(data);
|
|
req.end(); |