Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
226cb0193b
|
|||
|
aca4c8aa4d
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@extollo/lib",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.5",
|
||||
"description": "The framework library that lifts up your code.",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
@@ -8,8 +8,8 @@
|
||||
"lib": "lib"
|
||||
},
|
||||
"dependencies": {
|
||||
"@extollo/di": "git+https://code.garrettmills.dev/extollo/di",
|
||||
"@extollo/util": "git+https://code.garrettmills.dev/extollo/util",
|
||||
"@extollo/di": "^0.4.5",
|
||||
"@extollo/util": "^0.3.3",
|
||||
"@types/busboy": "^0.2.3",
|
||||
"@types/negotiator": "^0.6.1",
|
||||
"@types/node": "^14.14.37",
|
||||
|
||||
76
pnpm-lock.yaml
generated
76
pnpm-lock.yaml
generated
@@ -1,6 +1,6 @@
|
||||
dependencies:
|
||||
'@extollo/di': code.garrettmills.dev/extollo/di/902c31997016d24c735448bbf1e58f06e94f4139
|
||||
'@extollo/util': code.garrettmills.dev/extollo/util/131e0c93ee7ea67d771053fbd69fbf7f6612fadf
|
||||
'@extollo/di': 0.4.5
|
||||
'@extollo/util': 0.3.3
|
||||
'@types/busboy': 0.2.3
|
||||
'@types/negotiator': 0.6.1
|
||||
'@types/node': 14.14.37
|
||||
@@ -33,6 +33,31 @@ packages:
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-A2aa3QTkWoyqsZZFl56MLUsfmh7O0gN41IPvXAE/++8ojpbz12SszD7JEGYVdn4f9Kt4amIei07swF1h4AqmmQ==
|
||||
/@extollo/di/0.4.5:
|
||||
dependencies:
|
||||
'@extollo/util': 0.3.3
|
||||
'@types/node': 14.14.37
|
||||
reflect-metadata: 0.1.13
|
||||
typescript: 4.2.3
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-PDYzYtFesHgdyhQKmAw1z+U13QLBOFgmrvjZgFls1Em+/P11PKWE43Ar3qXSLSIgPhrXU7grYdSyU8EGLBsekw==
|
||||
/@extollo/util/0.3.3:
|
||||
dependencies:
|
||||
'@types/mkdirp': 1.0.1
|
||||
'@types/node': 14.14.37
|
||||
'@types/rimraf': 3.0.0
|
||||
'@types/ssh2': 0.5.46
|
||||
'@types/uuid': 8.3.0
|
||||
colors: 1.4.0
|
||||
mkdirp: 1.0.4
|
||||
rimraf: 3.0.2
|
||||
ssh2: 0.8.9
|
||||
typescript: 4.2.3
|
||||
uuid: 8.3.2
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-qjUVSeHaOIwKcI4n1x4/t5k6Xqej/sL/0J0S3WG3s/EpRycXrAjog53/YsmQXCQcGaj7Ir5wJmLLHawZUWUfyQ==
|
||||
/@types/busboy/0.2.3:
|
||||
dependencies:
|
||||
'@types/node': 14.14.37
|
||||
@@ -125,10 +150,10 @@ packages:
|
||||
node: '>= 10.0.0'
|
||||
resolution:
|
||||
integrity: sha512-GAwkz0AihzY5bkwIY5QDR+LvsRQgB/B+1foMPvi0FZPMl5fjD7ICiznUiBdLYMH1QYe6vqu4gWYytZOccLouFw==
|
||||
/balanced-match/1.0.0:
|
||||
/balanced-match/1.0.2:
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
|
||||
integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
|
||||
/bcrypt-pbkdf/1.0.2:
|
||||
dependencies:
|
||||
tweetnacl: 0.14.5
|
||||
@@ -137,7 +162,7 @@ packages:
|
||||
integrity: sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=
|
||||
/brace-expansion/1.1.11:
|
||||
dependencies:
|
||||
balanced-match: 1.0.0
|
||||
balanced-match: 1.0.2
|
||||
concat-map: 0.0.1
|
||||
dev: false
|
||||
resolution:
|
||||
@@ -576,46 +601,9 @@ packages:
|
||||
node: '>=6'
|
||||
resolution:
|
||||
integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==
|
||||
code.garrettmills.dev/extollo/di/902c31997016d24c735448bbf1e58f06e94f4139:
|
||||
dependencies:
|
||||
'@extollo/util': code.garrettmills.dev/extollo/util/131e0c93ee7ea67d771053fbd69fbf7f6612fadf
|
||||
'@types/node': 14.14.37
|
||||
reflect-metadata: 0.1.13
|
||||
typescript: 4.2.3
|
||||
dev: false
|
||||
name: '@extollo/di'
|
||||
prepare: true
|
||||
requiresBuild: true
|
||||
resolution:
|
||||
commit: 902c31997016d24c735448bbf1e58f06e94f4139
|
||||
repo: https://code.garrettmills.dev/extollo/di
|
||||
type: git
|
||||
version: 0.4.4
|
||||
code.garrettmills.dev/extollo/util/131e0c93ee7ea67d771053fbd69fbf7f6612fadf:
|
||||
dependencies:
|
||||
'@types/mkdirp': 1.0.1
|
||||
'@types/node': 14.14.37
|
||||
'@types/rimraf': 3.0.0
|
||||
'@types/ssh2': 0.5.46
|
||||
'@types/uuid': 8.3.0
|
||||
colors: 1.4.0
|
||||
mkdirp: 1.0.4
|
||||
rimraf: 3.0.2
|
||||
ssh2: 0.8.9
|
||||
typescript: 4.2.3
|
||||
uuid: 8.3.2
|
||||
dev: false
|
||||
name: '@extollo/util'
|
||||
prepare: true
|
||||
requiresBuild: true
|
||||
resolution:
|
||||
commit: 131e0c93ee7ea67d771053fbd69fbf7f6612fadf
|
||||
repo: https://code.garrettmills.dev/extollo/util
|
||||
type: git
|
||||
version: 0.3.2
|
||||
specifiers:
|
||||
'@extollo/di': git+https://code.garrettmills.dev/extollo/di
|
||||
'@extollo/util': git+https://code.garrettmills.dev/extollo/util
|
||||
'@extollo/di': ^0.4.5
|
||||
'@extollo/util': ^0.3.3
|
||||
'@types/busboy': ^0.2.3
|
||||
'@types/negotiator': ^0.6.1
|
||||
'@types/node': ^14.14.37
|
||||
|
||||
@@ -30,8 +30,51 @@ export class ParseIncomingBodyHTTPModule extends HTTPKernelModule {
|
||||
protected readonly logging!: Logging
|
||||
|
||||
public async apply(request: Request): Promise<Request> {
|
||||
if ( !request.getHeader('content-type') ) return request
|
||||
const contentType = request.getHeader('content-type')
|
||||
const contentTypes = (Array.isArray(contentType) ? contentType : [contentType])
|
||||
.filter(Boolean).map(x => x!.toLowerCase())
|
||||
if ( !contentType ) return request
|
||||
|
||||
if (
|
||||
contentTypes.includes('multipart/form-data')
|
||||
|| contentTypes.includes('application/x-www-form-urlencoded')
|
||||
) {
|
||||
return this.applyBusboy(request)
|
||||
}
|
||||
|
||||
if ( contentTypes.includes('application/json') ) {
|
||||
return this.applyJSON(request)
|
||||
}
|
||||
|
||||
return request
|
||||
}
|
||||
|
||||
public async applyJSON(request: Request): Promise<Request> {
|
||||
await new Promise<void>((res, rej) => {
|
||||
let data = ''
|
||||
|
||||
request.toNative().on('data', chunk => {
|
||||
data += chunk
|
||||
})
|
||||
|
||||
request.toNative().on('end', () => {
|
||||
try {
|
||||
const body = JSON.parse(data)
|
||||
for ( const key in body ) {
|
||||
if ( !body.hasOwnProperty(key) ) continue
|
||||
request.parsedInput[key] = body[key]
|
||||
}
|
||||
res()
|
||||
} catch (e) {
|
||||
rej(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return request
|
||||
}
|
||||
|
||||
public async applyBusboy(request: Request): Promise<Request> {
|
||||
const config = this.config.get('server.uploads', {})
|
||||
|
||||
await new Promise<void>((res, rej) => {
|
||||
|
||||
Reference in New Issue
Block a user