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

@gavdi/cap-service-core

v1.1.7

Published

Core library for CAP NodeJS

Downloads

25

Readme

@gavdi/cap-service-core - CAP Core Library

Core library for CAP NodeJS applications

What's in the box?

With @gavdi/cap-service-core you'll get everything you need to develop a solid service layer for your solutions.

The core layer comes with the abstractions for service connections and database queries, giving you the option to focus on what is important for your project instead.

On top of this, you'll also get what you need to ensure dependency injection in your code, without having to write too much boilerplate code everytime you start a new project.

Features

  • Dependency Injection
  • External service abstractions
  • Default logging middleware for service requests

How To Install

The core layer is super simple to include in your projects, just run the install command:

npm i --save @gavdi/cap-service-core

And you're now free to make use of all the library at your leisure. However, to get the most out of the library, it is recommended to bootstrap your service with the core. To see how to do that, see the configuration section.

Configuration

When bootstrapping your service in your service.ts file, you can include the core layer by bootstrapping using the recommended approach seen below:

import {
  ExternalServiceFactory,
  InitDIContainer,
  LoggingMiddleware,
} from "@gavdi/cap-service-core";
import { Service } from "@sap/cds/apis/services";
import { createCombinedHandler, useContainer } from "cds-routing-handlers";
import "reflect-metadata";
import Container from "typedi";

const hdl = createCombinedHandler({
  handler: [
    // Entity Handlers
    `${__dirname}/api/handlers/**/*.js`,
    `${__dirname}/api/handlers/**/*.ts`,

    // Function/Action Import Handlers
    `${__dirname}/api/functions/**/*.js`,
    `${__dirname}/api/functions/**/*.ts`,
    `${__dirname}/api/actions/**/*.js`,
    `${__dirname}/api/actions/**/*.ts`,
  ],
  middlewares: [LoggingMiddleware],
});

export default async (srv: Service) => {
  // Configure handlers
  hdl(srv);

  // Setup the DI Container
  await InitDIContainer([
    { id: "sf", value: await ExternalServiceFactory.createInstance(SF) },
    {
      id: "sf-tech",
      value: await ExternalServiceFactory.createInstance(SFTech),
    },
  ]);

  // Needed by our handler constructor for dependency injection
  useContainer(Container);
};

TODOs

  • [ ] Port over batch query builder to own package and include as part of core
  • [ ] Provide standard utility functions for the core
  • [ ] Provide default standard types for use with standard apps
  • [ ] Abstract away the cds-routing-handlers setup
  • [ ] Include heavily used transaction functions as a part of library
  • [ ] Provide unit testing setup for library
  • [ ] Remove dependency for cds-routing-handlers and use dx-frontier's solution instead

(c) Copyright by Gavdi Labs 2024 - All Rights Reserved