Skip to content

Commit 0cc7a1c

Browse files
committed
fix: deno 2 experimental support
1 parent 689d255 commit 0cc7a1c

28 files changed

+106
-61
lines changed

deno.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"tasks": {
3+
"dev": "deno run --watch main.ts"
4+
},
5+
"imports": {
6+
"@std/assert": "jsr:@std/assert@1",
7+
"@internal/": "./src/internal/",
8+
"@storage/": "./src/storage/",
9+
"postgres-migrations/": "npm:postgres-migrations/",
10+
"postgres-migrations/dist/": "npm:postgres-migrations/dist/",
11+
"ajv": "npm:ajv"
12+
}
13+
}

src/http/error-handler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FastifyInstance } from 'fastify'
22
import { FastifyError } from '@fastify/error'
3-
import { DatabaseError } from 'pg'
3+
import pg from 'pg'
44
import { ErrorCode, isRenderableError } from '@internal/errors'
55

66
/**
@@ -17,15 +17,15 @@ export const setErrorHandler = (app: FastifyInstance) => {
1717

1818
// database error
1919
if (
20-
error instanceof DatabaseError &&
20+
error instanceof pg.DatabaseError &&
2121
[
2222
'Authentication error', // supavisor specific
2323
'Max client connections reached',
2424
'remaining connection slots are reserved for non-replication superuser connections',
2525
'no more connections allowed',
2626
'sorry, too many clients already',
2727
'server login has been failing, try again later',
28-
].some((msg) => (error as DatabaseError).message.includes(msg))
28+
].some((msg) => (error as pg.DatabaseError).message.includes(msg))
2929
) {
3030
return reply.status(429).send({
3131
statusCode: `429`,

src/http/plugins/log-request.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import fastifyPlugin from 'fastify-plugin'
22
import { logSchema, redactQueryParamFromRequest } from '@internal/monitoring'
33
import { trace } from '@opentelemetry/api'
4-
import { FastifyRequest } from 'fastify/types/request'
5-
import { FastifyReply } from 'fastify/types/reply'
4+
import { FastifyRequest, FastifyReply } from 'fastify'
65

76
interface RequestLoggerOptions {
87
excludeUrls?: string[]

src/http/plugins/tracing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fastifyPlugin from 'fastify-plugin'
2-
import { isIP } from 'net'
2+
import { isIP } from 'node:net'
33
import { getTenantConfig } from '@internal/database'
44

55
import { getConfig } from '../../config'

src/http/routes/object/getObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'
22
import { FromSchema } from 'json-schema-to-ts'
3-
import { IncomingMessage, Server, ServerResponse } from 'http'
3+
import { IncomingMessage, Server, ServerResponse } from 'node:http'
44
import { getConfig } from '../../../config'
55
import { AuthenticatedRangeRequest } from '../../types'
66
import { ROUTE_OPERATIONS } from '../operations'

src/http/routes/object/getObjectInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'
22
import { FromSchema } from 'json-schema-to-ts'
3-
import { IncomingMessage, Server, ServerResponse } from 'http'
3+
import { IncomingMessage, Server, ServerResponse } from 'node:http'
44
import { getConfig } from '../../../config'
55
import { AuthenticatedRangeRequest } from '../../types'
66
import { Obj } from '@storage/schemas'

src/http/routes/s3/error-handler.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { FastifyError } from '@fastify/error'
2-
import { FastifyRequest } from 'fastify/types/request'
3-
import { FastifyReply } from 'fastify/types/reply'
2+
import { FastifyReply, FastifyRequest } from 'fastify'
43
import { S3ServiceException } from '@aws-sdk/client-s3'
5-
import { DatabaseError } from 'pg'
4+
import pg from 'pg'
65
import { ErrorCode, StorageBackendError } from '@internal/errors'
76

87
export const s3ErrorHandler = (
@@ -41,14 +40,14 @@ export const s3ErrorHandler = (
4140

4241
// database error
4342
if (
44-
error instanceof DatabaseError &&
43+
error instanceof pg.DatabaseError &&
4544
[
4645
'Max client connections reached',
4746
'remaining connection slots are reserved for non-replication superuser connections',
4847
'no more connections allowed',
4948
'sorry, too many clients already',
5049
'server login has been failing, try again later',
51-
].some((msg) => (error as DatabaseError).message.includes(msg))
50+
].some((msg) => (error as pg.DatabaseError).message.includes(msg))
5251
) {
5352
return reply.status(429).send({
5453
Error: {

src/http/routes/tus/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FastifyBaseLogger, FastifyInstance } from 'fastify'
22
import fastifyPlugin from 'fastify-plugin'
3-
import * as http from 'http'
3+
import * as http from 'node:http'
44
import { ServerOptions, DataStore } from '@tus/server'
55
import { getFileSizeLimit } from '@storage/limits'
66
import { Storage } from '@storage/storage'

src/http/routes/tus/lifecycle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import http from 'http'
1+
import http from 'node:http'
22
import { BaseLogger } from 'pino'
33
import { Upload } from '@tus/server'
4-
import { randomUUID } from 'crypto'
4+
import { randomUUID } from 'node:crypto'
55
import { TenantConnection } from '@internal/database'
66
import { ERRORS, isRenderableError } from '@internal/errors'
77
import { Storage } from '@storage/storage'

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import './start/server'
1+
import './start/server.ts'

0 commit comments

Comments
 (0)