
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@kasko/fe-mock-api-lib
Advanced tools
KASKO platform API request mocking made easy.
yarn add -D @kasko/fe-mock-api-lib
+ const mockApi = require('@kasko/fe-mock-api-lib');
module.exports = {
mode: 'development',
devServer: {
open: true,
port: 3000,
+ before(app) {
+ mockApi(app, path.resolve('./mock-api/api.js'));
+ },
+
+ // Optional: reload page after changes are made
+ contentBase: [
+ path.resolve('./src'),
+ path.resolve('./mock-api'),
+ ],
+ watchContentBase: true,
},
};
mock-api
folder:mock-api/api.js
const path = require('path');
const mockApi = require('@kasko/fe-mock-api-lib');
const item = require('./resources/item.json');
const itemContents = mockApi.parseCsvFile(path.resolve(__dirname, './resources/item-contents.csv'));
const itemFieldDefinitions = require('./resources/item-field-definitions.json');
const itemManifest = require('./resources/item-webapp-manifest.json');
module.exports = mockApi.constructRoutes({
'GET /touchpoints/:touchpoint/items/:item': async (req, res) => {
item.content.data = await itemContents;
item.webapp_manifest = itemManifest;
item.field_definition = itemFieldDefinitions;
return res.json(item);
},
});
mock-api/resources/item-contents.csv
"hello.world","Hello!"
mock-api/resources/item-field-definitions.json
{
"policy": [
{
"name": "salutation",
"validation": "required|string|in:mr,ms"
}
],
"quote": [
{
"name": "duration",
"validation": "required|string|in:P1Y,P2Y,P3Y"
}
]
}
mock-api/resources/item-webapp-manifest.json
{
"version": "1.0",
"schema": {
"config": {
"initial_screen": "start",
"default_values": {
"duration": "P1Y"
},
"requests": [
{
"type": "quote"
},
{
"type": "policy"
},
{
"type": "payment"
}
],
"content_key": {
"insurer_name": "insurer_name"
}
},
"flow": [
// ...
]
}
}
mock-api/resources/item.json
{
"id": "id_hash",
"object": "item",
"currency": "eur",
"currency_profile_id": "id_hash",
"field_definition": {},
"config": {
"tax_rate": 0.19
},
"webapp_manifest": {},
"tags": [],
"payment_methods": [
{
"payment_method": "creditcard",
"provider": "stripe",
"keys": {
"public_key": "pk_test_123"
}
}
],
"subscription_plans": [],
"content": {
"id": "id_hash",
"object": "content",
"data": {}
},
"assets": []
}
yarn install
yarn test
yarn lint
FAQs
KASKO platform API request mocking made easy.
The npm package @kasko/fe-mock-api-lib receives a total of 1 weekly downloads. As such, @kasko/fe-mock-api-lib popularity was classified as not popular.
We found that @kasko/fe-mock-api-lib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 18 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.