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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cca-user-module

v0.2.12

Published

User module

Downloads

237

Readme

cca-user-module

cca-user-module is a TypeScript module that provides use cases, a controller, and a container to manage users in your application. It supports creating, retrieving, updating, and deleting users and is designed to be integrated into a larger system that provides database and HTTP wiring.


Installation

Install the module via npm:

npm install cca-user-module

Features

  • Create User: Create a new user with required fields such as name and email.
  • Get User: Retrieve user details by ID.
  • Get All Users: Retrieve a list of all users (cached for a short TTL).
  • Update User: Update existing user information.
  • Delete User: Delete a user by ID.

Usage Example

Below is an example of how to integrate the UserController provided by cca-user-module into your Express application.

import express from 'express';
import { createUserContainer, UserController } from 'cca-user-module';
import { BaseDatabase } from 'cca-core';

const app = express();
app.use(express.json());

// Create the container using a BaseDatabase instance provided by the host system
const database = new BaseDatabase(/* ... your TypeORM data source ... */);
const { userController } = createUserContainer(database);
const controller: UserController = userController;

// Define user routes
app.post('/users', controller.createUser);
app.get('/users/:id', controller.getUser);
app.get('/users', controller.getAllUsers);
app.put('/users/:id', controller.updateUser);
app.delete('/users/:id', controller.deleteUser);

// Error handling middleware
app.use((err, req, res, next) => {
  res.status(500).json({ error: err.message });
});

app.listen(3000, () => console.log('Server running on port 3000'));

API Endpoints

1. Create a User

  • URL: /users
  • Method: POST
  • Description: Creates a new user.
  • Request Body:
    • User details (e.g., name, email).
  • Response:
    • Code: 201 Created
    • Content: JSON object with the newly created user details.

2. Get a Single User

  • URL: /users/:id
  • Method: GET
  • Description: Retrieves a user by their ID.
  • Response:
    • Code: 200 OK
    • Content: JSON object with user details.

3. Get All Users

  • URL: /users
  • Method: GET
  • Description: Retrieves all users.
  • Response:
    • Code: 200 OK
    • Content: JSON array containing user objects.

4. Update a User

  • URL: /users/:id
  • Method: PUT
  • Description: Updates an existing user.
  • Request Body: JSON object with the fields to update.
  • Response:
    • Code: 200 OK
    • Content: JSON object with the updated user details.

5. Delete a User

  • URL: /users/:id
  • Method: DELETE
  • Description: Deletes a user by their ID.
  • Response:
    • Code: 204 No Content

Error Handling

Ensure your Express application includes error-handling middleware to capture and process errors from the controller methods:

app.use((err, req, res, next) => {
  res.status(500).json({ error: err.message });
});

Scripts

npm run build:tsup
npm run test

Notes

  • Input validation is performed for id, name, and email fields.
  • Get All Users uses a short-lived cache (TTL 300 seconds). Cache is invalidated on create/update/remove.

License

This project is licensed under the MIT License.