Modern Functional Fluent
<CFML> REST APIs
LED BY
Luis F. Majano
Luis Majano
About Me
• CEO Ortus Solutions
• Computer Engineer
• Creator of all things box!
• Documentation Weirdo!
• www.luismajano.com
@lmajano
@ortussolutions
Modernize or Die™
Podcasts
www.youtube.com/c/OrtusSolutions/
•Age of APIs
•Guiding Principles
•Look at the past to see the future
•API Evolution
Agenda
- Harold Abelson
Programs must be written for people to read, and only
incidentally for machines to execute.
Inspiration
• Every company is a software company
• Deal with two concerns most of the time:
APIs
Front-Ends (maybe)
• We must be:
Agile
Connected
Sustainable
Age of APIs
Guiding Principles
• Cohesion
• Readability
• Reusability
• Encapsulation
• Abstractions
• Testability
• Sanity
C.R.R.E.A.T.S
You can never escape
it….
Crux of Our Session
Ortus Philosophy on Code
Make it work!
Then Make it pretty!
• Hit .cfm pages and return JSON
• Hit .cfc’s with remote access and returnFormat=json
API - version 0
/users/getdata.cfm?page=4&exclude=data
/cfcs/UserService.cfc?method=login&email=#email#&password=#password#
/cfcs/DataService.cfc?method=list&max=40
√ Pros X Cons
• Easy to write • Manual Processes
• Status codes manually
• Headers manually
• CORS manually
• Inline queries?
• No MVC
• Maybe some CFCs
• Automated tests?
• Ugly URIs
• No self documentation
• Expose our
fi
le structures
• Breaks all the rules of encapsulation
• How do we secure it?
• What if we rename
fi
les?
• How do I version it?
API - version 0
• Using native CFML REST
• We can leverage HTTP methods
• We can leverage URL resources and path params
• CFC and annotation-driven
GET /rest/myapp/users/page/4/exclude/data
POST /rest/myapp/users/login?email=#email#&password=#password#
GET /rest/myapp/studentService/Thomas-235
API - version 0.5
• CFC Driven
• Can leverage status codes
• Can leverage verbs
• Can leverage URIs
• Maybe testable
• Instant grati
fi
cation
• Manual Processes
• CORS manually
• Security manually
• Every URL starts with /rest/{appname}
• BIF method for custom status codes,
headers, content
• Impossible to test or mock (bound to the engine)
• restSetResponse()
• Register base URLs via admin, admin API or
methods
• Security is a pain since CFC methods are
called
• No documentation
• Maybe testable
• Relies on pure inheritance for reuse
• Careful on not setting this.restSettings.location,
EVERY CFC is scanned.
API - version 0.5
√ Pros X Cons
• I’ve written APIs like that
• I still have APIs like that
• I admit it
• I’m scared when I go back to maintain them
• I have cried in a dark corner
• I see no issues with it
• How can we do things differently?
• Modern
• Functional
• Fluent
• Testable
What do we do?
We have all done it!
Why ….
• More human code
• Less boilerplate
• Focus on what it should do and not how to do it (BDD)
• Focus on testing
• Easier to produce
• Easier to maintain
• Let the tools do the work
...and dare I say it, FUN!!!
• Use ColdBox HMVC
• Version the API -> 6 versions
• Database Versioning -> cfmigrations
• BDD Tests
• Iterate to make it more human
• Reuse the ecosystem
• Validation
• Cors
• Docs
Testing…
Build a Rants API
github.com/lmajano/modern-functional-
fl
uent-cfml-rest
• ColdBox Modular REST:
> coldbox create app skeleton=rest-hmvc
• Versioned
• Handlers are RestHandlers
• Global customizable/mockable Response object:
data, errors, status, messages, pagination
• Convention-based routing for pretty URLs
• Using service objects with queryExecute() to return query data
• BDD Tests
API - version 1
API - version 1
• Refactor to use a Router instead of convention routing
• Refactor to use array of structs instead of queries
• Refactor to use structs for GET operations
• Refactor to eliminate temporary variable assignments (
fl
uent and readable)
• CBValidation instead of manual validation
• Create an exists() function instead of getting records
• Use get() functions for consistency
• More BDD Tests!
API - version 2
• Predictable routing with ColdBox API Resourceful Routes
• Uniformity on routing
• Less Boilerplate
• Introduce a BaseService object for encapsulation/abstraction
• exists(), existsOrFail()
• getOrFail(), get()
• delete()
• Use validateOrFail() for less boilerplate from cbValidation
• Human and
fl
uent levels are increasing+++++
API - version 3
• Using OOP => Create Entities to model behavior
• Better visualization of what a Rant is or User is
• Encapsulated validation constraints in entities
• Encapsulated marshaling of data to a function : getMemento()
• Services uses a populator to in
fl
ate queries to objects
• Return the full entity memento on create and updates instead of just the id
API - version 4
• Populate Entities with populateModel() and remove boilerplate
• Use a preHandler for paraming incoming variables
• Use Mementifer to stop building data manually
• Add a global new() for all services via BaseService.cfc
• Make your Objects
fl
uent and functional by adding a BaseEntity.cfc
• getOrFail()
• validateOrFail()
• populate()
• save()
• delete()
• Basic memento settings
• More complex validation
API - version 5
• Make a catch all resource for invalid routing
• Add mementi
fi
er runtime includes, excludes for
fl
exibility
• Custom Includes
• Relationships
• More
fl
uency
• Event Caching
• Add Swagger/OpenAPI Docs
• More Tooling
• Install cbswaggerUI
• RestFox
API - version 6
Luis Majano
CEO and Software Architect
Ortus Solutions, Corp
Thank You!
@lmajano
@ortussolutions
P/F:
E-mail:
1-888-557-8057
lmajano@ortussolutions.com
www.ortussolutions.com

