Skip to content

Instantly share code, notes, and snippets.

@dminkovski
Created February 12, 2025 22:57
Show Gist options
  • Save dminkovski/a44262f318538acb72fe0e37f3cb367d to your computer and use it in GitHub Desktop.
Save dminkovski/a44262f318538acb72fe0e37f3cb367d to your computer and use it in GitHub Desktop.
copilot-instructions.txt
# GitHub Copilot Instructions for REST API Development
## General Guidelines:
- Follow modern **TypeScript** best practices.
- Prioritize **modular and reusable code** for maintainability.
- Always use **ESLint** and **Prettier** for code formatting and linting.
- Ensure compatibility with **Node.js LTS versions**.
## API Development:
- Adhere to **RESTful API principles**.
- Use **Express.js** for backend services.
- Apply authentication using **OAuth2 or JWT**.
## Security Practices:
- Never expose secrets or credentials in code.
- Use **environment variables** for sensitive information.
- Implement **rate limiting** to prevent abuse.
- Sanitize user input to avoid **SQL injection & XSS attacks**.
## Code Structure:
- Organize files under `/src` with subfolders:
- `/controllers` → Request handling logic.
- `/services` → Business logic.
- `/models` → Database schemas & types.
- `/routes` → API endpoint definitions.
- `/middleware` → Authentication & logging middleware.
## Tooling & Automation:
- Use **GitHub Actions** for CI/CD.
- All code must pass unit tests before merging.
- Automatically generate API docs using **Swagger (OpenAPI 3.0)**.
- Implement **error logging** using Winston or Pino.
## Copilot Behavior:
- When suggesting code:
- Prefer **documented solutions** with inline comments.
- Suggest **efficient and optimized** algorithms.
- Provide **alternative approaches** if applicable.
## Testing:
- Write tests using **Jest** for unit testing.
- Use **Supertest** for API endpoint testing.
- Ensure **at least 80% code coverage**.
## Deployment:
- Deploy applications to **Azure App Service** or **Azure Kubernetes Service (AKS)**.
- Use **Bicep or Terraform** for infrastructure provisioning.
- Always use **Managed Identity** for authentication in Azure.
# Final Note:
- If generating documentation, follow **Markdown format**.
- Avoid hallucinating responses-only suggest best practices.
- Do not assume configurations-verify against `.env`, `package.json` and `config.json`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment