[API] Remove fastify
This commit is contained in:
parent
2548c200ed
commit
4dce582b64
20 changed files with 0 additions and 5746 deletions
62
api/.gitignore
vendored
62
api/.gitignore
vendored
|
@ -1,62 +0,0 @@
|
||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
|
|
||||||
# nyc test coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directories
|
|
||||||
node_modules
|
|
||||||
jspm_packages
|
|
||||||
|
|
||||||
# Optional npm cache directory
|
|
||||||
.npm
|
|
||||||
|
|
||||||
# Optional REPL history
|
|
||||||
.node_repl_history
|
|
||||||
|
|
||||||
# 0x
|
|
||||||
profile-*
|
|
||||||
|
|
||||||
# mac files
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# vim swap files
|
|
||||||
*.swp
|
|
||||||
|
|
||||||
# webstorm
|
|
||||||
.idea
|
|
||||||
|
|
||||||
# vscode
|
|
||||||
.vscode
|
|
||||||
*code-workspace
|
|
||||||
|
|
||||||
# clinic
|
|
||||||
profile*
|
|
||||||
*clinic*
|
|
||||||
*flamegraph*
|
|
||||||
|
|
||||||
# generated code
|
|
||||||
examples/typescript-server.js
|
|
||||||
test/types/index.js
|
|
|
@ -1,2 +0,0 @@
|
||||||
# kafka-ui
|
|
||||||
UI for Apache Kafka management
|
|
35
api/app.js
35
api/app.js
|
@ -1,35 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const AutoLoad = require('fastify-autoload');
|
|
||||||
const CORS = require('fastify-cors');
|
|
||||||
|
|
||||||
module.exports = function (fastify, opts, next) {
|
|
||||||
fastify.register(CORS, {
|
|
||||||
origin: 'http://localhost:3000',
|
|
||||||
preflight: true,
|
|
||||||
preflightContinue: true,
|
|
||||||
credentials: true,
|
|
||||||
methods: ['GET', 'PUT', 'PATCH', 'POST', 'DELETE'],
|
|
||||||
})
|
|
||||||
|
|
||||||
// Do not touch the following lines
|
|
||||||
|
|
||||||
// This loads all plugins defined in plugins
|
|
||||||
// those should be support plugins that are reused
|
|
||||||
// through your application
|
|
||||||
fastify.register(AutoLoad, {
|
|
||||||
dir: path.join(__dirname, 'plugins'),
|
|
||||||
options: Object.assign({}, opts)
|
|
||||||
})
|
|
||||||
|
|
||||||
// This loads all plugins defined in services
|
|
||||||
// define your routes in one of these
|
|
||||||
fastify.register(AutoLoad, {
|
|
||||||
dir: path.join(__dirname, 'services'),
|
|
||||||
options: Object.assign({}, opts)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Make sure to call next when done
|
|
||||||
next()
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
const randomBrokerMetrics = () => ({
|
|
||||||
bytesInPerSec: Math.ceil(Math.random() * 10000),
|
|
||||||
|
|
||||||
brokerCount: 1,
|
|
||||||
zooKeeperStatus: 1,
|
|
||||||
activeControllers: 1,
|
|
||||||
uncleanLeaderElectionCount: 0,
|
|
||||||
networkPoolUsage: Math.random() * 0.01,
|
|
||||||
requestPoolUsage: Math.random() * 0.01,
|
|
||||||
onlinePartitionCount: Math.ceil(Math.random() * 100),
|
|
||||||
underReplicatedPartitionCount: Math.ceil(Math.random() * 10),
|
|
||||||
offlinePartitionCount: Math.ceil(Math.random() * 10),
|
|
||||||
diskUsage: [
|
|
||||||
{
|
|
||||||
brokerId: 1,
|
|
||||||
segmentSize: Math.ceil(Math.random() * 1_000_000_000),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
diskUsageDistribution: 'even',
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
'wrYGf-csNgiGdK7B_ADF7Z': randomBrokerMetrics(),
|
|
||||||
'dMMQx-WRh77BKYas_g2ZTz': randomBrokerMetrics(),
|
|
||||||
};
|
|
|
@ -1,21 +0,0 @@
|
||||||
const randomBroker = () => ({
|
|
||||||
bytesInPerSec: Math.ceil(Math.random() * 10_000),
|
|
||||||
bytesOutPerSec: Math.ceil(Math.random() * 10_000),
|
|
||||||
segmentSize: Math.ceil(Math.random() * 1_000_000_000),
|
|
||||||
partitionReplicas: 134,
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
'wrYGf-csNgiGdK7B_ADF7Z': [
|
|
||||||
{
|
|
||||||
brokerId: 1,
|
|
||||||
...randomBroker(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'dMMQx-WRh77BKYas_g2ZTz': [
|
|
||||||
{
|
|
||||||
brokerId: 2,
|
|
||||||
...randomBroker(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
|
@ -1,132 +0,0 @@
|
||||||
module.exports = [
|
|
||||||
{
|
|
||||||
name: 'compression.type',
|
|
||||||
value: 'producer',
|
|
||||||
defaultValue: 'producer',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'leader.replication.throttled.replicas',
|
|
||||||
value: '',
|
|
||||||
defaultValue: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'message.downconversion.enable',
|
|
||||||
value: 'false',
|
|
||||||
defaultValue: 'true',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'min.insync.replicas',
|
|
||||||
value: '1',
|
|
||||||
defaultValue: '1',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'segment.jitter.ms',
|
|
||||||
value: '0',
|
|
||||||
defaultValue: '0',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'cleanup.policy',
|
|
||||||
value: 'compact',
|
|
||||||
defaultValue: 'delete',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'flush.ms',
|
|
||||||
value: '9223372036854775807',
|
|
||||||
defaultValue: '9223372036854775807',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'follower.replication.throttled.replicas',
|
|
||||||
value: '',
|
|
||||||
defaultValue: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'segment.bytes',
|
|
||||||
value: '1073741824',
|
|
||||||
defaultValue: '1073741824',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'retention.ms',
|
|
||||||
value: '43200000',
|
|
||||||
defaultValue: '43200000',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'flush.messages',
|
|
||||||
value: '9223372036854775807',
|
|
||||||
defaultValue: '9223372036854775807',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'message.format.version',
|
|
||||||
value: '2.3-IV1',
|
|
||||||
defaultValue: '2.3-IV1',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'file.delete.delay.ms',
|
|
||||||
value: '60000',
|
|
||||||
defaultValue: '60000',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'max.compaction.lag.ms',
|
|
||||||
value: '9223372036854775807',
|
|
||||||
defaultValue: '9223372036854775807',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'max.message.bytes',
|
|
||||||
value: '1000012',
|
|
||||||
defaultValue: '1000012',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'min.compaction.lag.ms',
|
|
||||||
value: '0',
|
|
||||||
defaultValue: '0',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'message.timestamp.type',
|
|
||||||
value: 'CreateTime',
|
|
||||||
defaultValue: 'CreateTime',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'preallocate',
|
|
||||||
value: 'false',
|
|
||||||
defaultValue: 'false',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'min.cleanable.dirty.ratio',
|
|
||||||
value: '0.5',
|
|
||||||
defaultValue: '0.5',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'index.interval.bytes',
|
|
||||||
value: '4096',
|
|
||||||
defaultValue: '4096',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'unclean.leader.election.enable',
|
|
||||||
value: 'true',
|
|
||||||
defaultValue: 'true',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'retention.bytes',
|
|
||||||
value: '-1',
|
|
||||||
defaultValue: '-1',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'delete.retention.ms',
|
|
||||||
value: '86400000',
|
|
||||||
defaultValue: '86400000',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'segment.ms',
|
|
||||||
value: '604800000',
|
|
||||||
defaultValue: '604800000',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'message.timestamp.difference.max.ms',
|
|
||||||
value: '9223372036854775807',
|
|
||||||
defaultValue: '9223372036854775807',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'segment.index.bytes',
|
|
||||||
value: '10485760',
|
|
||||||
defaultValue: '10485760',
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -1,10 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
partitionCount: 25,
|
|
||||||
replicationFactor: 1,
|
|
||||||
replicas: 25,
|
|
||||||
inSyncReplicas: 25,
|
|
||||||
bytesInPerSec: 0,
|
|
||||||
segmentSize: 0,
|
|
||||||
segmentCount: 25,
|
|
||||||
underReplicatedPartitions: 0
|
|
||||||
};
|
|
|
@ -1,224 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
'wrYGf-csNgiGdK7B_ADF7Z': [
|
|
||||||
{
|
|
||||||
name: 'docker-connect-status',
|
|
||||||
internal: true,
|
|
||||||
partitions: [
|
|
||||||
{
|
|
||||||
partition: 0,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: false,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
partition: 1,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
partition: 2,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
partition: 3,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
partition: 4,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'dsadsda',
|
|
||||||
internal: false,
|
|
||||||
partitions: [
|
|
||||||
{
|
|
||||||
partition: 0,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'my-topic',
|
|
||||||
internal: false,
|
|
||||||
partitions: [
|
|
||||||
{
|
|
||||||
partition: 0,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'docker-connect-offsets',
|
|
||||||
internal: false,
|
|
||||||
partitions: [
|
|
||||||
{
|
|
||||||
partition: 0,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
partition: 1,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
partition: 2,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
partition: 3,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
partition: 4,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
partition: 5,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'dMMQx-WRh77BKYas_g2ZTz': [
|
|
||||||
{
|
|
||||||
name: '_schemas',
|
|
||||||
internal: false,
|
|
||||||
partitions: [
|
|
||||||
{
|
|
||||||
partition: 0,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'docker-connect-configs',
|
|
||||||
internal: false,
|
|
||||||
partitions: [
|
|
||||||
{
|
|
||||||
partition: 0,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '_kafka-ui-test-topic-monitoring-message-rekey-store',
|
|
||||||
internal: false,
|
|
||||||
partitions: [
|
|
||||||
{
|
|
||||||
partition: 0,
|
|
||||||
leader: 1,
|
|
||||||
replicas: [
|
|
||||||
{
|
|
||||||
broker: 1,
|
|
||||||
leader: true,
|
|
||||||
inSync: true,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
4963
api/package-lock.json
generated
4963
api/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,27 +0,0 @@
|
||||||
{
|
|
||||||
"name": "api",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "app.js",
|
|
||||||
"directories": {
|
|
||||||
"test": "test"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "tap test/**/*.test.js",
|
|
||||||
"start": "fastify start --log-level info app.js",
|
|
||||||
"dev": "fastify start --log-level info --pretty-logs --watch --port 3004 app.js"
|
|
||||||
},
|
|
||||||
"keywords": [],
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"fastify": "^2.0.0",
|
|
||||||
"fastify-autoload": "^1.0.0",
|
|
||||||
"fastify-cli": "^1.3.0",
|
|
||||||
"fastify-cors": "^3.0.0",
|
|
||||||
"fastify-plugin": "^1.5.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"tap": "^12.5.3"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
# Plugins Folder
|
|
||||||
|
|
||||||
Plugins define behavior that is common to all the routes in your
|
|
||||||
application. Authentication, caching, templates, and all the other cross
|
|
||||||
cutting concerns should be handled by plugins placed in this folder.
|
|
||||||
|
|
||||||
Files in this folder are typically defined through the
|
|
||||||
[`fastify-plugin`](https://github.com/fastify/fastify-plugin) module,
|
|
||||||
making them non-encapsulated. They can define decorators and set hooks
|
|
||||||
that will then be used in the rest of your application.
|
|
||||||
|
|
||||||
Check out:
|
|
||||||
|
|
||||||
* [The hitchhiker's guide to plugins](https://github.com/fastify/fastify/blob/master/docs/Plugins-Guide.md)
|
|
||||||
* [Fastify decorators](https://www.fastify.io/docs/latest/Decorators/).
|
|
||||||
* [Fastify lifecycle](https://www.fastify.io/docs/latest/Lifecycle/).
|
|
|
@ -1,21 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const fp = require('fastify-plugin')
|
|
||||||
|
|
||||||
// the use of fastify-plugin is required to be able
|
|
||||||
// to export the decorators to the outer scope
|
|
||||||
|
|
||||||
module.exports = fp(function (fastify, opts, next) {
|
|
||||||
fastify.decorate('someSupport', function () {
|
|
||||||
return 'hugs'
|
|
||||||
})
|
|
||||||
next()
|
|
||||||
})
|
|
||||||
|
|
||||||
// If you prefer async/await, use the following
|
|
||||||
//
|
|
||||||
// module.exports = fp(async function (fastify, opts) {
|
|
||||||
// fastify.decorate('someSupport', function () {
|
|
||||||
// return 'hugs'
|
|
||||||
// })
|
|
||||||
// })
|
|
|
@ -1,16 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const brokers = require('../mocks/brokers');
|
|
||||||
const brokerMetrics = require('../mocks/brokerMetrics');
|
|
||||||
|
|
||||||
module.exports = function (fastify, opts, next) {
|
|
||||||
fastify
|
|
||||||
.get('/clusters/:clusterId/brokers', function (request, reply) {
|
|
||||||
reply.send(brokers[request.params.clusterId]);
|
|
||||||
})
|
|
||||||
.get('/clusters/:clusterId/metrics/broker', function (request, reply) {
|
|
||||||
reply.send(brokerMetrics[request.params.clusterId]);
|
|
||||||
});
|
|
||||||
|
|
||||||
next();
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = function (fastify, opts, next) {
|
|
||||||
fastify.get('/clusters', function (request, reply) {
|
|
||||||
reply.send([
|
|
||||||
{
|
|
||||||
id: 'wrYGf-csNgiGdK7B_ADF7Z',
|
|
||||||
name: 'fake.cluster',
|
|
||||||
defaultCluster: true,
|
|
||||||
status: 'online',
|
|
||||||
brokerCount: 1,
|
|
||||||
onlinePartitionCount: 20,
|
|
||||||
topicCount: 2,
|
|
||||||
bytesInPerSec: Math.ceil(Math.random() * 10_000),
|
|
||||||
bytesOutPerSec: Math.ceil(Math.random() * 10_000),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'dMMQx-WRh77BKYas_g2ZTz',
|
|
||||||
name: 'kafka-ui.cluster',
|
|
||||||
default: false,
|
|
||||||
status: 'offline',
|
|
||||||
brokerCount: 0,
|
|
||||||
onlinePartitionCount: 0,
|
|
||||||
topicCount: 0,
|
|
||||||
bytesInPerSec: Math.ceil(Math.random() * 10_000),
|
|
||||||
bytesOutPerSec: Math.ceil(Math.random() * 10_000),
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
next();
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = function (fastify, opts, next) {
|
|
||||||
fastify.get('/', function (request, reply) {
|
|
||||||
reply.send({ root: true });
|
|
||||||
});
|
|
||||||
|
|
||||||
next();
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const topics = require('../mocks/topics');
|
|
||||||
const topicDetails = require('../mocks/topicDetails');
|
|
||||||
const topicConfig = require('../mocks/topicConfig');
|
|
||||||
|
|
||||||
module.exports = function (fastify, opts, next) {
|
|
||||||
fastify
|
|
||||||
.get('/clusters/:clusterId/topics', function (request, reply) {
|
|
||||||
reply.send(topics[request.params.clusterId]);
|
|
||||||
})
|
|
||||||
.get('/clusters/:clusterId/topics/:topicId', function (request, reply) {
|
|
||||||
reply.send(topicDetails);
|
|
||||||
})
|
|
||||||
.get('/clusters/:clusterId/topics/:topicId/config', function (request, reply) {
|
|
||||||
reply.send(topicConfig);
|
|
||||||
})
|
|
||||||
.post('/clusters/:clusterId/topics', function (request, reply) {
|
|
||||||
/* Payload
|
|
||||||
{
|
|
||||||
"name":"AlphaNumeric-String_with,and.",
|
|
||||||
"partitions":"1",
|
|
||||||
"replicationFactor":"1",
|
|
||||||
"configs": {
|
|
||||||
"retention.ms": "604800000",
|
|
||||||
"retention.bytes": "-1",
|
|
||||||
"max.message.bytes":"1000012",
|
|
||||||
"min.insync.replicas":"1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
reply.code(201).send();
|
|
||||||
});
|
|
||||||
|
|
||||||
next();
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
// This file contains code that we reuse
|
|
||||||
// between our tests.
|
|
||||||
|
|
||||||
const Fastify = require('fastify')
|
|
||||||
const fp = require('fastify-plugin')
|
|
||||||
const App = require('../app')
|
|
||||||
|
|
||||||
// Fill in this config with all the configurations
|
|
||||||
// needed for testing the application
|
|
||||||
function config () {
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// automatically build and tear down our instance
|
|
||||||
function build (t) {
|
|
||||||
const app = Fastify()
|
|
||||||
|
|
||||||
// fastify-plugin ensures that all decorators
|
|
||||||
// are exposed for testing purposes, this is
|
|
||||||
// different from the production setup
|
|
||||||
app.register(fp(App), config())
|
|
||||||
|
|
||||||
// tear down our app after we are done
|
|
||||||
t.tearDown(app.close.bind(app))
|
|
||||||
|
|
||||||
return app
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
config,
|
|
||||||
build
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const { test } = require('tap')
|
|
||||||
const Fastify = require('fastify')
|
|
||||||
const Support = require('../../plugins/support')
|
|
||||||
|
|
||||||
test('support works standalone', (t) => {
|
|
||||||
t.plan(2)
|
|
||||||
const fastify = Fastify()
|
|
||||||
fastify.register(Support)
|
|
||||||
|
|
||||||
fastify.ready((err) => {
|
|
||||||
t.error(err)
|
|
||||||
t.equal(fastify.someSupport(), 'hugs')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// If you prefer async/await, use the following
|
|
||||||
//
|
|
||||||
// test('support works standalone', async (t) => {
|
|
||||||
// const fastify = Fastify()
|
|
||||||
// fastify.register(Support)
|
|
||||||
//
|
|
||||||
// await fastify.ready()
|
|
||||||
// t.equal(fastify.someSupport(), 'hugs')
|
|
||||||
// })
|
|
|
@ -1,27 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const { test } = require('tap')
|
|
||||||
const { build } = require('../helper')
|
|
||||||
|
|
||||||
test('example is loaded', (t) => {
|
|
||||||
t.plan(2)
|
|
||||||
const app = build(t)
|
|
||||||
|
|
||||||
app.inject({
|
|
||||||
url: '/example'
|
|
||||||
}, (err, res) => {
|
|
||||||
t.error(err)
|
|
||||||
t.equal(res.payload, 'this is an example')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// If you prefer async/await, use the following
|
|
||||||
//
|
|
||||||
// test('example is loaded', async (t) => {
|
|
||||||
// const app = build(t)
|
|
||||||
//
|
|
||||||
// const res = await app.inject({
|
|
||||||
// url: '/example'
|
|
||||||
// })
|
|
||||||
// t.equal(res.payload, 'this is an example')
|
|
||||||
// })
|
|
|
@ -1,27 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const { test } = require('tap')
|
|
||||||
const { build } = require('../helper')
|
|
||||||
|
|
||||||
test('default root route', (t) => {
|
|
||||||
t.plan(2)
|
|
||||||
const app = build(t)
|
|
||||||
|
|
||||||
app.inject({
|
|
||||||
url: '/'
|
|
||||||
}, (err, res) => {
|
|
||||||
t.error(err)
|
|
||||||
t.deepEqual(JSON.parse(res.payload), { root: true })
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// If you prefer async/await, use the following
|
|
||||||
//
|
|
||||||
// test('default root route', async (t) => {
|
|
||||||
// const app = build(t)
|
|
||||||
//
|
|
||||||
// const res = await app.inject({
|
|
||||||
// url: '/'
|
|
||||||
// })
|
|
||||||
// t.deepEqual(JSON.parse(res.payload), { root: true })
|
|
||||||
// })
|
|
Loading…
Add table
Reference in a new issue