More Related Content

PDF
Modern Functional Fluent ColdFusion REST Apis
PDF
Rest ful tools for lazy experts
PDF
RESTFul Tools For Lazy Experts - CFSummit 2016
PDF
Bring api manager into your stack
PDF
Алексей Веркеенко "Symfony2 & REST API"
PDF
Don't screw it up! How to build durable API
PDF
Building sustainable RESTFul services
PDF
Building Advanced RESTFul services
Modern Functional Fluent ColdFusion REST Apis
Rest ful tools for lazy experts
RESTFul Tools For Lazy Experts - CFSummit 2016
Bring api manager into your stack
Алексей Веркеенко "Symfony2 & REST API"
Don't screw it up! How to build durable API
Building sustainable RESTFul services
Building Advanced RESTFul services

Similar to Modern Functional Fluent CFML REST by Luis Majano (20)

PDF
Building APIs in an easy way using API Platform
PDF
Crafting APIs
PPTX
IBM Integration Bus and REST APIs - Sanjay Nagchowdhury
PPTX
RESTful Services
PDF
API Platform 2.1: when Symfony meets ReactJS (Symfony Live 2017)
PDF
RESTful web service with JBoss Fuse
PDF
Writing RESTful Web Services
PPTX
REST Methodologies
PPTX
REST Api Tips and Tricks
PDF
PDF
REST API Recommendations
PDF
Intro to ColdBox MVC at Japan CFUG
PPTX
Rest APIs Training
PDF
REST in pieces
PDF
[drupalday2017] - REST in pieces
PDF
API Platform: Full Stack Framework Resurrection
PPT
APITalkMeetupSharable
PDF
Building a Great Web API - Evan Cooke - QCON 2011
PDF
Consumer centric api design v0.4.0
PDF
Into The Box 2018 Ortus Keynote
Building APIs in an easy way using API Platform
Crafting APIs
IBM Integration Bus and REST APIs - Sanjay Nagchowdhury
RESTful Services
API Platform 2.1: when Symfony meets ReactJS (Symfony Live 2017)
RESTful web service with JBoss Fuse
Writing RESTful Web Services
REST Methodologies
REST Api Tips and Tricks
REST API Recommendations
Intro to ColdBox MVC at Japan CFUG
Rest APIs Training
REST in pieces
[drupalday2017] - REST in pieces
API Platform: Full Stack Framework Resurrection
APITalkMeetupSharable
Building a Great Web API - Evan Cooke - QCON 2011
Consumer centric api design v0.4.0
Into The Box 2018 Ortus Keynote
Ad

More from Ortus Solutions, Corp (20)

