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
81
Other Decks in Programming
See All in Programming
RDoc meets YARD
okuramasafumi
4
170
AI Coding Agentのセキュリティリスク:PRの自己承認とメルカリの対策
s3h
0
200
個人軟體時代
ethanhuang13
0
320
Navigating Dependency Injection with Metro
zacsweers
3
220
Testing Trophyは叫ばない
toms74209200
0
840
Improving my own Ruby thereafter
sisshiki1969
1
160
testingを眺める
matumoto
1
140
Ruby×iOSアプリ開発 ~共に歩んだエコシステムの物語~
temoki
0
270
複雑なドメインに挑む.pdf
yukisakai1225
5
1.1k
TDD 実践ミニトーク
contour_gara
1
290
AIを活用し、今後に備えるための技術知識 / Basic Knowledge to Utilize AI
kishida
21
5.6k
Processing Gem ベースの、2D レトロゲームエンジンの開発
tokujiros
2
120
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
268
13k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
For a Future-Friendly Web
brad_frost
180
9.9k
Building an army of robots
kneath
306
46k
BBQ
matthewcrist
89
9.8k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Building Adaptive Systems
keathley
43
2.7k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Why Our Code Smells
bkeepers
PRO
339
57k
GraphQLとの向き合い方2022年版
quramy
49
14k
GitHub's CSS Performance
jonrohan
1032
460k
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