Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rokkit-ts/rokkit.ts-web
The Web-Module of the Rokkit.ts Framework based on TypeScript and Node.js
https://github.com/rokkit-ts/rokkit.ts-web
backend framework microservice microservices nodejs rokkit typescript
Last synced: 2 months ago
JSON representation
The Web-Module of the Rokkit.ts Framework based on TypeScript and Node.js
- Host: GitHub
- URL: https://github.com/rokkit-ts/rokkit.ts-web
- Owner: rokkit-ts
- License: mit
- Created: 2019-11-27T11:53:13.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T02:39:25.000Z (about 2 years ago)
- Last Synced: 2024-08-09T12:18:27.858Z (5 months ago)
- Topics: backend, framework, microservice, microservices, nodejs, rokkit, typescript
- Language: TypeScript
- Homepage: https://rokkit.dev
- Size: 578 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# [Rokkit.ts Web](https://rokkit.dev)
![GitHub](https://img.shields.io/github/license/rokkit-ts/rokkit.ts-web)
![npm (scoped)](https://img.shields.io/npm/v/@rokkit.ts/web)
[![Build Status](https://travis-ci.com/rokkit-ts/rokkit.ts-web.svg?branch=master)](https://travis-ci.com/rokkit-ts/rokkit.ts-web)Rokkit.ts a microservice framework build in TypeScript for Node.js.
It focuses on a modular component system, developer exerience and good designed APIs to build any application without making restrictions.
Rokkit.ts tries to be adaptable for all needs.
If you want to know more about the framework check out our [Website](https://rokkit.dev/).
The Framework is still in an early phase but allready provides functionality to build basic applications.This is the web module of Rokkit.ts. This module provides the ability to easily build and query web API's.
This module is meant to be used with the [Rokkit.ts-Core](https://github.com/rokkit-ts/rokkit.ts-core), there is a way to use the module on its own but only with additional effort that is not needed when using the core-module.## Install
Install rokkit.ts-web as an npm package:
```bash
npm install @rokkit.ts/web
```### [Getting Started](https://rokkit.dev/#getting-started)
In order to start your first project check out the [Getting Started](https://rokkit.dev/#getting-started) section on our website and try out our cli to create your first project. For a detailed example have a look at our [sample application repository](https://github.com/rokkit-ts/sample-application).
## API
The web modules' functionallities can be devided into two major categories:
- Building web APIs
- Querying web APIsBoth are explained in the following.
_Disclaimer_ The current version of the web module only support the first part of the planned functionality.### Building web APIs
The web module of rokkit.ts is based on a the HTTP-Server framework [restify](). Rokkit.ts uses restify as an underlying HTTP-Server to register user methods on it and to be able to rely on an well tested and widely used framework.
#### Controller
The controller builds the entry point to create an endpoint for your web API. The controller annotation does two things for you.
First it marks a class as an [component](https://github.com/rokkit-ts/rokkit.ts-core) of the framework. Secondly the web module will register this class as container that provides request methods for the HTTP-Server.
The following example shows a sample controller with a simple method that returns a string on a HTTP-GET on the correct request path.
The controller here specifies the base path for all methods with the class. The method can add onto this base path or just respond to the base path.
In the shown example the method will be called when ever a HTTP-GET request hits the path `/hello/world`.```TypeScript
import { Controller, Get } from '@rokkit.ts/web'@Controller('/hello')
class SampleController {@Get('/world')
public helloWorld () {
return 'Hello World!'
}
}
```#### Http Methods
Beside the previously shows Get decorator there decorators for each HTTP method. Each of the decorators works in the same ways as it can specify an request path or just use the parent one from the controller.
Decorators:
- GET
- POST
- PUT
- DELETE
- PATCH
- HEAD
- OPTIONS```TypeScript
@DecoratorName(RequestPath)
```The decorator could only be used on functions within a controller class, otherwise these are not recognized by the framework.
#### Request Attribute accessors
Next to access more data based on the request or to define the request you are able to inject different objects or attributes.
These decorators can only be used on parameters of a controller method that is also annotated with one of the previously named functions.Parameter Decorators:
- Request -- Provides you the full request object
- Response -- Provides you the full response object
- Body -- Provides you the request body as an json obj
- RequestQueryParameter(name) -- Provides you the specified request parameter
- RequestPathParameter(name) -- Provides you the specified path parameter
- Header(name) -- Provides you the specified request header### Querying web APIs
_Currently in development_
## Contribution
All kinds of contributions are welcome, no matter how big or small.
Before you start to contribute please read our [Code of Conduct](./CODE_OF_CONDUCT.md).In order to submit any contribution check out our [contribution guidelines](./CONTRIBUTION.md).
## License
Rokkit.ts Core is Open Source software released under the [MIT license](./LICENSE).