Skip to content

Commit 7453d12

Browse files
committed
🎉 feat: init
0 parents  commit 7453d12

20 files changed

Lines changed: 1558 additions & 0 deletions

.eslintrc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
"env": {
3+
"es2021": true,
4+
"node": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/recommended"
9+
],
10+
"parser": "@typescript-eslint/parser",
11+
"parserOptions": {
12+
"ecmaVersion": "latest",
13+
"sourceType": "module"
14+
},
15+
"plugins": [
16+
"@typescript-eslint"
17+
],
18+
"rules": {
19+
"@typescript-eslint/ban-types": 'off',
20+
'@typescript-eslint/no-explicit-any': 'off'
21+
},
22+
"ignorePatterns": ["example/*", "tests/**/*"]
23+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
3+
node_modules
4+
.pnpm-debug.log
5+
dist

.npmignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.git
2+
.gitignore
3+
.prettierrc
4+
.cjs.swcrc
5+
.es.swcrc
6+
bun.lockb
7+
8+
node_modules
9+
tsconfig.json
10+
pnpm-lock.yaml
11+
jest.config.js
12+
nodemon.json
13+
14+
example
15+
tests
16+
test
17+
CHANGELOG.md
18+
.eslintrc.js
19+
tsconfig.cjs.json
20+
tsconfig.esm.json

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 0.7.0 - 26 Oct 2023
2+
Feature:
3+
- Init

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2022 saltyAom
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# @elysiajs/server-timing
2+
Plugin for [elysia](https://github.com/elysiajs/elysia) for performance audit via [server timing](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing)
3+
4+
## Installation
5+
```bash
6+
bun add @elysiajs/server-timing
7+
```
8+
9+
Please refers to the [documentation](https://elysiajs.com/plugins/server-timing) on how to use the package

bun.lockb

43.8 KB
Binary file not shown.

example/index.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Elysia } from 'elysia'
2+
import { serverTiming } from '../src/index'
3+
4+
const delay = (time = 1000) => new Promise((r) => setTimeout(r, time))
5+
6+
const app = new Elysia()
7+
.use(
8+
serverTiming({
9+
allow: ({ request }) => {
10+
return new URL(request.url).pathname !== '/no-trace'
11+
}
12+
})
13+
)
14+
.onRequest(async function init() {
15+
await delay(50)
16+
})
17+
.get(
18+
'/',
19+
function demo() {
20+
return 'Server Timing'
21+
},
22+
{
23+
beforeHandle: [
24+
async function a() {
25+
await delay(100)
26+
},
27+
async function b() {
28+
await delay(250)
29+
}
30+
],
31+
async afterHandle() {
32+
await delay(50)
33+
}
34+
}
35+
)
36+
.get('/no-trace', () => 'hi')
37+
.listen(3000)

package.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "@elysiajs/server-timing",
3+
"version": "0.7.0",
4+
"description": "Plugin for Elysia for performance audit via server timing",
5+
"author": {
6+
"name": "saltyAom",
7+
"url": "https://github.com/SaltyAom",
8+
"email": "saltyaom@gmail.com"
9+
},
10+
"main": "./dist/index.js",
11+
"exports": {
12+
"bun": "./dist/index.js",
13+
"node": "./dist/cjs/index.js",
14+
"require": "./dist/cjs/index.js",
15+
"import": "./dist/index.js",
16+
"default": "./dist/index.js"
17+
},
18+
"types": "./src/index.ts",
19+
"keywords": [
20+
"elysia",
21+
"server-timing"
22+
],
23+
"homepage": "https://github.com/elysiajs/elysia-server-timing",
24+
"repository": {
25+
"type": "git",
26+
"url": "https://github.com/elysiajs/elysia-server-timing"
27+
},
28+
"bugs": "https://github.com/elysiajs/elysia-server-timing/issues",
29+
"license": "MIT",
30+
"scripts": {
31+
"dev": "bun run --watch example/index.ts",
32+
"test": "bun test && npm run test:node",
33+
"test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js",
34+
"build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
35+
"release": "npm run build && npm run test && npm publish --access public"
36+
},
37+
"peerDependencies": {
38+
"elysia": ">= 0.7.20"
39+
},
40+
"devDependencies": {
41+
"@types/node": "^20.1.4",
42+
"bun-types": "^0.5.8",
43+
"elysia": "0.7.20",
44+
"eslint": "^8.40.0",
45+
"rimraf": "4.3.1",
46+
"typescript": "^5.0.4"
47+
}
48+
}

0 commit comments

Comments
 (0)