import { AISearchAPIClient } from 'aisearchapi-client';
const client = new AISearchAPIClient({
apiKey: 'YOUR_API_KEY'
});
const response = await client.search({
prompt: 'What are some security risks I should be aware of?',
context: [{
role: 'user',
content: 'I am developing a web app using Node.js and Express.'
}],
response_type: 'markdown'
});
console.log(response);
{
"answer": "### Node.js Security Risks and Mitigation Strategies\n\nWhen developing Node.js applications that handle personal data and deploy to AWS, you should be aware of several critical security risks:\n\n**Authentication and Authorization**\n- Implement secure session management\n- Use strong password policies and multi-factor authentication\n- Avoid hardcoded credentials in your code\n\n**Data Protection**\n- Encrypt sensitive data both in transit and at rest\n- Implement proper input validation and sanitization\n- Use HTTPS for all data transmission\n\n**Infrastructure Security**\n- Keep Node.js and dependencies up to date\n- Configure AWS security groups properly\n- Use AWS IAM roles with least privilege principle\n\n**Application Security**\n- Protect against common vulnerabilities like XSS, CSRF, and SQL injection\n- Implement rate limiting and request throttling\n- Use security headers like HSTS, CSP, and X-Frame-Options",
"response_type": "markdown",
"sources": [
"https://owasp.org/www-project-nodejs-goat/",
"https://nodejs.org/en/docs/guides/security/",
"https://aws.amazon.com/security/security-learning/"
],
"response_time": 2847
}
Execute a search query.
import { AISearchAPIClient } from 'aisearchapi-client';
const client = new AISearchAPIClient({
apiKey: 'YOUR_API_KEY'
});
const response = await client.search({
prompt: 'What are some security risks I should be aware of?',
context: [{
role: 'user',
content: 'I am developing a web app using Node.js and Express.'
}],
response_type: 'markdown'
});
console.log(response);
{
"answer": "### Node.js Security Risks and Mitigation Strategies\n\nWhen developing Node.js applications that handle personal data and deploy to AWS, you should be aware of several critical security risks:\n\n**Authentication and Authorization**\n- Implement secure session management\n- Use strong password policies and multi-factor authentication\n- Avoid hardcoded credentials in your code\n\n**Data Protection**\n- Encrypt sensitive data both in transit and at rest\n- Implement proper input validation and sanitization\n- Use HTTPS for all data transmission\n\n**Infrastructure Security**\n- Keep Node.js and dependencies up to date\n- Configure AWS security groups properly\n- Use AWS IAM roles with least privilege principle\n\n**Application Security**\n- Protect against common vulnerabilities like XSS, CSRF, and SQL injection\n- Implement rate limiting and request throttling\n- Use security headers like HSTS, CSP, and X-Frame-Options",
"response_type": "markdown",
"sources": [
"https://owasp.org/www-project-nodejs-goat/",
"https://nodejs.org/en/docs/guides/security/",
"https://aws.amazon.com/security/security-learning/"
],
"response_time": 2847
}
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Search request
The body is of type object
.
Search response
The response is of type object
.