generated from templates/typescript-types
	add some id and http types
This commit is contained in:
		@@ -23,8 +23,8 @@ jobs:
 | 
			
		||||
 | 
			
		||||
      - name: Login to package registry
 | 
			
		||||
        run: |
 | 
			
		||||
          npm config set @<scope name>:registry https://gitea.jbrumond.me/api/packages/<scope name>/npm/
 | 
			
		||||
          npm config set -- '//gitea.jbrumond.me/api/packages/<scope name>/npm/:_authToken' "$NPM_PUBLISH_TOKEN"
 | 
			
		||||
          npm config set @js:registry https://gitea.jbrumond.me/api/packages/js/npm/
 | 
			
		||||
          npm config set -- '//gitea.jbrumond.me/api/packages/js/npm/:_authToken' "$NPM_PUBLISH_TOKEN"
 | 
			
		||||
 | 
			
		||||
      - name: Publish package
 | 
			
		||||
        run: npm publish
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,15 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "@templates/typescript-types",
 | 
			
		||||
  "name": "@js/types",
 | 
			
		||||
  "version": "1.0.0",
 | 
			
		||||
  "description": "Template project for creating new TypeScript type-definition-only packages",
 | 
			
		||||
  "main": "src/index.d.ts",
 | 
			
		||||
  "types": "src/index.d.ts",
 | 
			
		||||
  "publishConfig": {
 | 
			
		||||
    "registry": "https://gitea.jbrumond.me/api/packages/templates/npm/"
 | 
			
		||||
    "registry": "https://gitea.jbrumond.me/api/packages/js/npm/"
 | 
			
		||||
  },
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "https://gitea.jbrumond.me/templates/typescript-types.git"
 | 
			
		||||
    "url": "https://gitea.jbrumond.me/js/typescript-types.git"
 | 
			
		||||
  },
 | 
			
		||||
  "author": "James Brumond <https://jbrumond.me>",
 | 
			
		||||
  "license": "ISC",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										38
									
								
								readme.md
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								readme.md
									
									
									
									
									
								
							@@ -1,27 +1,29 @@
 | 
			
		||||
 | 
			
		||||
Template project for creating new TypeScript type-definition-only packages
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
## Get Started
 | 
			
		||||
 | 
			
		||||
### Pull down the code
 | 
			
		||||
Collection of general-purpose type definitions
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
git init
 | 
			
		||||
git pull https://gitea.jbrumond.me/templates/typescript-types.git master
 | 
			
		||||
# Update project npm config to refer to correct registry for the @js scope
 | 
			
		||||
echo '@js:registry=https://gitea.jbrumond.me/api/packages/js/npm/' >> ./.npmrc
 | 
			
		||||
 | 
			
		||||
npm install --save-dev @js/types
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Update configuration
 | 
			
		||||
 | 
			
		||||
- In `package.json`, update any fields like `name`, `description`, `repository`, etc.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Building
 | 
			
		||||
 | 
			
		||||
No build step is necessary, as the types are written directly as `.d.ts` files to begin with.
 | 
			
		||||
## Types
 | 
			
		||||
 | 
			
		||||
```ts
 | 
			
		||||
import {
 | 
			
		||||
	// Various identifier strings
 | 
			
		||||
	HttpURL,
 | 
			
		||||
	UUID,
 | 
			
		||||
	SnowflakeID,
 | 
			
		||||
 | 
			
		||||
	// HTTP verbs
 | 
			
		||||
	HttpVerb,
 | 
			
		||||
	HttpVerbExtended,
 | 
			
		||||
 | 
			
		||||
	// Pino-compatible logger interface
 | 
			
		||||
	Logger,
 | 
			
		||||
	LogFn,
 | 
			
		||||
} from '@js/types';
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								src/http.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/http.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
 | 
			
		||||
/**  */
 | 
			
		||||
export type HttpVerb
 | 
			
		||||
	= 'GET'
 | 
			
		||||
	| 'HEAD'
 | 
			
		||||
	| 'POST'
 | 
			
		||||
	| 'PUT'
 | 
			
		||||
	| 'DELETE'
 | 
			
		||||
	| 'OPTIONS'
 | 
			
		||||
	;
 | 
			
		||||
 | 
			
		||||
/**  */
 | 
			
		||||
export type HttpVerbExtended
 | 
			
		||||
	= HttpVerb
 | 
			
		||||
	| 'PATCH'
 | 
			
		||||
	| 'QUERY'
 | 
			
		||||
	| 'CONNECT'
 | 
			
		||||
	| 'TRACE'
 | 
			
		||||
	;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										6
									
								
								src/identifiers.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/identifiers.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
 | 
			
		||||
export type HttpURL = `http://${string}` | `https://${string}`;
 | 
			
		||||
 | 
			
		||||
export type UUID = `${string}-${string}-${string}-${string}-${string}`;
 | 
			
		||||
 | 
			
		||||
export type SnowflakeID = `${bigint}`;
 | 
			
		||||
							
								
								
									
										4
									
								
								src/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								src/index.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -1,2 +1,4 @@
 | 
			
		||||
 | 
			
		||||
export function hello() : string;
 | 
			
		||||
export * from './http';
 | 
			
		||||
export * from './identifiers';
 | 
			
		||||
export * from './logger';
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										19
									
								
								src/logger.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/logger.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
 | 
			
		||||
// These types are based on / compatible with the pino Logger object
 | 
			
		||||
 | 
			
		||||
export interface LogFn {
 | 
			
		||||
	<T extends object>(obj: T, msg?: string, ...args: any[]): void;
 | 
			
		||||
	(obj: unknown, msg?: string, ...args: any[]): void;
 | 
			
		||||
	(msg: string, ...args: any[]): void;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface Logger {
 | 
			
		||||
	child(bindings: Record<string, any>, options?: any): Logger;
 | 
			
		||||
	fatal: LogFn;
 | 
			
		||||
	error: LogFn;
 | 
			
		||||
	warn: LogFn;
 | 
			
		||||
	info: LogFn;
 | 
			
		||||
	debug: LogFn;
 | 
			
		||||
	trace: LogFn;
 | 
			
		||||
	silent: LogFn;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user