Skip to content

Commit 42217c1

Browse files
committed
Set up the project
This mega-commit sets up the entire project including the first version of the package.
1 parent ca49cc6 commit 42217c1

13 files changed

Lines changed: 6060 additions & 2 deletions

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = tab
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
groups:
8+
eslint:
9+
patterns:
10+
- "*eslint*"
11+
12+
- package-ecosystem: "github-actions"
13+
directory: ".github/workflows"
14+
schedule:
15+
interval: "daily"

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build the package
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version-file: .node-version
20+
- run: npm ci
21+
- run: npm run build

.github/workflows/lint.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
actionlint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version-file: .node-version
16+
- name: Lint GitHub Action workflows
17+
uses: raven-actions/actionlint@v2
18+
eslint:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version-file: .node-version
25+
- run: npm ci
26+
- run: npm run lint:eslint
27+
prettier:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version-file: .node-version
34+
- run: npm ci
35+
- run: npm run lint:prettier
36+
tsc:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-node@v4
41+
with:
42+
node-version-file: .node-version
43+
- run: npm ci
44+
- run: npm run lint:tsc

.github/workflows/publish.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release to npm
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "package.json"
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: .node-version
21+
registry-url: "https://registry.npmjs.org/"
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Compare package version
27+
id: version_check
28+
run: |
29+
VERSION=$(jq -r '.version' package.json)
30+
PREV_VERSION=$(git show HEAD~1:package.json | jq -r '.version')
31+
echo "current=$VERSION" >> "$GITHUB_OUTPUT"
32+
echo "previous=$PREV_VERSION" >> "$GITHUB_OUTPUT"
33+
if [ "$VERSION" = "$PREV_VERSION" ]; then
34+
echo "No version change. Skipping publish."
35+
exit 0
36+
fi
37+
38+
- name: Build
39+
run: npm run build
40+
41+
- name: Publish to npm
42+
run: npm publish --access public
43+
env:
44+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
1-
# http-status-codes
2-
An organized collection of meaningfully named HTTP status code constants.
1+
# HTTP Status Codes
2+
3+
This simple package provides an organized collection of meaningfully named HTTP status code constants.
4+
5+
## Installation
6+
7+
```sh
8+
npm install http-status-codes
9+
```
10+
11+
## Usage
12+
13+
Import the enums and use them in your code for clarity and type safety:
14+
15+
```js
16+
import { HTTP_STATUS } from "http-status-codes-enum";
17+
18+
if (response.status === HTTP_STATUS.SUCCESSFUL.OK) {
19+
// handle success
20+
}
21+
22+
if (response.status === HTTP_STATUS.CLIENT_ERROR.NOT_FOUND) {
23+
// handle 404
24+
}
25+
```
26+
27+
## Status Code Groups
28+
29+
- `INFORMATIONAL`: 1xx codes (e.g., CONTINUE, PROCESSING)
30+
- `SUCCESSFUL`: 2xx codes (e.g., OK, CREATED)
31+
- `REDIRECTION`: 3xx codes (e.g., MOVED_PERMANENTLY, FOUND)
32+
- `CLIENT_ERROR`: 4xx codes (e.g., BAD_REQUEST, NOT_FOUND)
33+
- `SERVER_ERROR`: 5xx codes (e.g., INTERNAL_SERVER_ERROR, SERVICE_UNAVAILABLE)
34+
35+
## API
36+
37+
All status codes are available as enums under the `HTTP_STATUS` object. Example:
38+
39+
```js
40+
HTTP_STATUS.SUCCESSFUL.CREATED; // 201
41+
HTTP_STATUS.CLIENT_ERROR.FORBIDDEN; // 403
42+
```

eslint.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from "eslint/config";
2+
import js from "@eslint/js";
3+
import love from "eslint-config-love";
4+
import tseslint from "typescript-eslint";
5+
import prettier from "eslint-config-prettier";
6+
7+
export default defineConfig([
8+
js.configs.recommended,
9+
tseslint.configs.eslintRecommended,
10+
tseslint.configs.recommendedTypeChecked,
11+
tseslint.configs.strict,
12+
love,
13+
prettier,
14+
]);

0 commit comments

Comments
 (0)