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
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
120
Other Decks in Programming
See All in Programming
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
140
symfony/aiとlaravel/boost
77web
0
110
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
230
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
0
150
dRuby over BLE
makicamel
2
400
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
630
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
220
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
970
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
240
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
220
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
270
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.2k
Featured
See All Featured
BBQ
matthewcrist
89
10k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
180
Code Review Best Practice
trishagee
74
20k
Statistics for Hackers
jakevdp
799
230k
Navigating Team Friction
lara
192
16k
My Coaching Mixtape
mlcsv
0
160
The Language of Interfaces
destraynor
162
27k
How STYLIGHT went responsive
nonsquared
100
6.2k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
Visualization
eitanlees
152
17k
YesSQL, Process and Tooling at Scale
rocio
174
15k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
55k
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