This document provides an overview of a guided hackathon to build a single page application using the MEAN stack (MongoDB, Express, AngularJS, Node.js) in 2 hours. It outlines the concepts that will be covered, including API testing, DOM integration testing, build systems, and more. Attendees will build a package manager for the Go programming language, creating the server with Express and Mongoose, and the client with AngularJS and Browserify. Testing will be done with Mocha, Karma, and other tools.
Replace Angular with React. Make the move from the MEAN stack to the powerful MERN Stack!
Come and learn about the MERN stack. No, that isn't a typo. The MERN stack is Mongo, Express, and Node, with React instead of Angular. While both React and Angular are remarkable JavaScript technologies, React comes with less baggage. There is no TypeScript, no annotations, no bossy framework telling you how to do everything.
Slide deck presented during my session on "Mean Stack - An Overview" at JavaScript Meetup #6 on Saturday, September 24, 2016. The meetup was at Akamai Technologies, Bengaluru.
MongoDB Days Silicon Valley: Building Applications with the MEAN StackMongoDB
Presented by Jason Zucchetto, Curriculum Engineer, MongoDB
Experience level: Introductory
Walk through building a sample application with the MEAN stack (MongoDB-Express-Angular-Node.js). We'll start from the beginning, walking through every component of the MEAN stack, in building a modern web application. The presentation focuses on building MongoMart, a simple application for searching and viewing MongoDB merchandise. You'll walk away with a basic knowledge of MEAN stack components and how to leverage them in building applications.
1. Isomorphic JavaScript is the pattern of running JavaScript code on both server & client.
2. People are using it for production today. Ask Facebook, Yahoo, Asana, Airbnb, Rising Stack, …
3. This is not another talk about NodeJS!
In this article, I’d like to tell you about 7 Node JS project ideas that will help you train your skills, build an impressive portfolio, and get hired.
For some time, I’m publishing the lists of projects that you can use to practice the coding skills that you’ve just learned. I was focusing mostly on frontend technologies, but today I decided to jump to the Javascript backend framework called Node JS.
MEAN Stack technology is a full-stack JavaScript solution that helps you build fast and very light weight web application. The web application made under MEAN stack is fast because the Node js which is run time environment made by C++ which is very fast as compare to other languages.
MEAN is acronym of Mongodb, Express js, Angular js, Node js. The MEAN stack technology is very easy to learn because MEAN is completely based on JavaScript which means you don't have to learn different languages for implementing this.
Escaping the yellow bubble - rewriting Domino using MongoDb and AngularMark Leusink
Slides from my ICON UK 2014 session held on September 13, 2014 at IBM Southbank, London.
The session was an introduction to the MEAN stack (Mongo, Express, Angular and Node).
In this session, we will walk through building a REST API from scratch with the MEAN stack using the test-driven development approach. We’ll cover MongoDB’s document model, the Mongoose object document mapper, and testing with Mocha and Superagent as we build a mobile shopping cart application. You'll walk away with an understanding of how to build your first app on MongoDB using the MEAN stack.
Replace Angular with React. Make the move from the MEAN stack to the powerful MERN Stack!
Come and learn about the MERN stack. No, that isn't a typo. The MERN stack is Mongo, Express, and Node, with React instead of Angular. While both React and Angular are remarkable JavaScript technologies, React comes with less baggage. There is no TypeScript, no annotations, no bossy framework telling you how to do everything.
Slide deck presented during my session on "Mean Stack - An Overview" at JavaScript Meetup #6 on Saturday, September 24, 2016. The meetup was at Akamai Technologies, Bengaluru.
MongoDB Days Silicon Valley: Building Applications with the MEAN StackMongoDB
Presented by Jason Zucchetto, Curriculum Engineer, MongoDB
Experience level: Introductory
Walk through building a sample application with the MEAN stack (MongoDB-Express-Angular-Node.js). We'll start from the beginning, walking through every component of the MEAN stack, in building a modern web application. The presentation focuses on building MongoMart, a simple application for searching and viewing MongoDB merchandise. You'll walk away with a basic knowledge of MEAN stack components and how to leverage them in building applications.
1. Isomorphic JavaScript is the pattern of running JavaScript code on both server & client.
2. People are using it for production today. Ask Facebook, Yahoo, Asana, Airbnb, Rising Stack, …
3. This is not another talk about NodeJS!
In this article, I’d like to tell you about 7 Node JS project ideas that will help you train your skills, build an impressive portfolio, and get hired.
For some time, I’m publishing the lists of projects that you can use to practice the coding skills that you’ve just learned. I was focusing mostly on frontend technologies, but today I decided to jump to the Javascript backend framework called Node JS.
MEAN Stack technology is a full-stack JavaScript solution that helps you build fast and very light weight web application. The web application made under MEAN stack is fast because the Node js which is run time environment made by C++ which is very fast as compare to other languages.
MEAN is acronym of Mongodb, Express js, Angular js, Node js. The MEAN stack technology is very easy to learn because MEAN is completely based on JavaScript which means you don't have to learn different languages for implementing this.
Escaping the yellow bubble - rewriting Domino using MongoDb and AngularMark Leusink
Slides from my ICON UK 2014 session held on September 13, 2014 at IBM Southbank, London.
The session was an introduction to the MEAN stack (Mongo, Express, Angular and Node).
In this session, we will walk through building a REST API from scratch with the MEAN stack using the test-driven development approach. We’ll cover MongoDB’s document model, the Mongoose object document mapper, and testing with Mocha and Superagent as we build a mobile shopping cart application. You'll walk away with an understanding of how to build your first app on MongoDB using the MEAN stack.
Jeff Andersen from GoInstant
Have you ever thought that writing web applications should allow you to use your mad Javascript skillz on the server side as well? Node.js is such a platform. Bundling up the Google Chrome Javascript runtime, Node lets you easily building fast and scalable network applications perfect for the real-time web. It's also a pretty great platform for building basic data driven websites too. Jeff, a web developer at Halifax based GoInstant, will introduce us to the Node platform, exploring it from the ground up.
Topics of this presentation:
- Basics and best practices of developing single-page applications (SPA) and Web API Services on Microsoft .NET -
- Core with Docker and Linux.
- PowerShell Core automated builds.
- Markdown/PDF documentation.
- Documentation of public interfaces with Swagger/OAS/YAML.
- Automated testing of SPA on Protractor and testing the Web API on Postman/Newman.
This presentation by Sergii Fradkov (Consultant, Engineering), Andrii Zarharov (Lead Software Engineer, Consultant), Igor Magdich (Lead Test Engineer, Consultant) was delivered at GlobalLogic Kharkiv .NET TechTalk #1 on May 24, 2019.
The MEAN stack allows you to build fast, responsive, and maintainable full-stack websites using JavaScript. The stack uses four innovative frameworks: MongoDB for rapid data access, Express for simplified web development, Angular for componentized and fluid UI, and Node for speed.
Not sure if the MEAN stack is for you? Then come to this free warm-up session. We give you a quick tour of all of the pieces of the stack. How to get you machine ready. And show you what it is like to build a site using it.
This session is for both front and backend developers. We'll show you how JavaScript, the world's most ubiquitous language, can help you to master the web.
Node.js Development with Apache NetBeansRyan Cuprak
This session covers the basics of developing Node.js applications with NetBeans. NetBeans includes fully integrated support for both JavaScript and Node.js. You’ll get a tour of the features and learn how NetBeans can accelerate your projects. The presentation looks at basic code editing capabilities provided by the IDE, tool integration (npm/Grunt/Bower/Webpack), frameworks such as Express, and debugging capabilities. You’ll see why NetBeans is the best free JavaScript/Node.js IDE.
Build software like a bag of marbles, not a castle of LEGO®Hannes Lowette
If you have ever played with LEGO®, you will know that adding, removing or changing features of a completed castle isn’t as easy as it seems. You will have to deconstruct large parts to get to where you want to be, to build it all up again afterwards. Unfortunately, our software is often built the same way. Wouldn’t it be better if our software behaved like a bag of marbles? So you can just add, remove or replace them at will?
Most of us have taken different approaches to building software: a big monolith, a collection of services, a bus architecture, etc. But whatever your large scale architecture is, at the granular level (a single service or host), you will probably still end up with tightly couple code. Adding functionality means making changes to every layer, service or component involved. It gets even harder if you want to enable or disable features for certain deployments: you’ll need to wrap code in feature flags, write custom DB migration scripts, etc. There has to be a better way!
So what if you think of functionality as loose feature assemblies? We can construct our code in such a way that adding a feature is as simple as adding the assembly to your deployment, and removing it is done by just deleting the file. We would open the door for so many scenarios!
In this talk, I will explain how to tackle the following parts of your application to achieve this goal: WebAPI, Entity Framework, Onion Architecture, IoC and database migrations. And most of all, when you would want to do this. Because… ‘it depends’.
Ember.js - introduction
I have searched for Ember ppt in the internet. Got many things but not like structured... So i have just combined and made a new one..
I am just learning and not an expert. Please share your comments, so i can keep up myself..
The goal of every developer is get her super cool new feature out to customers, as fast as possible, with little to no bugs and with no manual effort so she can go back to coding the next awesome one. Doing all of this takes tremendous amounts of effort to plan, coordinate and execute on a DevOps engineer. Continuous Integration coupled with Continuous Deployment aide in this endeavor. But again, those are cumbersome and can be difficult to set up. AWS has four new tools to help with this; AWS CodeDeploy, CodeCommit, CodePipeline, and CodeBuild. Each one has specialized features to help get your code to customers faster, more reliable and bug free as possible. In this presentation, we will walk through how to setup a CI/CD pipeline using those AWS tools and demonstrate how we can go from yay it compiles to a 5-star review.
Microsoft has built a rich ecosystem around the various flavors of ASP.NET – MVC, Web API and even WebForms have a place in the modern web development world. So what the heck is up with ASP.NET Core anyways? Microsoft has flipped the ASP.NET world on its head with this fast, cross-platform web framework, designed from the ground up with developers from all walks of life in mind – and the change isn’t as scary as you think.
In this session, we’ll learn about ASP.NET Core and its design philosophies. We’ll learn how to leverage several popular development tools frequently used by developers outside of the ASP.NET ecosystem, including Gulp, Bower, Node and NPM, to build and run our application. Finally, we’ll use Visual Studio Code to create and run our very first ASP.NET Core project (on a Mac no less!)
For current ASP.NET developers, we’ll also touch on the portability of your current ASP.NET code.
The professionals who just want to know about the topmost web application development frameworks must go through this blog. For the top 10 development Framework introduction, positive and negative aspects are clearly mentioned.
Similar to MEAN Stack WeNode Barcelona Workshop (20)
A Practical Introduction to Functions-as-a-ServiceValeri Karpov
Facebook Dev Circles, October 24, 2018. An introduction to AWS Lambda using Node.js and an overview of the tradeoffs of using serverless functions as opposed to traditional REST APIs.
A Gentle Introduction to Functions-as-a-ServiceValeri Karpov
Slides from my talk on functions-as-a-service at Wyncode Academy in Miami in April '18. Provides an overview of the tradeoffs between different FaaS providers
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Enhancing Performance with Globus and the Science DMZGlobus
ESnet has led the way in helping national facilities—and many other institutions in the research community—configure Science DMZs and troubleshoot network issues to maximize data transfer performance. In this talk we will present a summary of approaches and tips for getting the most out of your network infrastructure using Globus Connect Server.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
1. Guided MEAN Stack Hackathon
Building (and Testing) a Single Page App in 2 Hours
Valeri Karpov
Software Engineer, MongoDB
www.thecodebarbarian.com
www.slideshare.net/vkarpov15
github.com/vkarpov15
@code_barbarian
2. Who is this guy?
•Coined the MEAN stack in April ‘13
•CI/Tools/NodeJS/Go Engineer at MongoDB
•Maintains mongoose, omni-di
•AngularJS since 0.9.4 in 2010
•Hackmaster General at Bookalokal
•Former CTO, LevelUp
*
3. General Outline
•MEAN = MongoDB, ExpressJS, AngularJS, NodeJS
•Beginner talk: high-level concepts of MEAN
•Emphasis on testing and workflow
•Building a single page app - Axl
•NPM-inspired Package Manager for Golang
•Browser interface only
•No Go knowledge required
*
6. Concepts You’ll Be Learning About
•Streams
•API testing
•DOM integration tests with Sauce
•Build systems and architecture
•Configuration + workflow
•General principles for writing NPM packages
*
7. NPM Packages You’ll Be Using
•mocha: unit tests and API integration tests
•browserify: compile Node JS into browser JS
•mongoose: schema validation for Node + MongoDB
•karma: browser automation for testing
•gulp: general-purpose build workflow
•And several more
*
8. Step By Step, the Server Side
•Step 1: Define the problem + brief overview of Go
•Step 2: Define schema and models (mongoose)
•Step 3: Build an API (express)
•Step 4: API-level testing (mocha)
•Step 5: Extending the API to support search
*
9. Step By Step, the HTML Client Side
•Step 6: Create AngularJS SPA client (browserify)
•Step 7: Testing the Single Page App (karma)
•Step 8: CDN for templates and JS (gulp)
*
10. Step 1: A Brief Overview of Go
•Language developed by Google
•Cute toy language with some niche use cases:
*
• Fast-compiling small native binaries
• Tight integration with C
• “Agent” programs like MongoDB MMS agents
•Has some bad limitations
• Generics
• Package management
12. Why Build a Go Package Manager
•npm gets package management mostly right
•Go doesn’t and could use some help
*
13. What npm Does Right
•Mostly semantic versioning (no v20130722)
*
• Will my code break if I upgrade from v2.1.3 to v2.1.4?
•2 commands to install and test
• npm install
• npm test
• And you’re ready to hack
•No need to change PATH or env variables
•Result: a package for every use case
•Go doesn’t have any of this
14. Goals for Axl Server
•Upload/download releases of projects
•Projects hosted on Amazon Cloudfront (streams!)
•Query for projects using semver syntax:
*
• version 1.2.0 matches “~1.2”, “>=1.2.0”, “<=1.3.0”, etc.
• Thankfully, there’s an npm module for that
•Ability to search projects by keyword
•Sane build system and workflow
•Take advantage of a single page app
15. Step 2: Design Schemas
“Smart data structures and dumb code works a lot better
than the other way around.”
*
- Eric S. Raymond
“Bad programmers worry about the code. Good
programmers worry about data structures and their
relationships.”
- Linus Torvalds
16. A Brief Overview of Mongoose
•MongoDB is schema-less
•But your schema design still matters!
•Mongoose = NodeJS schemas for MongoDB
*
• Validation
• Casting for objects and queries
• Promises and other syntactic sugar
• Object document mapper (ODM)
•Users include Tinder and McDonalds
19. About the User Model
•_id and username will be pulled from Twitter oauth
•Most real data will be tracked in other models
*
20. The Project Schema
•In Go, project names are strings like “github.
com/vkarpov15/mgo”
•Releases a list of semver strings
*
21. Why the data Field?
•Simple and intuitive access control
•data contains fields user can edit
*
22. Project Schema Indexes
•MongoDB has indexes for speeding up queries
•Tradeoffs: may make writes slower
•Project schema indexes on:
*
• Project name
• Maintainers usernames (multi-key!)
• Name and keywords text index (more in search section)
26. Indexes for Release Schema
•Indexes can be ordered to help with sorting
•The -1 means higher releaseNumbers come first
•Indexes define how you’ll query your data
*
28. DownloadHistory Indexes
•For the two common use cases of DownloadHistory
*
• How many downloads did a package have this month?
• What are the most popular packages this month?
29. Schema Design Takeaways
•Design schemas carefully
•Use indexes that fit your use cases
•Don’t go overboard on indexing everything!
•Use Mongoose for seamless validation + casting
*
30. Step 3: REST-ish API with Express
•Express: powerful lightweight web framework
•Highly customizable (> 6900 packages on npm)
•Rapidly growing user base:
*
• NBC
• SegmentIO
• MySpace
31. Whats in an API?
•API = actions on top of objects
•REST principles: use HTTP error codes and verbs
•Key concerns for API scalability:
*
• Load search results piece-by-piece from DB
• Hit indexes
• Don’t preclude horizontal scalability (multiple servers)
•MEAN stack allows you to be very lazy
32. API Basics: Load a Project By Name
•GET /api/project?project=gopkg.in/mgo
*
33. A Slide Dedicated to a Bad Pun
•Only place where Axl can tolerate a Slash :)
•(Slash was the guitarist for GNR. He and Axl don’t like each other)
*
34. Brief Aside on Dependency Injection
•Using my lightweight DI helper, omni-di
•Tool for managing and constructing dependencies
•Create objects once, pass them in to functions
•Injector inspects parameter names to find correct
dependencies
*
43. More Sophisticated: Semver Query
•Find me a Release that matches “~1.2”
•GET /api/release?project=gopkg.in/mgo&version=~1.2
•Perfect application of streams
•Hard to index semver queries
*
45. Streaming Document by Document
•Like a for loop, but don’t load whole array in RAM
*
46. And If You Don’t Find a Document...
•Return a nice, handy 404
*
47. POST /api/release
•The most important and most sophisticated
•Subtleties:
*
• Race conditions between multiple servers
• Error handling
• CDN (or, why the “scale npm” campaign happened)
• Authorization
48. Pushing a new Release
•POST /api/release?project=gopkg.in/mgo&version=1.2.0
*
49. MongoDB for Multi-server
Concurrency
•MongoDB operations are ACID per document
•ACID stands for
*
• Atomic
• Consistent
• Isolated
• Durable
•FindAndModify underlies Mongoose
findOneAndUpdate()
50. Multi-Server POST /api/release
•findOneAndUpdate is ACID means a version gets
added to a project only once
•Multiple servers => only one wins
*
51. The isNew Flag
•isNew = false means “return document before update”
*
57. Step 3: Testing the API
•Writing API is easy, testing can be hard
•But easy with Express + Mocha + Node!
•Stub out authentication
•Event-driven nature of JS: no interrupts
•Single process responsible for:
*
• Running Express server
• Sending HTTP requests to Express server
• Using Mocha to test the results of HTTP requests
58. Step 4: Testing the API
•Writing API is easy, testing can be hard
•But easy with Express + Mocha + Node!
•Stub out authentication
•Event-driven nature of JS: no interrupts
•Single process responsible for:
*
• Running Express server
• Sending HTTP requests to Express server
• Using Mocha to test the results of HTTP requests
59. Why One Process?
•Minimal setup
•Run tests with one command
•Use real configuration
•Can assert on state of DB as well as result
*
65. Testing Workflow
•Systems like Gulp are sometimes overkill
•Don’t ask people to “npm install mocha -g”!
*
• Version management
• Incompatibilities with different projects versions
• Breaks the npm install promise
66. Using Makefile for Testing
•Makefile surprisingly common in NodeJS
•Usually as a command shortener
•Use “make api-test” to run tests
*
68. Step 5: Search API
•Use testing framework to do some TDD
•Test-driven Development: tests first, then code
•Usually done with unit tests
•Faster and more fun with API integration tests
*
73. Notes on Text Search
•Requires mongoose >= 3.8.9
•The $meta keyword used to get “text score”
•Higher text score => more relevant
•Usually want to sort by text result
•Supports stemming in 15 languages
*
76. Step 6: AngularJS SPA Client
•REST API is only the beginning
•What about building a client?
•AngularJS is the best tool for the job (IMO)
*
• MVC-ish client-side templating framework
• Two-way data binding
• Dependency injection, elegant structure
•Writing client-side JS is painful - use Browserify
•Won’t need very sophisticated AngularJS for Axl
77. Book Announcement
•My book on AngularJS is coming out Dec 22
•Pre-order on Amazon for a more detailed dive into
AngularJS
*
78. Overview of AngularJS
•Client-side templates (Two-way data binding)
•Client-side routing (Single Page Apps)
*
79. Why a Single Page App?
•Clean separation of data and views
•Ship HTML separately from data
•Enables you to store HTML as static asset
(Cloudfront)
•Leaves your server free to serve up JSON
•Cleaner separation of concerns
*
80. Overview of Browserify
•Compiles NodeJS JS into one browser-friendly file
•Use same dependencies on client and server:
*
• moment
• underscore
• mongoose (schemas + validation only)
• other isomorphic JS
•Easy to upload JS to Cloudfront as static asset
81. Using AngularJS and Browserify
•npm has an angular package
•Only includes “core angular”
•You may still need other packages
*
82. Word of Warning
•npm angular package depends on contextify
•Contextify is notoriously picky about install reqs
•You need right version of python and a C++ compiler
•Possible, but tricky, to install on Windows
•I prefer to list angular as a devDependency in
package.json
*
83. Writing AngularJS in NodeJS
•Create an AngularJS “module”
•Axl also needs the angular client-side routing
module
*
86. What Does a Template Look Like?
•Written in Jade:
•“ng-” and “{{ }}” are tie-ins to AngularJS
*
87. Ok, So What’s a Controller?
•Defines an in-HTML API for the template to use
•Responsible for loading and organizing data
•Attaches properties to template “scope”
*
88. And What’s $projects?
•A service
•Typically a convenience wrapper around a resource
loaded from the server
*
91. Using Compiled JS
•In base jade file, layout.jade, include ui.js:
•Browserify downside: need to compile before use
*
92. Compiling Templates
•Jade downside: need to compile to HTML
•Jade has significant upsides over static HTML:
*
• Readability
• Can include conditionals on server configuration
• Handy for testing - next section
•So we also need to compile Jade!
93. Why Compile Templates
•Jade downside: need to compile to HTML
•Jade has significant upsides over static HTML:
*
• Readability
• Can include conditionals on server configuration
• Handy for testing - next section
•So we also need to compile Jade!
95. Compiling Templates Wrapup
•AngularJS templates need to be HTML
•Very easy to compile Jade
•Take advantage of server configuration
*
96. Step 7: Testing the AngularJS Client
•Trickiest part of any project: users will run your code
in different OS, browser, machine, etc.
•My job at MongoDB = this for the mongodb server
•Great tools for this in web-dev world:
*
• Sauce: think Amazon EC2 for browsers
• Karma: Popular browser automation tool
• ngScenario: AngularJS E2E testing framework
97. DOM Integration Tests
•Test the whole browser side of your code
•That is, test AngularJS’ integration with the DOM
•Stub out REST API calls (speed and ease of setup)
•Setting up data for E2E tests is often complex
•Sometimes known as a “midway test”
*
98. Karma Overview
•Interface for launching a browser and running tests
•Rich set of plugins
•Handles tunneling for remote browsers
•Plugins for launching
*
• local browsers (chrome, firefox, IE, etc.)
• browsers in the Sauce cloud
•My answer to “if I were stuck on a desert island with
only one npm module”
99. Tradeoffs, Local vs Sauce
•I recommend doing both
•Sauce allows you to spawn any browser:
*
• Chrome on Linux
• IE6 on WinXP
• Android 4.3 (yes, mobile included)
•But is slow and flakey
•Local is difficult to set up, but:
• Easier to debug: you can actually see the tests run
• Fast and reliable
100. Workflow and Local vs Sauce
•Make sure tests run with local config on Chrome
•Then use Sauce to run tests on different browsers
•Karma makes this easy: different configs
*
101. Karma Plugin Ecosystem
•Karma itself is a lightweight core
•Need plugins to make it do anything useful
•Yet another npm package with its own npm package
ecosystem (~170 plugins)
*
102. Generating a Karma Config
•Karma configs are pretty straightforward
•Karma has some handy tools:
*
• “node_modules/karma/bin/karma init” creates a new
config after asking you a few questions
•Or just copy/paste examples
106. Karma Sauce Environment Vars
•karma-sauce-launcher relies on 2 env variables:
*
• SAUCE_USERNAME: your Sauce username
• SAUCE_ACCESS_KEY: Sauce API key
•Make sure these are set or your tests will fail
108. Couple Words of Warning
•The api() function is home-baked
•The AngularJS equivalent, $httpBackend, is weird
•More about $httpBackend in Chapter 9 of
Professional AngularJS :)
•ngScenario is quirky and technically deprecated
•Its replacement, Protractor, is more quirky and
doesn’t support DOM integration tests
*
109. How Does the API Function Work?
•ngScenario DSL: domain specific language
*
110. window.AxlAPI
•Use a different layout.jade for running tests:
*
• Don’t load bootstrap
• Expose methods to stub out API requests
•ngScenario runs your tests in an iframe, so it can
actually interact with the code under test
114. Step 8: Deploying to S3 with Gulp
•With SPA, your HTML is static
•Might as well push it out to a CDN
•Last step, stay focused!
*
115. Overview of Gulp
•Simple build tool for web apps
•Another core package with a lot of plugins
•Grunt is its more well-known competitor
•Advantage of Gulp: its plain NodeJS
•List tasks in gulpfile.js
•Re-use your existing code and use streams!
*
123. And that’s a wrap! Time to Review
•Single page app with MEAN stack
•Mongoose Schema
•Express API
•AngularJS routing
•Browserify for building client code
•Karma for testing
•Gulp for pushing HTML+JS to S3+Cloudfront
*
124. Thanks for Listening!
•Slides on:
*
• Twitter: @code_barbarian
• Slideshare: slideshare.net/vkarpov15
•Repo on github: https://github.com/vkarpov15/axl-server
•Professional AngularJS on Amazon