From 1457cfcf56b37e2b7327fe7800d9159b6a36ee50 Mon Sep 17 00:00:00 2001 From: Niko Date: Wed, 16 Feb 2022 18:56:03 +0100 Subject: [PATCH] Refactor api.url to api.v1 (for later API changes, maybe) --- api/src/api-utils.js | 2 +- api/src/api.js | 2 +- api/src/server.js | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/src/api-utils.js b/api/src/api-utils.js index 803b9a2..5f4a7a5 100644 --- a/api/src/api-utils.js +++ b/api/src/api-utils.js @@ -1,7 +1,7 @@ const crypto = require('crypto') module.exports = { - url: (path) => { return '/api/v1' + path }, + v1url: (path) => { return '/api/v1' + path }, isURLValid: (url) => { try { const u = new URL(url) diff --git a/api/src/api.js b/api/src/api.js index d63ede6..0d4ac94 100644 --- a/api/src/api.js +++ b/api/src/api.js @@ -1,5 +1,5 @@ module.exports = { - url: require('./api-utils.js').url, + v1: require('./api-utils.js').v1url, auth: require('./api/auth.js'), feed: require('./api/feed.js'), accounts: require('./api/accounts.js'), diff --git a/api/src/server.js b/api/src/server.js index 133c67c..935ea78 100644 --- a/api/src/server.js +++ b/api/src/server.js @@ -64,12 +64,12 @@ app.on('apex-outbox', activity.federation.outbox) app.on('apex-inbox', activity.federation.inbox) // API defines -/* POST */ app.route(api.url('/auth/register')).post(api.auth.register.post) -/* POST */ app.route(api.url('/auth/login')).post(api.auth.login.post) -/* GET */ app.route(api.url('/feed/meet')).get(api.feed.meet.get) -/* GET */ app.route(api.url('/me/pending_follows')).get(api.me.pending_follows.get) -/* POST */ app.route(api.url('/accounts/follow')).post(api.accounts.follow.post) -/* POST */ app.route(api.url('/accounts/unfollow')).post(api.accounts.unfollow.post) +/* POST */ app.route(api.v1('/auth/register')).post(api.auth.register.post) +/* POST */ app.route(api.v1('/auth/login')).post(api.auth.login.post) +/* GET */ app.route(api.v1('/feed/meet')).get(api.feed.meet.get) +/* GET */ app.route(api.v1('/me/pending_follows')).get(api.me.pending_follows.get) +/* POST */ app.route(api.v1('/accounts/follow')).post(api.accounts.follow.post) +/* POST */ app.route(api.v1('/accounts/unfollow')).post(api.accounts.unfollow.post) // initialize client.connect({ useNewUrlParser: true })