Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ootkin/deest

A minimal framework on top of express to build organized restful api
https://github.com/ootkin/deest

api backend decorators express framework javascript nodejs rest-api restful restful-api typescript webserver

Last synced: about 1 month ago
JSON representation

A minimal framework on top of express to build organized restful api

Awesome Lists containing this project

README

        

# deest
A minimal framework on top of express to build organized restful api.

# Table of Contents
* [Installation](#installation)
* [Define controllers](#define-controllers)
* [Arguments decorators](#arguments-decorator)

## Installation
1. Install package:

`npm install --save deest`

```typescript
import { Server } from "deest";

const server: Server = new Server({
port: process.env.port || "8080",
/**
* This is used to validate body and query parameters
* with class-validator
* @see https://github.com/typestack/class-validator
*/
validate: true
});

server.init({
middlewares: [
// Global express middlewares
],
errorHandlers: [
// Custom express error handlers
],
controllers: [
// Controller classes
],
});

server.listen(() => {
console.log(`Server is listening on port ${server.getPort()}`);
});
```

## Define controllers

* Create a controller:

```typescript
import { Controller, Get, Post, Put, Patch, Delete } from "deest"

@Controller("/users")
export class UserController {

@Get()
findAll() {
return []
}

@Post()
save() {
return { message: 'user has been saved' };
}

@Put()
save() {
return { message: 'user has been updated' };
}

@Patch()
save() {
return { message: 'user has been updated' };
}

@Delete()
save() {
return { message: 'user has been deleted' };
}
}
```

## Arguments decorators

TDB...