Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
AOP with FeathersJS
Search
AbraaoAlves
September 04, 2016
Programming
260
1
Share
AOP with FeathersJS
Show a powerful and flexible way to create API services in NodeJS.
AbraaoAlves
September 04, 2016
More Decks by AbraaoAlves
See All by AbraaoAlves
React+Redux+Typescript
abraaoalves
0
110
Other Decks in Programming
See All in Programming
Claude Codeをカスタムして自分だけのClaude Codeを作ろう
terisuke
0
160
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
310
Explore CoroutineScope
tomoeng11
0
140
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
730
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
2.2k
My daily life on Ruby
a_matsuda
2
150
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
310
How Swift's Type System Guides AI Agents
koher
0
320
The Less-Told Story of Socket Timeouts
coe401_
3
920
UIの境界線をデザインする | React Tokyo #15 メイントーク
sasagar
2
410
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
980
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
1
190
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
180
Designing for Performance
lara
611
70k
The untapped power of vector embeddings
frankvandijk
2
1.7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
200
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
390
How to Talk to Developers About Accessibility
jct
2
190
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
160
Being A Developer After 40
akosma
91
590k
Context Engineering - Making Every Token Count
addyosmani
9
860
Darren the Foodie - Storyboard
khoart
PRO
3
3.3k
Transcript
Aspect Oriented Programming with FeathersJS
Why Aspect?
Why Aspect ... var express = require('express'); var app =
express(); app.update('/', function (req, res, next) { if (isLoggedln(req) && isValidate(req)) { getUser(req.params.userId).then(function (user) { if (isAdmin(user) && isCurrent(user)) { updateInfo(req).then(function (info) { if (info.emailme) { sendEmail(user.email, info) } removePassword(user); res.send(info); }) } }); } }); because systems grow
@abraao4lves Software Engennier abraaoalves.github.io
Inspiration: Functional Programming f(g(x))
Continuation–passing style (CPS)
Continuation–passing style (CPS) let createUser = validateRequest >> verifyEmail >>
db.createUser >> smtpServer.sendEmail >> returnMessage F# Example:
(CPS) with NodeJS ?
var express = require('express'); var bodyParser = require('body-parser'); var app
= express(); app .use(bodyParser.json()) .use(function (req, res, next) { getUser(req.params.userId).then(function(user){ req.body.username = user.name; next() }) }) .use(function (req, res) { res.json(req.body || {message:'No content'}) }) (CPS) with NodeJS! Express - Middlewares
var express = require('express'); var bodyParser = require('body-parser'); var app
= express(); app .use(bodyParser.json()) .use(function (req, res, next) { getUser(req.params.userId).then(function(user){ req.body.username = user.name; next() }) }) .use(function (req, res) { res.json(req.body || {message:'No content'}) }) (CPS) with NodeJS! Express - Middlewares
And ... Aspect Oriented Programming?
Aspect Oriented Programming!
None
Get Starter
(CPS) with FeathersJS
(CPS) with FeathersJS // Register the hooks app.service('users') .before({ find:
[isLoggedIn, isAdmin], get: [isLoggedIn, isCurrent], create: hashPassword }) .after(removePasswords) .after({ create: sendEmail });
(CPS) with FeathersJS // Register the hooks app.service('users') .before({ find:
[isLoggedIn, isAdmin], get: [isLoggedIn, isCurrent], create: hashPassword }) .after(removePasswords) .after({ create: sendEmail });
(CPS) with FeathersJS // Register the hooks app.service('users') .before({ find:
[isLoggedIn, isAdmin], get: [isLoggedIn, isCurrent], create: hashPassword }) // To all methods .after(removePasswords) .after({ create: sendEmail });
DEMO
Thanks. @abraao4lves abraaoalves.github.io