4.0.7 • Published 2 months ago

@travetto/rest-model v4.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

RESTful Model Routes

RESTful support for generating APIs from Model classes.

Install: @travetto/rest-model

npm install @travetto/rest-model

# or

yarn add @travetto/rest-model

To facilitate common RESTful patterns, the module exposes Data Modeling Support support in the form of ModelRoutes.

Code: ModelRoutes example

import { Inject } from '@travetto/di';
import { ModelCrudSupport } from '@travetto/model';
import { Controller } from '@travetto/rest';
import { ModelRoutes } from '@travetto/rest-model';

import { User } from './user';

@Controller('/user')
@ModelRoutes(User)
class UserController {
  @Inject()
  source: ModelCrudSupport;
}

is a shorthand that is equal to:

Code: Comparable UserController, built manually

import { Inject } from '@travetto/di';
import { ModelCrudSupport } from '@travetto/model';
import { Path, Controller, Body, Get, Request, Delete, Post, Put } from '@travetto/rest';

import { User } from './user';

@Controller('/user')
class UserController {

  @Inject()
  service: ModelCrudSupport;

  @Get('')
  async getAllUser(req: Request) {
    return await this.service.list(User);
  }

  @Get(':id')
  async getUser(@Path() id: string) {
    return await this.service.get(User, id);
  }

  @Delete(':id')
  async deleteUser(@Path() id: string) {
    return await this.service.delete(User, id);
  }

  @Post('')
  async saveUser(@Body() user: User) {
    return await this.service.create(User, user);
  }

  @Put('')
  async updateUser(@Body() user: User) {
    return await this.service.update(User, user);
  }
}
4.0.7

2 months ago

4.0.6

2 months ago

4.0.5

2 months ago

4.0.4

2 months ago

4.0.3

2 months ago

4.0.1

3 months ago

4.0.0

3 months ago

4.0.2

3 months ago

4.0.0-rc.10

3 months ago

4.0.0-rc.9

3 months ago

4.0.0-rc.8

3 months ago

3.4.6

3 months ago

4.0.0-rc.7

3 months ago

4.0.0-rc.6

3 months ago

4.0.0-rc.5

3 months ago

4.0.0-rc.3

3 months ago

4.0.0-rc.4

3 months ago

4.0.0-rc.1

3 months ago

4.0.0-rc.2

3 months ago

4.0.0-rc.0

4 months ago

3.4.4

6 months ago

3.4.5

6 months ago

3.3.8

7 months ago

3.3.7

8 months ago

3.3.6

8 months ago

3.4.0

6 months ago

3.2.2

10 months ago

3.2.1

10 months ago

3.4.3

6 months ago

3.2.5

10 months ago

3.4.2

6 months ago

3.2.4

10 months ago

3.4.1

6 months ago

3.2.3

10 months ago

3.4.0-rc.9

6 months ago

3.4.0-rc.7

6 months ago

3.4.0-rc.8

6 months ago

3.4.0-rc.5

6 months ago

3.4.0-rc.6

6 months ago

3.4.0-rc.3

6 months ago

3.4.0-rc.4

6 months ago

3.4.0-rc.1

7 months ago

3.4.0-rc.2

6 months ago

3.4.0-rc.0

7 months ago

3.3.1

9 months ago

3.3.0

9 months ago

3.3.5

8 months ago

3.3.4

8 months ago

3.3.3

8 months ago

3.3.2

9 months ago

3.2.0

11 months ago

3.1.15

11 months ago

3.2.0-rc.0

11 months ago

3.1.12

12 months ago

3.1.11

12 months ago

3.1.14

11 months ago

3.1.13

11 months ago

3.1.10

12 months ago

3.1.9

12 months ago

3.1.8

1 year ago

3.1.7

1 year ago

3.1.6

1 year ago

3.1.5

1 year ago

3.1.4

1 year ago

3.0.3

1 year ago

3.1.0-rc.10

1 year ago

3.1.3

1 year ago

3.1.2

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

3.1.0-rc.2

1 year ago

3.1.0-rc.3

1 year ago

3.1.0-rc.0

1 year ago

3.1.0-rc.1

1 year ago

3.1.0-rc.6

1 year ago

3.1.0-rc.7

1 year ago

3.1.0-rc.4

1 year ago

3.1.0-rc.5

1 year ago

3.1.0-rc.8

1 year ago

3.1.0-rc.9

1 year ago

3.0.0-rc.26

1 year ago

3.0.0-rc.27

1 year ago

3.0.1-rc.1

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

3.0.2-rc.1

1 year ago

3.0.2-rc.0

1 year ago

3.0.0-rc.24

1 year ago

3.0.0-rc.23

1 year ago

3.0.0-rc.25

1 year ago

3.0.0-rc.20

1 year ago

3.0.0-rc.22

1 year ago

3.0.0-rc.21

1 year ago

3.0.0-rc.15

1 year ago

3.0.0-rc.17

1 year ago

3.0.0-rc.16

1 year ago

3.0.0-rc.19

1 year ago

3.0.0-rc.18

1 year ago

3.0.0-rc.13

1 year ago

3.0.0-rc.12

1 year ago

3.0.0-rc.14

1 year ago

3.0.0-rc.6

1 year ago

3.0.0-rc.11

1 year ago

3.0.0-rc.10

1 year ago

3.0.0-rc.9

1 year ago

3.0.0-rc.8

1 year ago

3.0.0-rc.7

1 year ago

3.0.0-rc.4

2 years ago

3.0.0-rc.3

2 years ago

3.0.0-rc.2

2 years ago

3.0.0-rc.1

2 years ago

3.0.0-rc.0

2 years ago