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時代のUIはどこへ行く?その2!
yusukebe
21
7.2k
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
11
4.1k
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
680
Agentic UI
manfredsteyer
PRO
0
160
New "Type" system on PicoRuby
pocke
1
920
AIで効率化できた業務・日常
ochtum
0
130
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
340
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
7
4.4k
スマートグラスで並列バイブコーディング
hyshu
0
140
Oxlintのカスタムルールの現況
syumai
6
1.1k
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
110
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
Featured
See All Featured
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
420
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Faster Mobile Websites
deanohume
310
31k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
130
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
210
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
Building the Perfect Custom Keyboard
takai
2
790
WENDY [Excerpt]
tessaabrams
11
38k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Being A Developer After 40
akosma
91
590k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
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