From d93811d47077d51d41af40214d4c03b1752344d1 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Thu, 8 Feb 2018 08:22:14 -0800 Subject: [PATCH] refactor --- routes/_actions/timeline.js | 4 ++-- routes/{_utils/mastodon => _api}/StatusStream.js | 2 +- routes/{_utils/mastodon => _api}/instance.js | 2 +- routes/{_utils/mastodon => _api}/oauth.js | 2 +- routes/{_utils/mastodon => _api}/search.js | 2 +- routes/{_utils/mastodon => _api}/timelines.js | 2 +- routes/{_utils/mastodon => _api}/user.js | 2 +- routes/{_utils/mastodon => _api}/utils.js | 0 routes/_components/search/Search.html | 2 +- routes/_components/timeline/Timeline.html | 2 +- routes/{_utils/database => _database}/cache.js | 0 routes/{_utils/database => _database}/constants.js | 0 routes/{_utils/database => _database}/database.js | 0 routes/{_utils/database => _database}/databaseCore.js | 0 routes/{_utils/database => _database}/databaseLifecycle.js | 0 routes/{_utils/database => _database}/utils.js | 0 routes/accounts/_actions/[accountId].js | 4 ++-- routes/settings/instances/_actions/[instanceName].js | 4 ++-- routes/settings/instances/_actions/add.js | 6 +++--- server.js | 2 +- 20 files changed, 18 insertions(+), 18 deletions(-) rename routes/{_utils/mastodon => _api}/StatusStream.js (96%) rename routes/{_utils/mastodon => _api}/instance.js (80%) rename routes/{_utils/mastodon => _api}/oauth.js (94%) rename routes/{_utils/mastodon => _api}/search.js (82%) rename routes/{_utils/mastodon => _api}/timelines.js (97%) rename routes/{_utils/mastodon => _api}/user.js (93%) rename routes/{_utils/mastodon => _api}/utils.js (100%) rename routes/{_utils/database => _database}/cache.js (100%) rename routes/{_utils/database => _database}/constants.js (100%) rename routes/{_utils/database => _database}/database.js (100%) rename routes/{_utils/database => _database}/databaseCore.js (100%) rename routes/{_utils/database => _database}/databaseLifecycle.js (100%) rename routes/{_utils/database => _database}/utils.js (100%) diff --git a/routes/_actions/timeline.js b/routes/_actions/timeline.js index 38baea91..79534b4b 100644 --- a/routes/_actions/timeline.js +++ b/routes/_actions/timeline.js @@ -1,6 +1,6 @@ import { store } from '../_store/store' -import { database } from '../_utils/database/database' -import { getTimeline } from '../_utils/mastodon/timelines' +import { database } from '../_database/database' +import { getTimeline } from '../_api/timelines' import { toast } from '../_utils/toast' import { mark, stop } from '../_utils/marks' import { mergeArrays } from '../_utils/arrays' diff --git a/routes/_utils/mastodon/StatusStream.js b/routes/_api/StatusStream.js similarity index 96% rename from routes/_utils/mastodon/StatusStream.js rename to routes/_api/StatusStream.js index 6b4e67cf..8566763d 100644 --- a/routes/_utils/mastodon/StatusStream.js +++ b/routes/_api/StatusStream.js @@ -1,4 +1,4 @@ -import { paramsString } from '../ajax' +import { paramsString } from '../_utils/ajax' import noop from 'lodash/noop' import WebSocketClient from '@gamestdio/websocket' diff --git a/routes/_utils/mastodon/instance.js b/routes/_api/instance.js similarity index 80% rename from routes/_utils/mastodon/instance.js rename to routes/_api/instance.js index b98eba35..793cbd20 100644 --- a/routes/_utils/mastodon/instance.js +++ b/routes/_api/instance.js @@ -1,4 +1,4 @@ -import { get } from '../ajax' +import { get } from '../_utils/ajax' import { basename } from './utils' export function getInstanceInfo(instanceName) { diff --git a/routes/_utils/mastodon/oauth.js b/routes/_api/oauth.js similarity index 94% rename from routes/_utils/mastodon/oauth.js rename to routes/_api/oauth.js index 7f115087..7908f6cb 100644 --- a/routes/_utils/mastodon/oauth.js +++ b/routes/_api/oauth.js @@ -1,7 +1,7 @@ const WEBSITE = 'https://pinafore.social' const SCOPES = 'read write follow' const CLIENT_NAME = 'Pinafore' -import { post, get, paramsString } from '../ajax' +import { post, get, paramsString } from '../_utils/ajax' import { basename } from './utils' export function registerApplication(instanceName, redirectUri) { diff --git a/routes/_utils/mastodon/search.js b/routes/_api/search.js similarity index 82% rename from routes/_utils/mastodon/search.js rename to routes/_api/search.js index 27190995..0fce507f 100644 --- a/routes/_utils/mastodon/search.js +++ b/routes/_api/search.js @@ -1,4 +1,4 @@ -import { get, paramsString } from '../ajax' +import { get, paramsString } from '../_utils/ajax' export function search(instanceName, accessToken, query) { let url = `https://${instanceName}/api/v1/search?` + paramsString({ diff --git a/routes/_utils/mastodon/timelines.js b/routes/_api/timelines.js similarity index 97% rename from routes/_utils/mastodon/timelines.js rename to routes/_api/timelines.js index bb85a571..1f9619d4 100644 --- a/routes/_utils/mastodon/timelines.js +++ b/routes/_api/timelines.js @@ -1,4 +1,4 @@ -import { get, paramsString } from '../ajax' +import { get, paramsString } from '../_utils/ajax' import { basename } from './utils' function getTimelineUrlPath(timeline) { diff --git a/routes/_utils/mastodon/user.js b/routes/_api/user.js similarity index 93% rename from routes/_utils/mastodon/user.js rename to routes/_api/user.js index 1ad334b3..e6aadc26 100644 --- a/routes/_utils/mastodon/user.js +++ b/routes/_api/user.js @@ -1,4 +1,4 @@ -import { get, paramsString } from '../ajax' +import { get, paramsString } from '../_utils/ajax' import { basename } from './utils' export function getVerifyCredentials(instanceName, accessToken) { diff --git a/routes/_utils/mastodon/utils.js b/routes/_api/utils.js similarity index 100% rename from routes/_utils/mastodon/utils.js rename to routes/_api/utils.js diff --git a/routes/_components/search/Search.html b/routes/_components/search/Search.html index 7240f6ec..e1c3c825 100644 --- a/routes/_components/search/Search.html +++ b/routes/_components/search/Search.html @@ -59,7 +59,7 @@ import { store } from '../../_store/store' import LoadingPage from '../LoadingPage.html' import { toast } from '../../_utils/toast' - import { search } from '../../_utils/mastodon/search' + import { search } from '../../_api/search' import SearchResults from './SearchResults.html' export default { diff --git a/routes/_components/timeline/Timeline.html b/routes/_components/timeline/Timeline.html index 45a54be8..7a9c3a22 100644 --- a/routes/_components/timeline/Timeline.html +++ b/routes/_components/timeline/Timeline.html @@ -52,7 +52,7 @@ import LoadingFooter from './LoadingFooter.html' import VirtualList from '../virtualList/VirtualList.html' import { timelines } from '../../_static/timelines' - import { database } from '../../_utils/database/database' + import { database } from '../../_database/database' import { initializeTimeline, fetchTimelineItemsOnScrollToBottom, setupTimeline } from '../../_actions/timeline' import LoadingPage from '../LoadingPage.html' diff --git a/routes/_utils/database/cache.js b/routes/_database/cache.js similarity index 100% rename from routes/_utils/database/cache.js rename to routes/_database/cache.js diff --git a/routes/_utils/database/constants.js b/routes/_database/constants.js similarity index 100% rename from routes/_utils/database/constants.js rename to routes/_database/constants.js diff --git a/routes/_utils/database/database.js b/routes/_database/database.js similarity index 100% rename from routes/_utils/database/database.js rename to routes/_database/database.js diff --git a/routes/_utils/database/databaseCore.js b/routes/_database/databaseCore.js similarity index 100% rename from routes/_utils/database/databaseCore.js rename to routes/_database/databaseCore.js diff --git a/routes/_utils/database/databaseLifecycle.js b/routes/_database/databaseLifecycle.js similarity index 100% rename from routes/_utils/database/databaseLifecycle.js rename to routes/_database/databaseLifecycle.js diff --git a/routes/_utils/database/utils.js b/routes/_database/utils.js similarity index 100% rename from routes/_utils/database/utils.js rename to routes/_database/utils.js diff --git a/routes/accounts/_actions/[accountId].js b/routes/accounts/_actions/[accountId].js index 39769838..054c44de 100644 --- a/routes/accounts/_actions/[accountId].js +++ b/routes/accounts/_actions/[accountId].js @@ -1,5 +1,5 @@ -import { getAccount, getRelationship } from '../../_utils/mastodon/user' -import { database } from '../../_utils/database/database' +import { getAccount, getRelationship } from '../../_api/user' +import { database } from '../../_database/database' import { store } from '../../_store/store' async function updateAccount(accountId, instanceName, accessToken) { diff --git a/routes/settings/instances/_actions/[instanceName].js b/routes/settings/instances/_actions/[instanceName].js index f0fde30e..8f8c6318 100644 --- a/routes/settings/instances/_actions/[instanceName].js +++ b/routes/settings/instances/_actions/[instanceName].js @@ -1,8 +1,8 @@ -import { getVerifyCredentials } from '../../../_utils/mastodon/user' +import { getVerifyCredentials } from '../../../_api/user' import { store } from '../../../_store/store' import { switchToTheme } from '../../../_utils/themeEngine' import { toast } from '../../../_utils/toast' -import { database } from '../../../_utils/database/database' +import { database } from '../../../_database/database' import { goto } from 'sapper/runtime.js' import pAny from 'p-any' diff --git a/routes/settings/instances/_actions/add.js b/routes/settings/instances/_actions/add.js index 8371b150..064db686 100644 --- a/routes/settings/instances/_actions/add.js +++ b/routes/settings/instances/_actions/add.js @@ -1,8 +1,8 @@ -import { getAccessTokenFromAuthCode, registerApplication, generateAuthLink } from '../../../_utils/mastodon/oauth' -import { getInstanceInfo } from '../../../_utils/mastodon/instance' +import { getAccessTokenFromAuthCode, registerApplication, generateAuthLink } from '../../../_api/oauth' +import { getInstanceInfo } from '../../../_api/instance' import { goto } from 'sapper/runtime.js' import { switchToTheme } from '../../../_utils/themeEngine' -import { database } from '../../../_utils/database/database' +import { database } from '../../../_database/database' import { store } from '../../../_store/store' import { updateVerifyCredentialsForInstance } from './[instanceName]' diff --git a/server.js b/server.js index 418d80f3..bbe5da7b 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,7 @@ const static = require('serve-static'); const { PORT = 4002 } = process.env; -// this allows us to do e.g. `fetch('/api/blog')` on the server +// this allows us to do e.g. `fetch('/_api/blog')` on the server const fetch = require('node-fetch'); global.fetch = (url, opts) => { if (url[0] === '/') url = `http://localhost:${PORT}${url}`;