Skip to content

Commit bb680bd

Browse files
author
v1rtl
committed
bump deps & eliminate lint errors
1 parent f5ecac7 commit bb680bd

File tree

12 files changed

+54
-57
lines changed

12 files changed

+54
-57
lines changed

app.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import { Router, serve, Server, rg, pushMiddleware } from './deps.ts'
33
import { NextFunction, RHandler as Handler, Middleware, UseMethodParams } from './types.ts'
44
import { onErrorHandler, ErrorHandler } from './onError.ts'
5-
import { setImmediate } from 'https://deno.land/std@0.99.0/node/timers.ts'
5+
import { setImmediate } from 'https://deno.land/std@0.100.0/node/timers.ts'
66
import type { Request } from './request.ts'
77
import type { Response } from './response.ts'
88
import { getURLParams, getPathname } from './utils/parseUrl.ts'
99
import { extendMiddleware } from './extend.ts'
10-
import * as path from 'https://deno.land/std@0.99.0/path/mod.ts'
10+
import * as path from 'https://deno.land/std@0.100.0/path/mod.ts'
1111

1212
const lead = (x: string) => (x.charCodeAt(0) === 47 ? x : '/' + x)
1313

deps.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ export { vary } from 'https://deno.land/x/[email protected]/mod.ts'
77
export { isIP } from 'https://deno.land/x/[email protected]/mod.ts'
88
export { Accepts } from 'https://deno.land/x/[email protected]/mod.ts'
99
export { encodeUrl } from 'https://deno.land/x/[email protected]/mod.ts'
10-
export { charset, contentType, lookup } from 'https://deno.land/x/[email protected].0/mod.ts'
10+
export { charset, contentType, lookup } from 'https://deno.land/x/[email protected].1/mod.ts'
1111
export { parse as rg } from 'https://deno.land/x/[email protected]/src/index.js'
12-
export { forwarded } from 'https://deno.land/x/[email protected].7/mod.ts'
13-
export * from 'https://deno.land/x/[email protected].8/mod.ts'
14-
import type { ServerRequest as Req, Response as ServerResponse } from 'https://deno.land/std@0.99.0/http/server.ts'
12+
export { forwarded } from 'https://deno.land/x/[email protected].8/mod.ts'
13+
export * from 'https://deno.land/x/[email protected].9/mod.ts'
14+
import type { ServerRequest as Req, Response as ServerResponse } from 'https://deno.land/std@0.100.0/http/server.ts'
1515

1616
interface Res extends ServerResponse {
1717
headers: Headers
1818
}
1919

2020
export type { Req, Res }
2121

22-
export { serve, Server } from 'https://deno.land/std@0.99.0/http/server.ts'
22+
export { serve, Server } from 'https://deno.land/std@0.100.0/http/server.ts'
2323

2424
export { Router, pushMiddleware } from 'https://esm.sh/@tinyhttp/[email protected]'

examples/jwt/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { App } from '../../mod.ts'
22
import { getNumericDate, Payload, Header, create, verify } from 'https://deno.land/x/[email protected]/mod.ts'
3-
import { readAll } from 'https://deno.land/std@0.99.0/io/util.ts'
3+
import { readAll } from 'https://deno.land/std@0.100.0/io/util.ts'
44

55
const SECRET = 'my_secret'
66

extensions/res/cookie.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Req, Res } from '../../deps.ts'
2-
import * as cookie from 'https://deno.land/std@0.99.0/http/cookie.ts'
2+
import * as cookie from 'https://deno.land/std@0.100.0/http/cookie.ts'
33

