https://github.com/joebertcerezo/ai_samp
This project is a secure Node.js app demonstrating OpenAI API integration with environment variables for sensitive data. It follows best practices for dependency management and credential handling. The setup is optimized for easy integration, scalability, and maintainability.
https://github.com/joebertcerezo/ai_samp
api github javascript node npm openai
Last synced: 3 months ago
JSON representation
This project is a secure Node.js app demonstrating OpenAI API integration with environment variables for sensitive data. It follows best practices for dependency management and credential handling. The setup is optimized for easy integration, scalability, and maintainability.
- Host: GitHub
- URL: https://github.com/joebertcerezo/ai_samp
- Owner: joebertcerezo
- Created: 2025-10-16T07:46:38.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2025-10-16T08:13:31.000Z (8 months ago)
- Last Synced: 2025-10-17T10:05:53.394Z (8 months ago)
- Topics: api, github, javascript, node, npm, openai
- Language: TypeScript
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AI_Samp
A secure Node.js sample for interacting with the OpenAI API using TypeScript.
## Features
- Uses [OpenAI Node.js SDK](https://www.npmjs.com/package/openai)
- Loads sensitive credentials from environment variables
- Example of a simple chat completion request
- Written in TypeScript with strict settings
- Follows best practices for configuration and dependency management
## Getting Started
### Prerequisites
- [Node.js](https://nodejs.org/) (v18+ recommended)
- An OpenAI API key
### Installation
1. Clone the repository:
```sh
git clone https://github.com/your-username/github_copilot.git
cd github_copilot
```
2. Install dependencies:
```sh
npm install
```
3. Copy the example environment file and set your credentials:
```sh
cp .env.example .env
# Edit .env and add your GITHUB_TOKEN (OpenAI API key)
```
### Usage
Build and run the sample script:
```sh
npm run dev
```
Or manually:
```sh
npx tsc
node ./dist/index.js
```
## Security Considerations
- **Never commit your `.env` file or API keys to version control.**
- All sensitive configuration is loaded from environment variables.
- Dependencies are kept up-to-date to minimize vulnerabilities.
- Avoid logging sensitive data.
## Project Structure
```
.
├── .env.example # Environment variable template
├── .gitignore
├── package.json
├── tsconfig.json
├── src/
│ └── index.ts # Main sample script (TypeScript)
└── README.md
```
## Best Practices
- Use environment variables for all secrets and API keys.
- Keep dependencies updated and audit regularly.
- Avoid logging sensitive data.
- Use `.gitignore` to prevent accidental commits of sensitive files.
- Use TypeScript strict mode for safer code.