tipi-services
Version:
Node.js library to access wrapping REST API of tipi backend services
62 lines (48 loc) • 1.01 kB
JavaScript
const HttpMethod = require('../enums/HttpMethod')
class Endpoint {
constructor (base) {
this.setBase(base)
}
static base (base) {
return new Endpoint(base)
}
get (path) {
this.method = HttpMethod.get
return this.setPath(path)
}
post (path) {
this.method = HttpMethod.post
return this.setPath(path)
}
patch (path) {
this.method = HttpMethod.patch
return this.setPath(path)
}
put (path) {
this.method = HttpMethod.put
return this.setPath(path)
}
delete (path) {
this.method = HttpMethod.delete
return this.setPath(path)
}
setPath (path) {
this.path = path
return this
}
setBase (base) {
this.baseUrl = base
return this
}
setSchema (schema) {
this.schema = schema
return this
}
get uri () {
return `${this.baseUrl}${this.path}`
}
get interactionPath () {
return `/v1${this.path}`
}
}
module.exports = Endpoint