All Projects → thiagobustamante → Typescript Rest

thiagobustamante / Typescript Rest

Licence: mit
This is a lightweight annotation-based expressjs extension for typescript.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Typescript Rest

Node Express Mongoose Passport Jwt Rest Api Auth
Node, express, mongoose, passport and JWT REST API authentication example
Stars: ✭ 146 (-68.12%)
Mutual labels:  api, rest, restful, expressjs
Node Express Postgresql Sequelize
Node.js, Express.js, Sequelize.js and PostgreSQL RESTful API
Stars: ✭ 148 (-67.69%)
Mutual labels:  api, rest, restful, expressjs
The Rest Architectural Style
An article on the REST architecture style.
Stars: ✭ 168 (-63.32%)
Mutual labels:  api, rest, restful
Proteus
Lean, mean, and incredibly fast JVM framework for web and microservice development.
Stars: ✭ 178 (-61.14%)
Mutual labels:  api, rest, microservice
Bookmarks.dev
Bookmarks and Code Snippets Manager for Developers & Co
Stars: ✭ 218 (-52.4%)
Mutual labels:  api, rest, expressjs
Appkernel
API development made easy: a smart Python 3 API framework
Stars: ✭ 152 (-66.81%)
Mutual labels:  api, rest, microservice
Flama
🔥 Fire up your API with this flamethrower
Stars: ✭ 161 (-64.85%)
Mutual labels:  api, rest, restful
Express Api Es6 Starter
Build APIs with Express.js in no time using ES6/ES7/ESNext goodness.
Stars: ✭ 212 (-53.71%)
Mutual labels:  api, rest, expressjs
Phalapi
A PHP framework foucs on API fast development.接口,从简单开始!PhalApi简称π框架,一个轻量级PHP开源接口框架,专注于接口服务开发。
Stars: ✭ 1,365 (+198.03%)
Mutual labels:  api, microservice, restful
Http Fake Backend
Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 253 (-44.76%)
Mutual labels:  api, rest, restful
Go Grpc Http Rest Microservice Tutorial
Source code for tutorial "How to develop Go gRPC microservice with HTTP/REST endpoint, middleware, Kubernetes deployment, etc."
Stars: ✭ 250 (-45.41%)
Mutual labels:  api, rest, microservice
Django Oscar Api
RESTful JSON API for django-oscar
Stars: ✭ 251 (-45.2%)
Mutual labels:  api, rest, restful
Kanary
A minimalist web framework for building REST APIs in Kotlin/Java.
Stars: ✭ 319 (-30.35%)
Mutual labels:  api, rest, microservice
Tenso
Tenso is an HTTP REST API framework
Stars: ✭ 167 (-63.54%)
Mutual labels:  api, rest, microservice
Golang Gin Realworld Example App
Exemplary real world application built with Golang + Gin
Stars: ✭ 1,780 (+288.65%)
Mutual labels:  api, rest, restful
Graphql2rest
GraphQL to REST converter: automatically generate a RESTful API from your existing GraphQL API
Stars: ✭ 181 (-60.48%)
Mutual labels:  api, rest, restful
Spring Boot Api Project Seed
🌱🚀一个基于Spring Boot & MyBatis的种子项目,用于快速构建中小型API、RESTful API项目~
Stars: ✭ 8,979 (+1860.48%)
Mutual labels:  api, rest, restful
Http restful api
整理HTTP后台端的RESTful API方面的知识
Stars: ✭ 94 (-79.48%)
Mutual labels:  api, rest, restful
Flask Restplus
Fully featured framework for fast, easy and documented API development with Flask
Stars: ✭ 2,585 (+464.41%)
Mutual labels:  api, rest, restful
Horse
Fast, opinionated, minimalist web framework for Delphi
Stars: ✭ 295 (-35.59%)
Mutual labels:  api, rest, restful

npm version Build Status Coverage Status Known Vulnerabilities BCH compliance

REST Services for Typescript

This is a lightweight annotation-based expressjs extension for typescript.

It can be used to define your APIs using decorators.

Table of Contents

Installation

This library only works with typescript. Ensure it is installed:

npm install typescript -g

To install typescript-rest:

npm install typescript-rest --save

Configuration

Typescript-rest requires the following TypeScript compilation options in your tsconfig.json file:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "target": "es6" // or anything newer like esnext
  }
}

Basic Usage

import * as express from "express";
import {Server, Path, GET, PathParam} from "typescript-rest";

@Path("/hello")
class HelloService {
  @Path(":name")
  @GET
  sayHello( @PathParam('name') name: string ): string {
    return "Hello " + name;
  }
}

let app: express.Application = express();
Server.buildServices(app);

app.listen(3000, function() {
  console.log('Rest Server listening on port 3000!');
});

That's it. You can just call now:

GET http://localhost:3000/hello/joe

Using with an IoC Container

Install the IoC container and the serviceFactory for the IoC Container

npm install typescript-rest --save
npm install typescript-ioc --save
npm install typescript-rest-ioc --save

Then add a rest.config file in the root of your project:

{
  "serviceFactory": "typescript-rest-ioc"
}

And you can use Injections, Request scopes and all the features of the IoC Container. It is possible to use it with any other IoC Container, like Inversify.

Example:

class HelloService {
  sayHello(name: string) {
    return "Hello " + name;
  }
}

@Path("/hello")
class HelloRestService {
  @Inject
  private helloService: HelloService;

  @Path(":name")
  @GET
  sayHello( @PathParam('name') name: string): string {
    return this.sayHello(name);
  }
}

Complete Guide

Check our documentation.

Boilerplate Project

You can check this project to get started.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].