@nldoc/event-source-api-stub
v3.0.7
Published
Stub for Event Source API
Readme
NLdoc's Event Source API Stub
This repository contains a stub for Event Source API's.
Installation
Run:
npm install @nldoc/event-source-api-stubUsage
Tests
See src/ServerApplication.spec.ts for usage in tests.
For use in tests:
import { afterAll, beforeAll, describe } from 'vitest'
import { ServerApplication } from '@nldoc/event-source-api-stub'
describe('...', () => {
const serverApp = new ServerApplication({ heartbeatInterval: 1_000 })
beforeAll(async () => serverApp.start(8123))
afterAll(async () => serverApp.stop())
// ...
})When you pass no port to run on, the operating system will pick a free port. That port can be retrieved by calling serverApp.port().
Standalone
For standalone use, run PORT=1234 event-source-api-stub
Development
Project structure
The project is structured as follows:
src/: Contains the TypeScript source files.src/**/*.spec.ts: Contains the tests for the TypeScript source files.src/**/*.ts: Contains the actual code.
dist/: Contains the compiled JavaScript files.
Testing
The types in this package are tested against the collection of examples (valid and invalid) that were provided in the NLdoc event specification. These examples will be downloaded to the local filesystem on first run of the tests.
To run the tests, run:
$ npm testLicense
See LICENSE.txt for the license of this repository.
