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

serverless-sub-routing

v2.4.0

Published

Serverless Sub Routing with DI

Downloads

2

Readme

Serverless Sub Routing POC

This project is a Node.js application utilising routing-controllers for route management, a Service Layer for business logic, and a Repository Pattern for database interactions, specifically with DynamoDB.

serverless-sub-routing/
│
├── src/
│   ├── domain/                         # Domain-specific logic, helpers, enums & models
│   │   ├── models/
│   │   ├── enums/
│   │   └── helpers/
│   │
│   ├── services/                       # Business logic implementation
│   │   └── UserService.ts
│   │
│   ├── providers/                      # Data source interaction layer
│   │   └── UserProvider.ts
│   │
│   ├── proxy/                          # Application entry point
│   │   └── index.ts
│   │   ├── resources/                  # HTTP routing handlers
│   │   │    └── UserResource.ts
│   │   └── middleware/                 # HTTP route, request & response error handling
│   │        ├── BeforeMiddleware.ts
│   │        ├── CustomErrorMiddleware.ts
│   │        └── NotFoundMiddleware.ts
│   │
│   └── functions/                      # Lambda functions and/or tasks that are not proxied
│       └── getUser/
│           └── handler.ts
│
├── package.json
├── tsconfig.json
└── README.md

Prerequisites

  • Node.js
  • npm

Getting started

  1. npm i - Installs dependencies
  2. npm run setup - Installs Serverless DynamoDB local
  3. npm run start - Starts Serverless offline
npm run package - Packages the project and outputs to /artifacts/*.zip

Architecture

Dependency Injection

We use Dependency Injection (DI) for managing dependencies between classes, making the application modular and testable.

Using an API Gateway Proxy

Resources

Resources in src/proxy/resources handle incoming HTTP requests and delegate complex business logic to the services. They are responsible for responding to the client.

Services

The src/proxy/services directory contains service classes. Services encapsulate the core business logic of the application. They interact with the repository layer to fetch and manipulate data.

Providers

Providers in src/proxy/providers are responsible for direct database interactions. They abstract the data layer, making it easier to manage data operations.

Middleware

Middleware in src/proxy/middleware is used to handle errors and other request/response operations. They are useful to hooking into parts of the lambda invocation.

Lambda Functions

Functions not using an API Gateway Proxy are in src/functions. They are responsible for handling the event and context passed to the lambda function.

Tests

Unit Tests

Tests are written using Jest and can be found in the tests directory.

The unit/ folder should mimic the src/ directory.

Code style

  • This project uses husky to run a series of checks on commit-msg, pre-commit and pre-push
  • This project uses lint-staged and eslint to enforce code styles
  • Conventional commits rules are enforced using @commitlint/cli
  • To bypass 'empty' commits, this format can be used git commit --allow-empty -m "fix: here is some work"