- Add
matchedRoute
(e.g./users/:id/comments
) andmatchedServiceKey
(e.g.api.users.comments
) into the context state - Fix documenting entities with complex constructors that use
@Required
@Validate
and@Required
will now only check forundefined
and will not countnull
properties as missing
- Registered services are now accessed under
ctx.state.services[your-path].service
(previouslyctx.state.services[your-path]
) to support base paths and nested paths - Fix the
@ForwardTo
decorator not supporting nested routes
- Handle registering nested service paths (e.g.
service('/api/:version/users/:userId/comments')
=>api.users.comments
)
- Use
hasOwnProperty()
instead of invoking handlers to check implict routes are implemented
- Fix
@Docs
overriding therequired
type on params - Added
samples
toRouteDocs
for documenting multiple route request/response samples
- Don't override docs of a route that forwards to another route
- Fix route params not being documented
- Use context of forwarded-to service for forwarded requests
- Added
@ForwardTo
decorator andforwardRequest()
helper for forwarding requests between services - Documentation from forward-to handlers is applied to the handler that forwarded the request
- The
Service
interface is now a class and should be extended rather than implemented - Implicit route methods (
index()
,post()
, etc) are now defined in theService
base class and by default return a 405 - method not allowed - Added automatic documentation - available via the Clay global object:
globalThis.clay.docs
- Added
@Docs
decorator for documenting service routes - Request headers are now strictly typed to
string
instead ofany
- Route handlers can now return a
RedirectResponse
type - Added
redirect()
helper function for creating redirects
- Support classes in @Validate that have parameters in their constructors
- Add
break
to validation condition, if set to true than any later errors for that key are not added to the response Request
andResponse
objects and their properties are nowreadonly
(apart from the context state)
- Keep Koa context unfrozen in @Before/@After
- Add new reworked @Before/@After see the docs
- New name: Clay!
- Remove
Service
prefix from all types and interfaces (e.g. ServiceRequest -> Request) - Added @Required decorator for entity properties
- Reworked how the @Validate object schema works, see the docs
- Removed the @Before and @After decorators
- Move registered services into
ctx.state
- Made koa-bodyparser a dependency
- Only reject null or undefined values in
@Validate
schemas
- Fix type of
ServiceRequest.path
- Added export for
ServicePolicyResponse
, returning a union type forboolean
andServicePolicyDenial
- Route base paths are now declared in the middleware declaration
- Services are now registered with lodash.set allowing for namespaced access
- (3.1.0) Add @Routes decorator for declaring routes
- (3.1.1) Fix missing export for new decorator
- (3.0.0) Reworked the way
@Validate
works: - (3.0.0) Keys that return a function must now return a boolean (false => fail, true => pass)
- (3.0.0) Keys that return a function must now throw an error to override the default message (see the docs)
- (3.0.1) Fix typing on
val
parameter of validation functions
- Validation schemas for
@Validate
can now take in booleans to specify whether the key is required
ServicePolicyDenial
's status code defaults to 403 instead of 401
Every change in 2.0.0 is breaking
- Removed the
@Resource
hook. The behaviour was iffy and the same functionality can (mostly) be achieved usingtoJSON()
- Renamed the
basePath
service config option toprefix
- Routes are now defined within the
routes
member variable of service classes - The
index()
function of service classes is now called forGET /
instead ofget()
(which now only gets called forGET/:id
) - Added the
ServicePolicyDenial
class for returning custom data and status codes with@HasPermission
- Bump to 1.0.0 (the project feels feature-complete now)
- Can check headers with the
@Validate
hook
- Use correct path when falling back to default route for method
- Don't handle methods if the defined routes don't include them
- (Breaking) Resources now need to implement an
async transform()
function to transform entities rather than doing it in the constructor
- Fixed exports for hook functions
- Set type of query params to
string
instead ofany
- Added
@HasPermission
hook for checking requests against policy classes
- (Breaking)
HookParams
now exposes thereq: ServiceRequest
of the handler instead of theargs
- Handle
@After
and@Before
hooks if they're async functions
- (Tests) Fix questionable usage of 204
@Validate
's body and query keys can now accept an array that will simply check if the keys in the array exist on the body or query
- Don't run
@Resource
hook on missing keys - (Debug) Better logging for when route/handler can't be found
- Added
@Resource
hook for transforming objects before being returned in responses - (Debug) Better logging for available routes
- Added
@Validation
hook for making sure request isn't missing required data
- Handle undefined route path gracefully
- Add
debug
option for logging - Drop generic declaration on Service
- Clean up package contents
- Register services directly to the app context (accessible via
app.context.services
)
- Route handlers can be functions