Extension for Visual Studio Code to provide snippets for creating a full-stack Node.js application with Express, EJS, and AWS.
Publisher
IKPKITINTER
Description
This extension provides a collection of snippets to quickly scaffold a Node.js application. The snippets cover setting up the server, creating models, controllers, routes, and views.
Installation
- Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
- Install the extension from the Visual Studio Code Marketplace.
- npx express-generator --view=ejs . or npm init express-generator . --view=ejs
- Install the required dependencies for the snippets:
npm install aws-sdk dotenv express ejs multer
- npx kill-port 3000
Snippets
Here is a list of available snippets:
| Prefix |
Description |
aws_config_1 |
AWS Config Setup |
aws_middleware_2 |
Middleware Config |
aws_model_create_3 |
Model ticket model helper |
aws_model_get_4 |
DynamoDB queries by scan/id |
aws_model_search_5 |
DynamoDB Search |
aws_model_update_6 |
Model update |
aws_model_delete_7 |
Model delete |
aws_s3_upload_8 |
S3 upload |
aws_s3_delete_9 |
S3 Delete |
aws_s3_replace_10 |
S3 Replace |
aws_controller_getall_11 |
Controller GetAll |
aws_controller_getbyid_12 |
Controller GetByID |
aws_controller_validate_13 |
Controller Validate |
aws_controller_showadd_14 |
Controller Show Form Add |
aws_controller_logic_15 |
Controller Logic |
aws_controller_add_16 |
Controller Add |
aws_controller_showedit_17 |
Controller Show Edit |
aws_controller_edit_18 |
Controller Edit |
aws_controller_delete_19 |
Controller Delete |
aws_router_20 |
Router |
aws_app.js_21 |
App.js |
aws_view_index_22 |
View Index |
aws_view_add_23 |
View Add |
aws_view_edit_24 |
View edit |
aws_view_detail_25 |
View Detail |
How to use
- Create a new file.
- Type the prefix of the snippet you want to use (e.g.,
aws_config).
- Press
Enter or Tab to insert the snippet.
- Fill in the required information.
- Save the file.
Example
To create a new app.js file:
- Create a new file named
app.js.
- Type
aws_app.js.
- Press
Enter.
- The following code will be inserted:
require('dotenv').config();
const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.set('view engine', 'ejs');
app.set('views', './views');
app.use('/tickets', require('./routes/ticket.route'));
app.get('/', (_req, res) => res.redirect('/tickets'));
app.listen(PORT, () => {
console.log(`Server is running at http://localhost:${PORT}`);
});