gg-express 1.0.44 → 1.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +13 -0
- package/package.json +8 -3
- package/readme.md +1 -1
- package/src/parseQueryJSON.ts +0 -33
package/.gitlab-ci.yml
ADDED
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gg-express",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.51",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/GGExpress.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "npm version patch
|
|
7
|
+
"build": "tsc && npm version patch --no-git-tag-version",
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
9
|
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://gitlab.com/tin.sittiyot/gg-express.git"
|
|
13
|
+
},
|
|
10
14
|
"author": "goomgum",
|
|
11
15
|
"license": "ISC",
|
|
12
16
|
"dependencies": {
|
|
@@ -19,7 +23,8 @@
|
|
|
19
23
|
"path": "^0.12.7"
|
|
20
24
|
},
|
|
21
25
|
"devDependencies": {
|
|
22
|
-
"@types/express": "^5.0.0"
|
|
26
|
+
"@types/express": "^5.0.0",
|
|
27
|
+
"typescript": "^5.6.3"
|
|
23
28
|
},
|
|
24
29
|
"keywords": [
|
|
25
30
|
"express",
|
package/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🚀 GG-Express
|
|
2
2
|
|
|
3
|
-
**GG-Express** is an Express.js wrapper that enforces strong type requirements for `GET`, `POST`, `PUT`, and `DELETE` methods. It ensures that `req.query` and `req.body` follow strict structure definitions and automatically generates an `apiConnector` class file for easy use in front-end development.
|
|
3
|
+
**GG-Express** is an Express.js wrapper that enforces strong type requirements for `GET`, `POST`, `PUT`, and `DELETE` methods. It ensures that `req.query` and `req.body` follow strict structure definitions and automatically generates an `apiConnector` class file for easy use in front-end development. 🎉🎉🎉
|
|
4
4
|
|
|
5
5
|
## ✨ Features
|
|
6
6
|
|
package/src/parseQueryJSON.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from "express"
|
|
2
|
-
|
|
3
|
-
export function parseQueryJSON(
|
|
4
|
-
req: Request,
|
|
5
|
-
res: Response,
|
|
6
|
-
next: NextFunction
|
|
7
|
-
) {
|
|
8
|
-
// Check if there's any query parameter to parse
|
|
9
|
-
if (req.query) {
|
|
10
|
-
for (const key in req.query) {
|
|
11
|
-
if (Array.isArray(req.query[key])) {
|
|
12
|
-
// If the query param is an array of stringified JSON, parse each item
|
|
13
|
-
req.query[key] = req.query[key].map((item) => {
|
|
14
|
-
try {
|
|
15
|
-
return JSON.parse(item as any)
|
|
16
|
-
} catch (err) {
|
|
17
|
-
console.error(`Failed to parse query parameter: ${item}`)
|
|
18
|
-
return item // Return the original if parsing fails
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
} else if (typeof req.query[key] === "string") {
|
|
22
|
-
// If the query param is a stringified JSON, attempt to parse it
|
|
23
|
-
try {
|
|
24
|
-
req.query[key] = JSON.parse(req.query[key])
|
|
25
|
-
} catch (err) {
|
|
26
|
-
console.error(`Failed to parse query parameter: ${req.query[key]}`)
|
|
27
|
-
// Keep the original string if parsing fails
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
next() // Call next middleware in the stack
|
|
33
|
-
}
|