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

teys-rest

v3.1.1

Published

Typescript REST server based on restify

Downloads

10

Readme

TEYS-REST

teys-rest is a wrapper around restify to quickly create REST API servers. Use Typescript and annotations you can create your controllers and expose only the methods you want. It helps you focus on your business code so you don't have to spend more time on setting up your server. teys-rest as two approach of quick api server:

  1. the classic api-server
  2. the single page application server aka spa-sever

Classic API Rest Server

The classic approach will allow you to create simple server like this:

import {ApiServer} from "teys-rest";
import {MyController1, MyController2} from "./controllers"

let api = new ApiServer();
api.start()
    .then(() => api.registerControllers(MyController1, MyController2))
    .then(() => console.log('server started'))

By default the server will run on port 3000 but it can be override by passing a ApiServerOptions object By default all controllers will be registered under /api/v1/{controller}. All controllers must extends the RestController class in order to be properly register. Each controller will have some properties injected via the teys-injector such as :

  • logger
  • logOptions
  • apiPrefix
  • restify server

Single Page Application Server

This approach is for people who wants to push a SPA with the Rest API code. It's build on top of the api-server approach

import path from "path"
import {SpaServer} from "teys-rest";
import {MyController1, MyController2} from "./controllers"


let spa = new SpaServer({
    public: path.join(__dirname, "public")
  });
spa.startWithControllers(MyController1, MyController2)
    .then(() => console.log('server started'))

Options

You can now specify the list of extensions of files that you want to expose

let spa = new SpaServer({
    public: path.join(__dirname, "public"),
    extensionsAllowed: ["png", "jpeg", "html", "js"]
  });

If a list is provided via the property extensionsAllowed it will override the default list of extensions. So only those declared inside the array will be available.
The default value is : ["css", "html", "js", "png", "svg", "ico", "jpeg", "jpg", "woff", "woff2", "ttf"]