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

restla

v0.8.3

Published

A full stack web framework designed for tight integration with frontend MVCs

Downloads

8

Readme

Restla

Introduction

Restla is a full-stack Node.js web framework written in TypeScript. It is specifically designed for developing the backend REST APIs of web applications.

Rather than reinvent the wheel, Restla provides a solid foundation that simplifies and integrates existing libraries commonly used in Node.js development. Restla integrates the Koa web framework and Squell, a type-safe wrapper for the Sequelize SQL ORM, to provide a completely promise-driven API that supports the async/await paradigm.

Restla extends Koa 2.x with additional functionality, but Koa's core functionality remains the same. This means you can use any official or third-party Koa middleware with Restla. By default, Restla applications have the following Koa middleware enabled:

Features

  • All Koa middleware works out of the box with Restla applications.
  • Resource, a router that can generate generic REST resource routes from a Squell model. The default functionality can easily be change by extending the Resource class.
  • Auth, an authentication helper that is backend agnostic (i.e. you could authenticate with a third-party authentication.

Installation

npm install --save restla

Usage

Error Handling

By default Restla catches all error during requests, coerces them into ApplicationErrors if they're not already an application error and then sends them to the client with a response similar to:

{
  "message": "Some error message",
  "errors": []
}

Restla automatically coerces ModelSafe validation errors into a 400 response and any authentication errors into 402 responses. Any other unknown errors are then turned into 500 errors. The validation error response (400 bad request) looks similar to the above but is populated with error messages for each field:

{
  "message": "Validation failed",
  "errors": [{
    "path": "name",
    "message": "Is required"
  }]
}

If you hit any errors you should reject (or throw if you're using the async keyword) with an an ApplicationError in your route or resource. It takes a status code and error message like so:

throw new ApplicationError(404, 'Not Found');

Restla will automatically catch any rejected errors and send them using the ApplicationContext's error method. You can provide your own error response handling method by passing in a custom ApplicationContext when instantiating a Restla application.

Documentation

The API documentation generated using TypeDoc is available online.

To generate API documentation from the code into the docs directory, run:

npm run docs

Testing

First install the library dependencies and the SQLite3 library:

npm install
npm install sqlite3

To execute the test suite using SQLite as the backend, run:

npm run test