PDF
BoxLang in Japan - The Future is Dynamic.pdf
PDF
BoxLang Dynamic AWS Lambda - Japan Edition
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
PDF
June Webinar: BoxLang-Dynamic-AWS-Lambda
PDF
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
PDF
What's-New-with-BoxLang-Brad Wood.pptx.pdf
PDF
Getting Started with BoxLang - CFCamp 2025.pdf
PDF
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
PDF
What's New with BoxLang Led by Brad Wood.pdf
PDF
Vector Databases and the BoxLangCFML Developer.pdf
PDF
Using cbSSO in a ColdBox App Led by Jacob Beers.pdf
PDF
Use JSON to Slash Your Database Performance.pdf
PDF
Portable CI wGitLab and Github led by Gavin Pickin.pdf
PDF
Tame the Mesh An intro to cross-platform tracing and troubleshooting.pdf
PDF
Supercharging CommandBox with Let's Encrypt.pdf
PDF
Spice up your site with cool animations using GSAP..pdf
PDF
Passkeys and cbSecurity Led by Eric Peterson.pdf
PDF
Legacy Code Nightmares , Hellscapes, and Lessons Learned.pdf
PDF
Integrating the OpenAI API in Your Coldfusion Apps.pdf
PDF
Hidden Gems in FusionReactor for BoxLang, ACF, and Lucee Users.pdf
BoxLang in Japan - The Future is Dynamic.pdf
BoxLang Dynamic AWS Lambda - Japan Edition
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
June Webinar: BoxLang-Dynamic-AWS-Lambda
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
What's-New-with-BoxLang-Brad Wood.pptx.pdf
Getting Started with BoxLang - CFCamp 2025.pdf
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
What's New with BoxLang Led by Brad Wood.pdf
Vector Databases and the BoxLangCFML Developer.pdf
Using cbSSO in a ColdBox App Led by Jacob Beers.pdf
Use JSON to Slash Your Database Performance.pdf
Portable CI wGitLab and Github led by Gavin Pickin.pdf
Tame the Mesh An intro to cross-platform tracing and troubleshooting.pdf
Supercharging CommandBox with Let's Encrypt.pdf
Spice up your site with cool animations using GSAP..pdf
Passkeys and cbSecurity Led by Eric Peterson.pdf
Legacy Code Nightmares , Hellscapes, and Lessons Learned.pdf
Integrating the OpenAI API in Your Coldfusion Apps.pdf
Hidden Gems in FusionReactor for BoxLang, ACF, and Lucee Users.pdf
Ad

Recently uploaded (20)

PPTX
assetexplorer- product-overview - presentation
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PDF
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
"Secure File Sharing Solutions on AWS".pptx
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
DNT Brochure 2025 – ISV Solutions @ D365
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PPTX
Patient Appointment Booking in Odoo with online payment
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
Types of Token_ From Utility to Security.pdf
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
assetexplorer- product-overview - presentation
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
How Tridens DevSecOps Ensures Compliance, Security, and Agility
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
iTop VPN Crack Latest Version Full Key 2025
Computer Software and OS of computer science of grade 11.pptx
"Secure File Sharing Solutions on AWS".pptx
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
Monitoring Stack: Grafana, Loki & Promtail
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Advanced SystemCare Ultimate Crack + Portable (2025)
DNT Brochure 2025 – ISV Solutions @ D365
How to Use SharePoint as an ISO-Compliant Document Management System
Patient Appointment Booking in Odoo with online payment
GSA Content Generator Crack (2025 Latest)
Types of Token_ From Utility to Security.pdf
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx

