The document provides an overview of using Node.js development with Apache NetBeans, addressing common misconceptions and presenting features such as support for JavaScript, HTML5, and various frameworks. It outlines a typical setup process, integration with Gulp, AWS Lambda testing, and unit testing frameworks. Additionally, it includes links for further resources and guides for setting up and running projects within the NetBeans environment.
NetBeans Misconceptions Following statementsare NOT TRUE: • JavaScript support is secondary • JavaScript integration is just for Java web apps • Projects must be created with NetBeans • Projects must be refactored to use NetBeans • NetBeans can’t deal with framework x and/or build tool y etc. NOT TRUE
Customizable Palette • DragHTML elements from Palette into HTML Window (Wizard appears) • Drag selections from HTML document to Palette to create new HTML snippets.
Typical Workflow npm initEdit package.json npm install NetBeans performs these tasks for us. Shell commands can be executed at any point – not locked into the IDE.
Unit Testing • SupportedUnit Testing frameworks: • Karma • JS Test Driver • Mocha • Demo • Jasmine – JavaScript unit testing framework • Tests written in JavaScript • Test synchronous and asychronous JavaScript code • Karma – JavaScript test runner • Based on NodeJS • Launches and executes tests in web browser
34.
Unit Testing Setup •For empty projects: • Add dependencies in package.json • Create karma.conf file • Configure testing • Implements tests • For existing projects: • Open project properties and configure
What is AWSLambda? • Function as a Service (Faas) from AWS • Stateless function that executes in the cloud • Executes in response to events (S3, DynamoDB, API Gateway, etc) • Can be implemented using • JavaScript (Node.js), Java, Python C# • Billed on executions: • First million executions are free • $0.20 per each million afterwards
39.
Example Lambda Function exports.handler= function(event,context) { context.succeed('Hello ' + event.firstName + ' ' + event.lastName + ' you are at JavaOne 2017!'); }; { "firstName": "Ryan", "lastName": "Cuprak” } Handler Function
40.
SAM – AWSLambda Testing https://github.com/awslabs/aws-sam-local
41.
AWS Lambda &NetBeans • NetBeans can test AWS Lambda locally • Prerequisites: • Install Docker • Install SAM Local - npm install -g aws-sam-local • Steps: 1. Create a Node.js project in NetBeans 2. Add aws-sdk to project via npm 3. Implement function 4. Add yaml configuration file 5. Add scripts entry to launch SAM
42.
AWS Lambda &NetBeans Debugging steps: 1. Start SAM in debug mode 2. Trigger event for invocation 3. Attach debugger