Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
5398260fbd | |
|
|
74d29859f3 |
17
beau.yml
17
beau.yml
|
|
@ -1,12 +1,23 @@
|
|||
endpoint: https://webhook.site/
|
||||
endpoint: https://httpbin.org/
|
||||
|
||||
plugins:
|
||||
- std:
|
||||
date:
|
||||
format: 'YYYY-MM-DD'
|
||||
|
||||
POST /8806bba7-d947-47bf-9445-cccc73e92bb8:
|
||||
alias: test
|
||||
POST /anything:
|
||||
alias: date
|
||||
payload:
|
||||
today: $[now(`YYYY`)]
|
||||
someDay: $[date(2018, 5, 17)]
|
||||
|
||||
POST /anything?1:
|
||||
alias: uuid
|
||||
payload:
|
||||
uuid: $[uuid()]
|
||||
|
||||
POST /anything?2:
|
||||
alias: upload
|
||||
formdata:
|
||||
file: $[createReadStream('./LICENSE')]
|
||||
|
||||
|
|
|
|||
15
lib/index.js
15
lib/index.js
|
|
@ -1,13 +1,14 @@
|
|||
const date = require('./plugins/date');
|
||||
const fileSystem = require('./plugins/fileSystem.js');
|
||||
const fileSystem = require('./plugins/fileSystem');
|
||||
const uuid = require('./plugins/uuid');
|
||||
|
||||
class STD {
|
||||
constructor(
|
||||
registry,
|
||||
settings = { date: { format: 'YYYY-MM-DDTHH:mm:ss.SSSZ' } }
|
||||
) {
|
||||
[date, fileSystem].forEach(plugin => plugin(registry, settings));
|
||||
}
|
||||
constructor(registry, settings) {
|
||||
const defaults = { date: { format: 'YYYY-MM-DDTHH:mm:ss.SSSZ' } };
|
||||
settings = Object.assign({}, defaults, settings);
|
||||
|
||||
[date, fileSystem, uuid].forEach(plugin => plugin(registry, settings));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = STD;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
const format = require('date-fns/format');
|
||||
|
||||
module.exports = (registry, settings) => {
|
||||
registry.defineDynamicValue('now', (fmt = settings.date.format) =>
|
||||
format(Date.now(), fmt)
|
||||
);
|
||||
registry.defineDynamicValue('now', (fmt = settings.date.format) =>
|
||||
format(Date.now(), fmt)
|
||||
);
|
||||
|
||||
registry.defineDynamicValue(
|
||||
'date',
|
||||
(year, month, day, fmt = settings.date.format) =>
|
||||
format(new Date(year, month - 1, day), fmt)
|
||||
);
|
||||
registry.defineDynamicValue(
|
||||
'date',
|
||||
(year, month, day, fmt = settings.date.format) =>
|
||||
format(new Date(year, month - 1, day), fmt)
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
const uuid = require('uuid/v4');
|
||||
|
||||
module.exports = registry => registry.defineDynamicValue('uuid', uuid);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "beau-std",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
@ -8,6 +8,11 @@
|
|||
"version": "1.29.0",
|
||||
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.29.0.tgz",
|
||||
"integrity": "sha512-lbTXWZ6M20cWH8N9S6afb0SBm6tMk+uUg6z3MqHPKE9atmsY3kJkTm8vKe93izJ2B2+q5MV990sM2CHgtAZaOw=="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz",
|
||||
"integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "beau-std",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.4",
|
||||
"description": "General purpose Beau plugins.",
|
||||
"main": "./lib/index.js",
|
||||
"scripts": {},
|
||||
|
|
@ -18,7 +18,8 @@
|
|||
},
|
||||
"homepage": "https://github.com/seich/beau-std#readme",
|
||||
"dependencies": {
|
||||
"date-fns": "^1.29.0"
|
||||
"date-fns": "^1.29.0",
|
||||
"uuid": "^3.2.1"
|
||||
},
|
||||
"devDependencies": {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue