FORGEBOX Enterprise 🚀 - Take your ColdFusion (CFML) Development to Modern Times! Learn More...

REST HMVC Template

v1.21.0 Public

REST HMVC Template

This template gives you the base for building RESTFul web services with ColdBox in a modular fashion. This template will create an api module with a v1 sub-module within it. It will leverage ColdBox 5 modular inherit entry points to mimic the URL resources to your modular design.

In the api/models folder you will find our Universal REST Response object that can be leveraged as your base for building RESTFul services.

+ modules_app
  + api
    + models
    + modules_app
      + v1

Implicit Methods

The base handler implements an around handler approach to provide consistency and the following actions:

  • onError - Fires whenever there is a runtime exception in any action
  • onInvalidHTTPMethod - Fires on invalid HTTP method access
  • onMissingAction - Fires on invalid missing actions on handlers

Utility Functions

We also give you some utility functions for RESTFul building:

  • routeNotFound - Can be used to fire of route not founds via 404
  • onExpectationFailed - Can be called when an expectation of a request fails, like invalid parameters/headers etc.
  • onAuthorizationFailure - Can be called to send a NOT Authorized status code and message.

HTTP Security

By default the base handlers leverages ColdBox method security via the this.allowedMethods structure:

this.allowedMethods = {
    "index"     : METHODS.GET,
    "get"       : METHODS.GET,
    "list"      : METHODS.GET,
    "update"    : METHODS.PUT & "," & METHODS.PATCH,
    "delete"    : METHODS.DELETE
};

HTTP Methods

The base handler contains a static construct called METHODS that implements basic HTTP Methods that you can use for messages and allowed methods.

METHODS = {
    "HEAD"      : "HEAD",
    "GET"       : "GET",
    "POST"      : "POST",
    "PATCH"     : "PATCH",
    "PUT"       : "PUT",
    "DELETE"    : "DELETE"
};

Status Codes

The base handler contains a static construct called STATUS that implements basic HTTP status codes you can use:

STATUS = {
    "CREATED"               : 201,
    "ACCEPTED"              : 202,
    "SUCCESS"               : 200,
    "NO_CONTENT"            : 204,
    "RESET"                 : 205,
    "PARTIAL_CONTENT"       : 206,
    "BAD_REQUEST"           : 400,
    "NOT_AUTHORIZED"        : 401,
    "NOT_FOUND"             : 404,
    "NOT_ALLOWED"           : 405,
    "NOT_ACCEPTABLE"        : 406,
    "TOO_MANY_REQUESTS"     : 429,
    "EXPECTATION_FAILED"    : 417,
    "INTERNAL_ERROR"        : 500,
    "NOT_IMPLEMENTED"       : 501
};

License

Apache License, Version 2.0.

Important Links

Source Code

  • https://github.com/coldbox-templates/rest-hmvc

Quick Installation

Each application templates contains a box.json so it can leverage CommandBox for its dependencies.
Just go into each template directory and type:

box install

This will setup all the needed dependencies for each application template. You can then type:

box server start

And run the application.


THE DAILY BREAD

"I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12

Here are all the versions for this package. Please note that you can leverage CommandBox package versioning to install any package you like. Please refer to our managing package version guide for more information.

Version Created Last Update Published By Stable Actions
Current
1.21.0 Jul 18 2019 03:25 PM Jul 18 2019 03:25 PM
Version History
1.20.0 Jun 26 2019 11:28 AM Jun 26 2019 11:28 AM
1.19.0 Jun 13 2019 12:57 PM Jun 13 2019 12:57 PM
1.18.0 May 25 2019 07:48 AM May 25 2019 07:48 AM
1.17.0 May 10 2019 04:53 PM May 10 2019 04:53 PM
1.16.0 Apr 30 2019 01:39 PM Apr 30 2019 01:39 PM
1.15.0 Apr 11 2019 12:06 PM Apr 11 2019 12:06 PM
1.14.1 Jan 24 2019 02:27 PM Jan 24 2019 02:27 PM
1.14.0 Nov 06 2018 04:55 AM Nov 06 2018 04:55 AM
1.13.0 Oct 23 2018 05:31 PM Oct 23 2018 05:31 PM
1.12.2 Oct 02 2018 05:52 PM Oct 02 2018 05:52 PM
1.12.1 Oct 02 2018 05:50 PM Oct 02 2018 05:50 PM
1.12.0 Oct 01 2018 03:48 PM Oct 01 2018 03:48 PM
1.11.0 Jul 18 2018 01:48 PM Jul 18 2018 01:48 PM
1.10.0 Jul 02 2018 05:56 PM Jul 02 2018 05:56 PM
1.9.0 Jun 07 2018 11:24 AM Jun 07 2018 11:24 AM
1.8.0 Apr 27 2018 09:13 AM Apr 27 2018 09:13 AM
1.7.0 Apr 25 2018 11:05 AM Apr 25 2018 11:05 AM
1.6.0 Jan 22 2018 11:55 AM Jan 22 2018 11:55 AM
1.5.0 Jan 16 2018 07:07 PM Jan 16 2018 07:07 PM
1.4.0 Jan 16 2018 06:35 PM Jan 16 2018 06:35 PM
1.3.0 Jan 12 2018 01:43 PM Jan 12 2018 01:43 PM
1.2.0 Jan 12 2018 01:00 PM Jan 12 2018 01:00 PM
1.1.0 Jan 12 2018 01:00 PM Jan 12 2018 01:00 PM
1.0.0 Jan 08 2018 05:27 PM Jan 08 2018 05:27 PM

 

No collaborators yet.
     
  • Jan 08 2018 05:27 PM
  • Jul 18 2019 03:25 PM
  • 753
  • 2945
  • 110