# express-decorator **Repository Path**: tuzilow/express-decorator ## Basic Information - **Project Name**: express-decorator - **Description**: some ES7 decorators for express - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-15 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # @tuzilow/express-decorator some simple ES7 decorators for express ## Get Started Install using yarn ```bash yarn add @tuzilow/express-decorator ``` Or using npm ```bash npm install @tuzilow/express-decorator ``` Example usage ```js import express from 'express'; import { Controller, Get, RootUrl } from '@tuzilow/express-decorator'; const Server = express(); @Controller class App { @RootUrl('/user') url() {} @Get('/') home(req, res) { res.json({ title: 'hello world', }); } @Get('/getOne') getOne(req, res) { const { id } = req.query; res.json({ title: 'hello world', id, }); } @Get('/list/:id') list(req, res) { const { id } = req.params; res.json({ title: 'hello world', id, }); } } Server.use(new App()); Server.listen(3000, () => { console.info('running in http://localhost:3000'); }); ``` ## API | Decorator | Description | | ---------------------- | ------------------------------------------------------------ | | @Controller | Class that is marked with this decorator is created a router | | @RootUrl(path: string) | Set root path | | @Get(path: string) | http get method | | @Post(path: string) | http post method | | @Put(path: string) | http put method | | @Delete(path: string) | http delete method |