44
export const setCookie = <Request extends Req = Req, Response extends Res = Res>(req: Request, res: Response) => (
55
name: string,

extensions/res/download.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { contentDisposition } from 'https://esm.sh/@tinyhttp/content-disposition'
22
import { SendFileOptions, sendFile } from './send/sendFile.ts'
3-
import { extname } from 'https://deno.land/std@0.99.0/path/mod.ts'
3+
import { extname } from 'https://deno.land/std@0.100.0/path/mod.ts'
44
import { setContentType, setHeader } from './headers.ts'
55
import { Req, Res } from '../../deps.ts'
66

extensions/res/send/sendFile.ts

+36-39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Req, Res } from '../../../deps.ts'
2-
import { isAbsolute, join, extname } from 'https://deno.land/std@0.99.0/path/mod.ts'
2+
import { isAbsolute, join, extname } from 'https://deno.land/std@0.100.0/path/mod.ts'
33
import { contentType } from '../../../deps.ts'
44
import { createETag } from '../utils.ts'
55
import { send } from './send.ts'
@@ -22,59 +22,56 @@ export type SendFileOptions = Partial<{
2222
*
2323
* @param res Response
2424
*/
25-
export const sendFile = <Request extends Req = Req, Response extends Res = Res>(req: Request, res: Response) => (
26-
path: string,
27-
opts: SendFileOptions = {}
28-
) => {
29-
const { root, headers = {}, encoding = 'utf-8', ...options } = opts
25+
export const sendFile =
26+
<Request extends Req = Req, Response extends Res = Res>(req: Request, res: Response) =>
27+
(path: string, opts: SendFileOptions = {}) => {
28+
const { root, headers = {}, encoding = 'utf-8', ...options } = opts
3029

31-
if (!isAbsolute(path) && !root) throw new TypeError('path must be absolute')
30+
if (!isAbsolute(path) && !root) throw new TypeError('path must be absolute')
3231

33-
const filePath = root ? join(root, path) : path
32+
const filePath = root ? join(root, path) : path
3433

35-
let stats: Deno.FileInfo
34+
const stats = Deno.statSync(filePath)
3635

37-
stats = Deno.statSync(filePath)
36+
headers['Content-Encoding'] = encoding
3837

39-
headers['Content-Encoding'] = encoding
38+
headers['Last-Modified'] = stats.mtime!.toUTCString()
4039

41-
headers['Last-Modified'] = stats.mtime!.toUTCString()
40+
headers['Content-Type'] = contentType(extname(path)) || 'text/html'
4241

43-
headers['Content-Type'] = contentType(extname(path)) || 'text/html'
42+
headers['ETag'] = createETag(stats)
4443

45-
headers['ETag'] = createETag(stats)
44+
headers['Content-Length'] = `${stats.size}`
4645

47-
headers['Content-Length'] = `${stats.size}`
46+
headers['Content-Security-Policy'] = "default-src 'none'"
47+
headers['X-Content-Type-Options'] = 'nosniff'
4848

49-
headers['Content-Security-Policy'] = "default-src 'none'"
50-
headers['X-Content-Type-Options'] = 'nosniff'
49+
let status = 200
5150

52-
let status = 200
51+
if (req.headers.get('range')) {
52+
status = 206
53+
const [x, y] = req.headers?.get('range')?.replace('bytes=', '').split('-') as [string, string]
54+
const end = (options.end = parseInt(y, 10) || stats.size - 1)
55+
const start = (options.start = parseInt(x, 10) || 0)
5356

54-
if (req.headers.get('range')) {
55-
status = 206
56-
const [x, y] = req.headers?.get('range')?.replace('bytes=', '').split('-') as [string, string]
57-
const end = (options.end = parseInt(y, 10) || stats.size - 1)
58-
const start = (options.start = parseInt(x, 10) || 0)
59-
60-
if (start >= stats.size || end >= stats.size) {
61-
res.status = 416
62-
res.headers?.set('Content-Range', `bytes */${stats.size}`)
63-
req.respond({})
64-
return res
57+
if (start >= stats.size || end >= stats.size) {
58+
res.status = 416
59+
res.headers?.set('Content-Range', `bytes */${stats.size}`)
60+
req.respond({})
61+
return res
62+
}
63+
headers['Content-Range'] = `bytes ${start}-${end}/${stats.size}`
64+
headers['Content-Length'] = `${end - start + 1}`
65+
headers['Accept-Ranges'] = 'bytes'
6566
}
66-
headers['Content-Range'] = `bytes ${start}-${end}/${stats.size}`
67-
headers['Content-Length'] = `${end - start + 1}`
68-
headers['Accept-Ranges'] = 'bytes'
69-
}
7067

71-
for (const [k, v] of Object.entries(headers)) res.headers?.set(k, v)
68+
for (const [k, v] of Object.entries(headers)) res.headers?.set(k, v)
7269

73-
res.status = status
70+
res.status = status
7471

75-
const file = Deno.openSync(filePath, { read: true, ...options })
72+
const file = Deno.openSync(filePath, { read: true, ...options })
7673

77-
send(req, res)(file)
74+
send(req, res)(file)
7875

79-
return res
80-
}
76+
return res
77+
}

extensions/res/utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { format, parse } from 'https://deno.land/x/content_type/mod.ts'
2-
import { etag as eTag } from 'https://deno.land/x/[email protected].3/src/utils/etag.ts'
1+
import { format, parse } from 'https://deno.land/x/content_type@1.0.1/mod.ts'
2+
import { etag as eTag } from 'https://deno.land/x/[email protected].4/src/utils/etag.ts'
33
import { lookup } from '../../deps.ts'
44

55
export const createETag = (body: Parameters<typeof eTag>[0]) => {
@@ -21,7 +21,7 @@ export function acceptParams(str: string, index?: number) {
2121
const ret: {
2222
value: string
2323
quality: number
24-
params: Record<string, any>
24+
params: Record<string, string>
2525
originalIndex?: number
2626
} = { value: parts[0], quality: 1, params: {}, originalIndex: index }
2727

request.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// deno-lint-ignore-file
2-
import { ServerRequest } from 'https://deno.land/std@0.99.0/http/server.ts'
2+
import { ServerRequest } from 'https://deno.land/std@0.100.0/http/server.ts'
33
import { App } from './app.ts'
44
import { QueryParams, Ranges, Protocol, AcceptsReturns, Middleware } from './types.ts'
55

response.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { SendFileOptions } from './extensions/res/send/sendFile.ts'
55
import type { TemplateEngineOptions, App } from './app.ts'
66
import type { FormatProps } from './extensions/res/format.ts'
77
import type { DownloadOptions } from './extensions/res/download.ts'
8-
import { Cookie } from 'https://deno.land/std@0.99.0/http/cookie.ts'
8+
import { Cookie } from 'https://deno.land/std@0.100.0/http/cookie.ts'
99

1010
export interface Response<O = any> extends ServerResponse, tinyhttp.Response {
1111
headers: Headers

tests/core/app.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { App } from '../../app.ts'
33
import { BindToSuperDeno, InitAppAndTest } from '../util.ts'
44
import { renderFile as eta } from 'https://deno.land/x/[email protected]/mod.ts'
55
import { EtaConfig } from 'https://deno.land/x/[email protected]/config.ts'
6-
import * as path from 'https://deno.land/std@0.99.0/path/mod.ts'
6+
import * as path from 'https://deno.land/std@0.100.0/path/mod.ts'
77

88
describe('App constructor', () => {
99
it('app.locals are get and set', () => {

tests/modules/res.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from '../../extensions/res/headers.ts'
1010
import { redirect } from '../../extensions/res/redirect.ts'
1111
import { attachment } from '../../extensions/res/download.ts'
12-
import * as path from 'https://deno.land/std@0.99.0/path/mod.ts'
12+
import * as path from 'https://deno.land/std@0.100.0/path/mod.ts'
1313

1414
const __dirname = new URL('.', import.meta.url).pathname
1515

utils/parseUrl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { parse } from 'https://deno.land/std@0.99.0/node/querystring.ts'
1+
import { parse } from 'https://deno.land/std@0.100.0/node/querystring.ts'
22

33
type Regex = {
44
keys: string[] | boolean

0 commit comments

Comments
 (0)