npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rokkit.ts/web

v0.3.0

Published

The web module to build an RESTFUL API with rokkit.ts

Downloads

19

Readme

Rokkit.ts Web

GitHub npm (scoped) Build Status

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.
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, 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:

npm install @rokkit.ts/web

Getting Started

In order to start your first project check out the 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.

API

The web modules' functionallities can be devided into two major categories:

  • Building web APIs
  • Querying web APIs

Both 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 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.

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
@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

If you want to contribute to the project, please don't hesitate to send feedback, create issues or pull requests for open ones.

License

Rokkit.ts Core is Open Source software released under the MIT license.