add more endpoint superclasses
This commit is contained in:
parent
df2d7a7ed5
commit
0f71c25cdb
17
src/server/interfaces/ApiEndpoint.js
Normal file
17
src/server/interfaces/ApiEndpoint.js
Normal file
@ -0,0 +1,17 @@
|
||||
const Endpoint = require('./Endpoint');
|
||||
|
||||
class ApiEndpoint extends Endpoint {
|
||||
|
||||
constructor (server, opts) {
|
||||
|
||||
if (!opts.path.startsWith('/')) opts.path = `/${opts.path}`;
|
||||
super(server, {
|
||||
...opts,
|
||||
path: `/api${opts.path}`
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ApiEndpoint;
|
18
src/server/interfaces/VersionedEndpoint.js
Normal file
18
src/server/interfaces/VersionedEndpoint.js
Normal file
@ -0,0 +1,18 @@
|
||||
const ApiEndpoint = require("./ApiEndpoint");
|
||||
|
||||
class VersionedEndpoint extends ApiEndpoint {
|
||||
|
||||
constructor (server, opts) {
|
||||
|
||||
if (typeof opts.version !== 'number') throw new Error('Missing endpoint version');
|
||||
if (!opts.path.startsWith('/')) opts.path = `/${opts.path}`;
|
||||
|
||||
super(server, {
|
||||
...opts,
|
||||
path: `/v${opts.version}${opts.path}`
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = VersionedEndpoint;
|
@ -1,4 +1,6 @@
|
||||
module.exports = {
|
||||
Endpoint: require('./Endpoint'),
|
||||
AbstractUserDatabase: require('./AbstractUserDatabase')
|
||||
AbstractUserDatabase: require('./AbstractUserDatabase'),
|
||||
VersionedEndpoint: require('./VersionedEndpoint'),
|
||||
ApiEndpoint: require('./ApiEndpoint'),
|
||||
};
|
Loading…
Reference in New Issue
Block a user