Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/penpenpng/nostr-typedef
Type definitions for Nostr applications made with TypeScript
https://github.com/penpenpng/nostr-typedef
nostr type-definitions typedefs types
Last synced: 27 days ago
JSON representation
Type definitions for Nostr applications made with TypeScript
- Host: GitHub
- URL: https://github.com/penpenpng/nostr-typedef
- Owner: penpenpng
- License: mit
- Created: 2023-06-25T19:06:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-28T15:23:37.000Z (about 2 months ago)
- Last Synced: 2024-10-28T22:11:27.245Z (about 2 months ago)
- Topics: nostr, type-definitions, typedefs, types
- Homepage: https://www.npmjs.com/package/nostr-typedef
- Size: 22.5 KB
- Stars: 11
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nostr - nostr-typedef - typedef.svg?style=social) - Type definition files to develop Nostr applications in TypeScript (Libraries / Client reviews and/or comparisons)
README
# nostr-typedef
**nostr-typedef** provides domain-specific type definitions (and useful doc comments) that are often needed to develop Nostr application with TypeScript.
It doesn't contain any implementations, but contains only type definitions.
Therefore, it doesn't affect the bundle size of your application at all.## Installation
For example, if your product is a library and some applications may depend on it, the dependency must be declared in `dependencies` field.
In short, `-S` option is required.```sh
npm install -S nostr-typedef
```If not, that is, if your application is not depended on anything else, you can put the dependency in `devDependencies` field.
```sh
npm install -D nostr-typedef
```## Example
```ts
import type * as Nostr from "nostr-typedef";// OK. No type errors.
const message: Nostr.ToRelayMessage.REQ = ["REQ", "subId", { kinds: [0] }];// NG. Required fields are missed so a type error occurs.
const event: Nostr.Event = {};
```## Types
For a complete list, see [index.d.ts](./index.d.ts).
Particularly useful ones are listed below:
- types
- `Event`
- `UnsignedEvent`
- `EventParameters`
- `Filter`
- namespaces
- `Kind`
- `Tag`
- `Content`
- `ToRelayMessage`
- `ToClientMessage`
- `Nip07`
- `Nip11`