open-index/open-npm huggingface dataset:
npm package: @openapi-typescript-infra/apollo-datasource-rest
Description: Use openapi-typescript types with apollo-datasource-rest
Author: Max Metral
Latest version: 3.0.0

# apollo-datasource-rest

This module allows you to use typed OpenAPI-based method calls in an Apollo RESTDataSource subclass. The apollo-datasource-rest package is in fact deprecated, but we still use this heavily so I will start with this package and move to the new @apollo packages when we move the rest of the service.

To use this module, you should derive from `TypedRESTDataSource<Paths, Context>` instead of directly from RESTDataSource. The first generic argument should point to the paths object created by openapi-typescript, and the second to your Apollo server context.

Now, instead of calling `this.get` to use the generic REST client, call `this.openapi.get` to use the typed client (which in turn calls this.get after fixing up all the types and parameters).

See [the test](__tests__/index.spec.ts) for an example using the PetStore API.
npm package: @openapi-typescript-infra/coconfig
Description: Default Node.js configuration files for openapi-typescript-infra projects
Author: developers@pyralis.com
Latest version: 4.7.1

# @openapi-typescript-infra/coconfig

![main CI](https://github.com/openapi-typescript-infra/coconfig/actions/workflows/npm_publish.yml/badge.svg)

Default Node.js configuration files for OpenAPI Typescript projects. Uses [coconfig](/gas-buddy/coconfig) to create a pile of configuration files.
npm package: @openapi-typescript-infra/create
Description: Project generator for @openapi-typescript-infra services
Author: Max Metral
Latest version: 3.0.1

# @openapi-typescript-infra/create

A plop-based project generator and maintenance tool for [services](/openapi-typescript-infra/service). Builds tests and
other infra to get up and running quickly. The generally expected conventions for project naming are:

* something-api - a service meant to be hit by the outside world that primarily hosts an OpenAPI endpoint (can have unspec'ed routes as well)
* something-serv - a service meant to be HIDDEN from the outside world but hit from other services (-web, -api, other -servs and admin tools) that hosts an OpenAPI endpoint (can have unspec'ed routes as well)
* something-web - a service meant to host a React app via Next (this is not wired up to the generator yet)

```
mkdir my-cool-api
cd my-cool-api
yarn create @openapi-typescript-infra
```

After that you can run `yarn build` to vet things, then `yarn test`. Then you should get to work on your API spec, which you can find in the `api` directory of your newly created project.
npm package: @openapi-typescript-infra/openapi-typescript-enum
Description: A version of openapi-typescript that also generates enumerations
Author: Max Metral
Latest version: 2.2.0

# openapi-typescript-enum

This module adds a transformer to openapi-typescript that generates real enums in addition to the typed unions.
You can use it as a straight replacement for `npx openapi-typescript` or `yarn openapi-typescript` as we essentially
copied the CLI code. In the future we'd prefer this was just a transform that was invoked from the openapi-typescript
CLI.
npm package: @openapi-typescript-infra/service
Description: An opinionated framework for building configuration driven services - web, api, or  ob. Uses OpenAPI, pino logging, express, confit, Typescript and vitest.
Author: developers@pyralis.com>
Latest version: 6.13.1

# @openapi-typescript-infra/service

[![Node CI](https://github.com/openapi-typescript-infra/service/actions/workflows/nodejs.yml/badge.svg)](https://github.com/openapi-typescript-infra/service/actions/workflows/nodejs.yml)

An opinionated framework for building high scale services - web, api, or job. Uses OpenAPI, pino, express, confit, Typescript and vitest.

This module creates an environment that makes it simpler to host a REST service
(less repetition, more enterprise grade features). Wherever possible, we use off
the shelf infrastructure (OpenAPI, Express@5, Terminus are examples). The goal is to allow
you to enjoy a high level of type safety with a low tax in type construction in a
microservice environment.

The module takes care of configuration-driven:

- body logging
- json parsing
- error handling
- hosted OpenAPI documents/handlers
- traditional routing
- graceful shutdown
- health checks
- Telemetry and instrumentation

services built with this module use Typescript with Node 20, which involves transpilation.
This module takes that into account across the development and production experience. It uses ESM because that
is the way the winds have blown.

This module has the following core functionality:

1. Loads multilevel environment aware configuration, merging configuration information as appropriate to yield a single hierarchical configuration store. We use a modern port of [confit](https://github.com/sesamecare/confit).
2. Engage OpenTelemetry for tracing and metrics monitoring (via Prometheus-format metrics) and wire this into JSON-based pino logging.
3. Setup an Express@5 application with common service hosting options such as body parsing, error handling and graceful shutdown.
4. Find and load route handlers and static content serving, if desired.
5. Validate and load OpenAPI 3 specifications and wire up methods to path-based route handlers including support for authentication.
6. Launch a second express app to serve health checks and metrics
7. Setup infrastructure for interservice calls with tracing.
8. Provide a central service runner that handles loading your service and getting to a running state in both development and production environments.

Please see the plop-based [project builder](../create) for an easy way to build an example project.
npm package: @openapi-typescript-infra/service-tester
Description: Testing utilities for @openapi-typescript-infra/service
Author: developers@pyralis.com
Latest version: 7.1.2

service-tester
===============

![main CI](https://github.com/openapi-typescript-infra/service-tester/actions/workflows/nodejs.yml/badge.svg)

[![npm version](https://badge.fury.io/js/@openapi-typescript-infra%2Fservice-tester.svg)](https://badge.fury.io/js/@openapi-typescript-infra%2Fservice-tester)

This module makes it easier for you to write tests for your node.js @openapi-typescript-infra/service microservice.
Simply add the module as a dev dependency:

```sh
yarn add -D @openapi-typescript-infra/service-tester
```

Then write a test in ```/__tests__/startup.test.js```:

```ts
import request from 'supertest';
import { getReusableApp, clearReusableApp } from '@openapi-typescript-infra/service-tester';
import myService from '../src/index';

describe('my service', () => {
  test('should start', async () => {
    const app = await getReusableApp(myService);
    expect(app).toBeTruthy();
    await request(app).get('/').expect(200);
  });
});
```

Service call mocking
--

Nock is so 2010. The future is mock! Since we have typed clients for services these days, mocking them is easier. We've played some nutty
tricks with Typescript (well, nutty for me), to enable this kind of syntax:

```
  mockServiceCall(app.locals.services.myCrazyServ, 'get_some_resource').mockResolvedValue({
    status: 200,
    responseType: 'response',
    body: { resource: true },
    headers: new Headers(),
  });
```

This will cause calls to `app.locals.services.myCrazyServ.get_some_resource()` to return `{resource: true}`. This is just shorthand
for `jest.spyOn(service, 'method')` with knowledge of the traditional return type of OpenAPI service calls.
npm package: @openapi-typescript-infra/temporal-worker
Description: A Typescript node module to centralize some boilerplate around creating Temporal.io workers
Author: Max Metral
Latest version: 1.0.2

# @openapi-typescript-infra/temporal-worker

A Typescript node module to centralize some boilerplate around creating Temporal.io workers. The module will wire up Temporal logging to @openapi-typescript-infra/service logging and take care of spin up and spin down as well as a default workflow code location.