Member-only story
How to make REST API’s using Node.js, Express.js & Typescript Decorators | Part-1
Decorators Introduction:
A Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter.
We’ll be using Method Decorators to develop routesDecorator.
A Method Decorator is declared just before a method declaration. The decorator is applied to the Property Descriptor for the method and can be used to observe, modify, or replace a method definition. A method decorator cannot be used in a declaration file, on overload, or in any other ambient context (such as in a declare
class).
Definition referred from typescript official site, Check more details about Method Decorators here
Decorators use the form @expression
, where expression
must evaluate to a function that will be called at run-time with information about the decorated declaration.
NOTE: Decorators are an experimental feature that may change in future releases.
Prerequisite:
- Make sure you have installed the latest Node.js ( Download link )
- Basic knowledge of javascript, typescript, node.js, and express.js