Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions jest.config.ts

This file was deleted.

26 changes: 17 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
{
"name": "ts-http-status-utils",
"version": "1.1.0",
"type": "module",
"description": "HTTP status code declarations, descriptions and utils",
"main": "dist/index.js",
"main": "./dist/ts-http-status-utils.umd.cjs",
"module": "./dist/ts-http-status-utils.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/ts-http-status-utils.js",
"require": "./dist/ts-http-status-utils.umd.cjs",
"types": "./dist/index.d.ts"
}
},
"files": [
"dist"
],
Expand All @@ -23,18 +32,17 @@
"http-error-message"
],
"scripts": {
"build": "yarn clean && tsc --emitDeclarationOnly --declaration --project tsconfig.json",
"build": "yarn clean && tsc && vite build",
"clean": "rimraf dist",
"test": "jest",
"test": "vitest",
"watch": "tsc --watch"
},
"devDependencies": {
"@types/jest": "^29.5.11",
"jest": "^29.7.0",
"@types/node": "^20.10.6",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.1",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vite": "^5.0.11",
"vite-plugin-dts": "^3.7.0",
"vitest": "^1.1.3"
}
}
6 changes: 6 additions & 0 deletions src/Interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ import { StatusCode } from "../StatusCode";
import { StatusDescription } from "../StatusDescription";
import { StatusPhrase } from "../StatusPhrase";

/**
* Represents an HTTP response object.
*/
export interface HttpResponseObject {
code: StatusCode;
phrase: StatusPhrase;
description: StatusDescription;
}

/**
* Represents a dictionary of HTTP response objects.
*/
export interface IHttpResponsesDictionary {
[id: number]: HttpResponseObject;
}
1 change: 1 addition & 0 deletions tests/helpers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import {
makeHttpResponsesDictionary,
getStatusPhraseByCode,
Expand Down
28 changes: 18 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": ["es2015", "dom"],
"strict": true,
"esModuleInterop": true,
"declaration": true,
"outDir": "dist",
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
// "suppressImplicitAnyIndexErrors": true,
"noEmit": false
"types": ["vitest/globals"],

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
Expand Down
28 changes: 28 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { resolve } from "path";
import { defineConfig } from "vite";
import { defineConfig as vitestConfig } from "vitest/config";
import dts from "vite-plugin-dts";

const testConfig = vitestConfig({
test: {
include: ["./tests/*.ts"],
globals: true,
},
});

const config = defineConfig({
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
name: "ts-http-status-utils",
fileName: "ts-http-status-utils",
formats: ["es"],
},
},
plugins: [dts({ insertTypesEntry: true })],
});

export default {
...testConfig,
...config,
};
Loading