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
1
250
AOP with FeathersJS
Show a powerful and flexible way to create API services in NodeJS.
AbraaoAlves
September 04, 2016
Tweet
Share
More Decks by AbraaoAlves
See All by AbraaoAlves
React+Redux+Typescript
abraaoalves
0
95
Other Decks in Programming
See All in Programming
複数チーム並行開発下でのコード移行アプローチ ~手動 Codemod から「生成AI 活用」への進化
andpad
0
180
JEP 496 と JEP 497 から学ぶ耐量子計算機暗号入門 / Learning Post-Quantum Crypto Basics from JEP 496 & 497
mackey0225
2
460
乱雑なコードの整理から学ぶ設計の初歩
masuda220
PRO
32
14k
Module Harmony
petamoriken
2
550
目的で駆動する、AI時代のアーキテクチャ設計 / purpose-driven-architecture
minodriven
10
3.3k
Reactive Thinking with Signals and the new Resource API
manfredsteyer
PRO
0
110
開発生産性が組織文化になるまでの軌跡
tonegawa07
0
190
チーム開発の “地ならし"
konifar
8
5.9k
FlutterKaigi 2025 システム裏側
yumnumm
0
1.2k
詳細の決定を遅らせつつ実装を早くする
shimabox
2
1.3k
モビリティSaaSにおけるデータ利活用の発展
nealle
0
590
しっかり学ぶ java.lang.*
nagise
1
420
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
57
6.1k
The Cult of Friendly URLs
andyhume
79
6.7k
Building Adaptive Systems
keathley
44
2.8k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
A Modern Web Designer's Workflow
chriscoyier
697
190k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.1k
Typedesign – Prime Four
hannesfritz
42
2.9k
Designing Experiences People Love
moore
142
24k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
980
GitHub's CSS Performance
jonrohan
1032
470k
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