File tree 10 files changed +35
-43
lines changed
10 files changed +35
-43
lines changed Original file line number Diff line number Diff line change 1
1
import { Elysia } from "elysia"
2
- // import { defaultOptions, ip } from "elysia-ip"
3
2
import { defaultOptions , ip } from "../src/index"
4
3
5
4
import type { Server } from "bun"
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " elysia-ip" ,
3
- "version" : " 1.0.3 " ,
3
+ "version" : " 1.0.4 " ,
4
4
"type" : " module" ,
5
5
"author" : {
6
6
"name" : " Gaurish Sethia" ,
Original file line number Diff line number Diff line change 1
- import { IPHeaders } from ".. /types/header "
1
+ import { Options , IPHeaders } from "./types"
2
2
3
3
export const headersToCheck : IPHeaders [ ] = [
4
4
"x-real-ip" , // Nginx proxy/FastCGI
@@ -14,3 +14,9 @@ export const headersToCheck: IPHeaders[] = [
14
14
"true-client-ip" , // Akamai and Cloudflare
15
15
"cf-pseudo-ipv4" , // Cloudflare
16
16
]
17
+
18
+ export const defaultOptions : Options = {
19
+ headersOnly : false ,
20
+ checkHeaders : headersToCheck ,
21
+ injectServer : ( app ) => app . server ,
22
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
export { getIP } from "./services/getip"
2
2
export { plugin as ip } from "./services/plugin"
3
3
4
- export { defaultOptions } from "./constants/defaultOptions"
5
- export { headersToCheck } from "./constants/headerlist"
6
-
7
- export type { IPHeaders } from "./types/header"
8
- export type { Options } from "./types/options"
9
- export type { injectServer } from "./types/injectserver"
4
+ export { defaultOptions , headersToCheck } from "./constants"
5
+ export type { IPHeaders , Options , InjectServer } from "./types"
Original file line number Diff line number Diff line change 1
- import { headersToCheck } from "../constants/headerlist "
2
- import { IPHeaders } from "../types/header "
1
+ import { headersToCheck } from "../constants"
2
+ import { IPHeaders } from "../types"
3
3
4
4
export const getIP = (
5
5
headers : Headers ,
Original file line number Diff line number Diff line change 1
1
import { Elysia } from "elysia"
2
- import { getIP } from "../services /getip"
3
- import { defaultOptions } from "../constants/defaultOptions "
4
- import type { Options } from "../types/options "
2
+ import { getIP } from "./getip"
3
+ import { defaultOptions } from "../constants"
4
+ import type { Options } from "../types"
5
5
6
6
export const plugin = ( userOptions ?: Partial < Options > ) => ( app : Elysia ) => {
7
7
const options : Options = {
Original file line number Diff line number Diff line change 1
- import type { IPHeaders } from "./header"
2
- import type { injectServer } from "./injectserver"
1
+ import type { Server } from "bun"
2
+ import type Elysia from "elysia"
3
+
4
+ export type IPHeaders =
5
+ | "x-real-ip"
6
+ | "x-client-ip"
7
+ | "cf-connecting-ip"
8
+ | "fastly-client-ip"
9
+ | "x-cluster-client-ip"
10
+ | "x-forwarded"
11
+ | "forwarded-for"
12
+ | "forwarded"
13
+ | "x-forwarded"
14
+ | "appengine-user-ip"
15
+ | "true-client-ip"
16
+ | "cf-pseudo-ipv4"
17
+ | ( string & { } )
18
+
19
+ export type InjectServer = ( app : Elysia ) => Server | null
3
20
4
21
export interface Options {
5
22
/**
@@ -15,5 +32,5 @@ export interface Options {
15
32
/**
16
33
*
17
34
*/
18
- injectServer : injectServer
35
+ injectServer : InjectServer
19
36
}
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments