@azteam/express 1.2.231 → 1.2.234
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/package.json +1 -1
- package/src/Server.js +6 -1
- package/src/validate.js +3 -0
package/package.json
CHANGED
package/src/Server.js
CHANGED
|
@@ -258,7 +258,7 @@ class Server {
|
|
|
258
258
|
delete res.cache;
|
|
259
259
|
|
|
260
260
|
req.trackDevice = {
|
|
261
|
-
ip: req.ip,
|
|
261
|
+
ip: req.headers['x-real-ip'] || req.ip,
|
|
262
262
|
device: req.get('X-DEVICE') || req.get('User-Agent'),
|
|
263
263
|
device_id: req.get('X-DEVICE-ID') || 'web',
|
|
264
264
|
os: req.get('X-OS') || 'web',
|
|
@@ -306,6 +306,11 @@ class Server {
|
|
|
306
306
|
app.all('/', async function (req, res) {
|
|
307
307
|
return res.success('welcome');
|
|
308
308
|
});
|
|
309
|
+
app.get('/track', async function (req, res) {
|
|
310
|
+
return res.success({
|
|
311
|
+
...req.trackDevice,
|
|
312
|
+
});
|
|
313
|
+
});
|
|
309
314
|
|
|
310
315
|
app.use(function (req, res) {
|
|
311
316
|
throw new ErrorException(NOT_FOUND);
|
package/src/validate.js
CHANGED
|
@@ -44,6 +44,8 @@ export const schemaInteger = (min = 0, max = 999999999, optional = false) => ({
|
|
|
44
44
|
|
|
45
45
|
export const schemaString = (min = 1, max = 255, optional = false) => ({
|
|
46
46
|
type: 'string',
|
|
47
|
+
convert: true,
|
|
48
|
+
trim: true,
|
|
47
49
|
min,
|
|
48
50
|
max,
|
|
49
51
|
optional,
|
|
@@ -85,6 +87,7 @@ export const schemaPhoneNumber = (optional = false) => ({
|
|
|
85
87
|
export const schemaSlug = (optional = false) => ({
|
|
86
88
|
type: 'string',
|
|
87
89
|
pattern: /[A-Za-z0-9_-]+/,
|
|
90
|
+
lowercase: true,
|
|
88
91
|
max: 300,
|
|
89
92
|
optional,
|
|
90
93
|
});
|