Node.js Snippets for VS Code
A comprehensive collection of Node.js snippets for Visual Studio Code.
⚠️ Disclaimer ⚠️
This extension is not an official Node.js product. It is a third-party extension created to enhance the Node.js development experience in VS Code.
Credits
Features
- Snippets for Express.js server setup
- Async/await function templates
- MongoDB/Mongoose integration snippets
- JWT authentication snippets
- Error handling middleware
- Environment variables configuration
- File upload handling
- TypeScript-specific snippets
- Security features (Helmet)
- And much more!
Snippets
JavaScript Snippets
Prefix |
Description |
express-server |
Create a basic Express server |
express-helmet |
Create a secure Express server with Helmet |
async-fn |
Create an async function with try-catch |
fetch-api |
Create a fetch API request |
mongodb-connect |
Create MongoDB connection with Mongoose |
mongoose-model |
Create a Mongoose model with schema |
jwt-auth |
Create JWT authentication middleware |
error-handler |
Create an error handling middleware |
env-vars |
Create environment variables configuration |
file-upload |
Create file upload configuration with Multer |
express-route |
Create an Express route handler |
express-post |
Create an Express POST route handler |
custom-middleware |
Create a custom Express middleware |
TypeScript Snippets
Prefix |
Description |
express-ts |
Create a basic Express server with TypeScript |
express-helmet-ts |
Create a secure Express server with Helmet and TypeScript |
async-fn-ts |
Create an async function with TypeScript |
interface |
Create a TypeScript interface |
type |
Create a TypeScript type |
mongoose-model-ts |
Create a Mongoose model with TypeScript |
controller-ts |
Create a controller with TypeScript |
middleware-ts |
Create a middleware with TypeScript |
service-ts |
Create a service class with TypeScript |
express-route-ts |
Create an Express route handler with TypeScript |
express-post-ts |
Create an Express POST route handler with TypeScript |
error-handler-ts |
Create an error handling middleware with TypeScript |
Usage
- Install the extension
- Open a JavaScript or TypeScript file
- Type the prefix of the snippet you want to use
- Press
Tab or Enter to insert the snippet
- Use
Tab to navigate through the placeholders
Requirements
- Visual Studio Code 1.60.0 or higher
- Node.js 14.0.0 or higher (for running the snippets)
Extension Settings
This extension contributes the following settings:
nodejs-snippets.enable : Enable/disable the extension
nodejs-snippets.showSuggestions : Show/hide suggestions in the editor
Known Issues
None at the moment. Please report any issues to the extension author.
Release Notes
1.0.0
Initial release of Node.js Snippets with:
- Basic Express server setup
- Async/await function templates
- MongoDB/Mongoose integration
- JWT authentication
- Error handling
- Environment variables
- File upload handling
- TypeScript support
- Security features (Helmet)
- Standardized naming conventions
Contributing
We welcome your feedback and suggestions to improve these snippets.
License
This project is licensed under the MIT License - see the LICENSE file for details.
| |