Modern Functional Fluent CFML REST by Luis Majano

  • 1. Modern Functional Fluent <CFML> REST APIs LED BY Luis F. Majano
  • 2. Luis Majano About Me • CEO Ortus Solutions • Computer Engineer • Creator of all things box! • Documentation Weirdo! • www.luismajano.com @lmajano @ortussolutions
  • 4. •Age of APIs •Guiding Principles •Look at the past to see the future •API Evolution Agenda
  • 5. - Harold Abelson Programs must be written for people to read, and only incidentally for machines to execute. Inspiration
  • 6. • Every company is a software company • Deal with two concerns most of the time: APIs Front-Ends (maybe) • We must be: Agile Connected Sustainable Age of APIs
  • 7. Guiding Principles • Cohesion • Readability • Reusability • Encapsulation • Abstractions • Testability • Sanity C.R.R.E.A.T.S
  • 8. You can never escape it….
  • 9. Crux of Our Session
  • 10. Ortus Philosophy on Code Make it work! Then Make it pretty!
  • 11. • Hit .cfm pages and return JSON • Hit .cfc’s with remote access and returnFormat=json API - version 0 /users/getdata.cfm?page=4&exclude=data /cfcs/UserService.cfc?method=login&email=#email#&password=#password# /cfcs/DataService.cfc?method=list&max=40
  • 12. √ Pros X Cons • Easy to write • Manual Processes • Status codes manually • Headers manually • CORS manually • Inline queries? • No MVC • Maybe some CFCs • Automated tests? • Ugly URIs • No self documentation • Expose our fi le structures • Breaks all the rules of encapsulation • How do we secure it? • What if we rename fi les? • How do I version it? API - version 0
  • 13. • Using native CFML REST • We can leverage HTTP methods • We can leverage URL resources and path params • CFC and annotation-driven GET /rest/myapp/users/page/4/exclude/data POST /rest/myapp/users/login?email=#email#&password=#password# GET /rest/myapp/studentService/Thomas-235 API - version 0.5
  • 14. • CFC Driven • Can leverage status codes • Can leverage verbs • Can leverage URIs • Maybe testable • Instant grati fi cation • Manual Processes • CORS manually • Security manually • Every URL starts with /rest/{appname} • BIF method for custom status codes, headers, content • Impossible to test or mock (bound to the engine) • restSetResponse() • Register base URLs via admin, admin API or methods • Security is a pain since CFC methods are called • No documentation • Maybe testable • Relies on pure inheritance for reuse • Careful on not setting this.restSettings.location, EVERY CFC is scanned. API - version 0.5 √ Pros X Cons
  • 15. • I’ve written APIs like that • I still have APIs like that • I admit it • I’m scared when I go back to maintain them • I have cried in a dark corner • I see no issues with it • How can we do things differently? • Modern • Functional • Fluent • Testable What do we do? We have all done it!
  • 16. Why …. • More human code • Less boilerplate • Focus on what it should do and not how to do it (BDD) • Focus on testing • Easier to produce • Easier to maintain • Let the tools do the work ...and dare I say it, FUN!!!
  • 17. • Use ColdBox HMVC • Version the API -> 6 versions • Database Versioning -> cfmigrations • BDD Tests • Iterate to make it more human • Reuse the ecosystem • Validation • Cors • Docs Testing… Build a Rants API github.com/lmajano/modern-functional- fl uent-cfml-rest
  • 18. • ColdBox Modular REST: > coldbox create app skeleton=rest-hmvc • Versioned • Handlers are RestHandlers • Global customizable/mockable Response object: data, errors, status, messages, pagination • Convention-based routing for pretty URLs • Using service objects with queryExecute() to return query data • BDD Tests API - version 1
  • 20. • Refactor to use a Router instead of convention routing • Refactor to use array of structs instead of queries • Refactor to use structs for GET operations • Refactor to eliminate temporary variable assignments ( fl uent and readable) • CBValidation instead of manual validation • Create an exists() function instead of getting records • Use get() functions for consistency • More BDD Tests! API - version 2
  • 21. • Predictable routing with ColdBox API Resourceful Routes • Uniformity on routing • Less Boilerplate • Introduce a BaseService object for encapsulation/abstraction • exists(), existsOrFail() • getOrFail(), get() • delete() • Use validateOrFail() for less boilerplate from cbValidation • Human and fl uent levels are increasing+++++ API - version 3
  • 22. • Using OOP => Create Entities to model behavior • Better visualization of what a Rant is or User is • Encapsulated validation constraints in entities • Encapsulated marshaling of data to a function : getMemento() • Services uses a populator to in fl ate queries to objects • Return the full entity memento on create and updates instead of just the id API - version 4
  • 23. • Populate Entities with populateModel() and remove boilerplate • Use a preHandler for paraming incoming variables • Use Mementifer to stop building data manually • Add a global new() for all services via BaseService.cfc • Make your Objects fl uent and functional by adding a BaseEntity.cfc • getOrFail() • validateOrFail() • populate() • save() • delete() • Basic memento settings • More complex validation API - version 5
  • 24. • Make a catch all resource for invalid routing • Add mementi fi er runtime includes, excludes for fl exibility • Custom Includes • Relationships • More fl uency • Event Caching • Add Swagger/OpenAPI Docs • More Tooling • Install cbswaggerUI • RestFox API - version 6
  • 25. Luis Majano CEO and Software Architect Ortus Solutions, Corp Thank You! @lmajano @ortussolutions P/F: E-mail: 1-888-557-8057 [email protected] www.ortussolutions.com