The "node-snippets" extension provides a collection of useful code snippets for Node.js development. With this extension, you can streamline your development process and boost productivity by using pre-defined snippets for common Node.js patterns and operations.
Features
Console Log: Quickly add console.log statements.
Function Declaration: Easily insert function declarations.
Arrow Function: Generate arrow functions with a shortcut.
Create HTTP Server: Set up a basic HTTP server.
Import Module: Import Node.js modules with ease.
Try Catch Block: Add a try-catch block for error handling.
Async Function: Create async functions with error handling.
Express Basic Route: Set up a basic Express route.
Export Module: Export Node.js modules.
Read File: Read a file asynchronously.
Write File: Write content to a file asynchronously.
Event Emitter: Use the EventEmitter class for events.
HTTP Post Request: Send an HTTP POST request.
Mongoose Query: Query MongoDB using Mongoose.
Middleware in Express: Create and use Express middleware.
Handle Promises: Create and handle promises.
Cluster Module: Create a cluster of Node.js processes.
Tip: Check out the screenshots below to see these snippets in action!
Code Prefixes
Here are some useful code prefixes for quick access:
Code Prefixes
clog: Inserts a console.log statement.
fn: Creates a standard function.
af: Creates an arrow function.
http-server: Sets up a basic HTTP server.
import: Imports a module using require.
trycatch: Provides a basic try-catch block for error handling.
asyncfn: Defines an async function with error handling.
express-route: Sets up a basic route in an Express application.
export: Exports a module.
readfile: Reads a file asynchronously.
writefile: Writes content to a file asynchronously.
eventemitter: Creates and uses an EventEmitter.
http-post: Sends an HTTP POST request.
mongoose-query: Queries MongoDB using Mongoose.
express-middleware: Creates and uses middleware in Express.
promise: Creates and handles a Promise.
cluster: Creates a cluster of Node.js processes.
express-joi: Validate request body using Joi.
express-swagger: Set up Swagger for API documentation.
express-file-upload: Handle file uploads using Multer.
express-rate-limit: Set up rate limiting.
express-redis: Connect to Redis.
express-nodemailer: Send email using Nodemailer.
express-router: Create a new Express router.
express-static: Serve static files.
express-sse: Set up Server-Sent Events endpoint.
express-session-mongodb: Store sessions in MongoDB.
express-cors: Set up CORS middleware.
express-json-api: Serve a simple JSON API.
express-api-versioning: Set up API versioning.
express-graphql: Set up a GraphQL server.
mongoose-connection: Connect to MongoDB using Mongoose.
mongoose-model: Create a Mongoose model.
node-inspector: Start Node.js with debugging enabled.
express-serve-static: Serve static files using Express.
express-websocket: Set up a WebSocket server.
express-init: Initialize a basic Express app.
express-setup: Basic Express server setup
express-get: Define a GET route
express-post: Define a POST route
express-put: Define a PUT route
express-delete: Define a DELETE route
express-middleware: Define middleware
express-error: Define error handling middleware
express-router: Set up an Express router
express-static: Serve static files from a directory
express-view: Set up a template engine
express-custom-error: Render a custom 404 error page
express-json: Send a JSON response
express-redirect: Redirect to another URL
express-query: Access query parameters from the request
express-param: Access route parameters from the request
express-header: Set response headers
express-auth: Set up basic authentication middleware
express-cors: Set up CORS middleware
express-rate-limit: Set up rate limiting middleware
express-compression: Set up compression middleware
express-session: Set up session middleware
express-body-parser: Set up body parser middleware
express-file-upload: Set up file upload middleware
express-mongodb: Set up MongoDB connection
express-postgresql: Set up PostgreSQL connection
express-mysql: Set up MySQL connection
express-register: User registration route
express-login: User login route
Video Tutorial
Check out the video tutorial for a detailed overview of these snippets:
Video Tutorial
Check out the video tutorial for a detailed overview of these snippets:
Or [download the video](https://github.com/tushar-kant/nodejs-snippet/raw/main/node_video.mp4) to watch it locally.
Screenshots
Here are some screenshots demonstrating the use of these snippets:
Requirements
No additional requirements are needed for this extension. It works with Node.js and VS Code.
Extension Settings
This extension does not add any new settings to VS Code.
Known Issues
No known issues at this time.
Working with Markdown
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
Split the editor (Cmd+\ on macOS or Ctrl+\ on Windows and Linux).
Toggle preview (Shift+Cmd+V on macOS or Shift+Ctrl+V on Windows and Linux).
Press Ctrl+Space (Windows, Linux, macOS) to see a list of Markdown snippets.