Skip to content

Commit 11b8b79

Browse files
committed
feat: main define_config helper and main exports
1 parent 7027c9e commit 11b8b79

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

index.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* @adonisjs/http-server
3+
*
4+
* (c) AdonisJS
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
export { Request } from './src/request.js'
11+
export { Response } from './src/response.js'
12+
export { Redirect } from './src/redirect.js'
13+
export { Server } from './src/server/main.js'
14+
export { Router } from './src/router/main.js'
15+
export { Route } from './src/router/route.js'
16+
export { RouteGroup } from './src/router/group.js'
17+
export { defineConfig } from './src/define_config.js'
18+
export { RouteResource } from './src/router/resource.js'
19+
export { BriskRoute } from './src/router/brisk.js'
20+
export { HttpContext } from './src/http_context/main.js'
21+
export { HttpException } from './src/exceptions/http_exception.js'
22+
export { AbortException } from './src/exceptions/abort_exception.js'
23+
export { RouteNotFoundException } from './src/exceptions/route_not_found.js'
24+
export { CannotMakeURLException } from './src/exceptions/cannot_make_url.js'
25+
export { DuplicateRouteException } from './src/exceptions/duplicate_route.js'
26+
export { CannotLookupRouteException } from './src/exceptions/cannot_lookup_route.js'
27+
export { DuplicateRouteNameException } from './src/exceptions/duplicate_route_name.js'
28+
export { DuplicateRouteParamException } from './src/exceptions/duplicate_route_param.js'

src/define_config.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* @adonisjs/http-server
3+
*
4+
* (c) AdonisJS
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
import proxyAddr from 'proxy-addr'
11+
import type { RequestConfig } from './types/request.js'
12+
import type { ResponseConfig } from './types/response.js'
13+
14+
/**
15+
* Define configuration for the HTTP server
16+
*/
17+
export function defineConfig(
18+
config: Partial<RequestConfig & ResponseConfig>
19+
): RequestConfig & ResponseConfig {
20+
return {
21+
allowMethodSpoofing: false,
22+
trustProxy: proxyAddr.compile('loopback'),
23+
subdomainOffset: 2,
24+
generateRequestId: false,
25+
useAsyncLocalStorage: false,
26+
etag: false,
27+
jsonpCallbackName: 'callback',
28+
cookie: {
29+
maxAge: '2h',
30+
path: '/',
31+
httpOnly: true,
32+
secure: false,
33+
sameSite: false,
34+
},
35+
...config,
36+
}
37+
}

0 commit comments

Comments
 (0)