mirror of
https://github.com/PretendoNetwork/miiverse-api.git
synced 2026-08-25 01:54:11 -05:00
split api and discovery services
This commit is contained in:
@@ -8,7 +8,8 @@ import { LOG_INFO, LOG_SUCCESS } from '@/logger';
|
||||
import xmlparser from '@/middleware/xml-parser';
|
||||
import auth from '@/middleware/auth';
|
||||
|
||||
import miiverse from '@/services/miiverse-api';
|
||||
import discovery from '@/services/discovery';
|
||||
import api from '@/services/api';
|
||||
|
||||
import { config } from '@/config-manager';
|
||||
|
||||
@@ -32,7 +33,8 @@ app.use(xmlparser);
|
||||
app.use(auth);
|
||||
|
||||
// import the servers into one
|
||||
app.use(miiverse);
|
||||
app.use(discovery);
|
||||
app.use(api);
|
||||
|
||||
// 404 handler
|
||||
LOG_INFO('Creating 404 status handler');
|
||||
|
||||
35
src/services/api/index.ts
Normal file
35
src/services/api/index.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import express from 'express';
|
||||
import subdomain from 'express-subdomain';
|
||||
import { LOG_INFO } from '@/logger';
|
||||
|
||||
import postsHandlers from '@/services/api/routes/posts';
|
||||
import friendMessagesHandlers from '@/services/api/routes/friend_messages';
|
||||
import communitiesHandlers from '@/services/api/routes/communities';
|
||||
import peopleHandlers from '@/services/api/routes/people';
|
||||
import topicsHandlers from '@/services/api/routes/topics';
|
||||
import usersHandlers from '@/services/api/routes/users';
|
||||
import statusHandlers from '@/services/api/routes/status';
|
||||
|
||||
// Main router for endpointsindex.js
|
||||
const router = express.Router();
|
||||
|
||||
// Router to handle the subdomain restriction
|
||||
const api = express.Router();
|
||||
|
||||
// Create subdomains
|
||||
LOG_INFO('[MIIVERSE] Creating \'api\' subdomain');
|
||||
router.use(subdomain('api.olv', api));
|
||||
router.use(subdomain('api-test.olv', api));
|
||||
router.use(subdomain('api-dev.olv', api));
|
||||
|
||||
// Setup routes
|
||||
api.use('/v1/posts', postsHandlers);
|
||||
api.use('/v1/posts.search', postsHandlers);
|
||||
api.use('/v1/friend_messages', friendMessagesHandlers);
|
||||
api.use('/v1/communities/', communitiesHandlers);
|
||||
api.use('/v1/people/', peopleHandlers);
|
||||
api.use('/v1/topics/', topicsHandlers);
|
||||
api.use('/v1/users/', usersHandlers);
|
||||
api.use('/v1/status/', statusHandlers);
|
||||
|
||||
export default router;
|
||||
20
src/services/discovery/index.ts
Normal file
20
src/services/discovery/index.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import express from 'express';
|
||||
import subdomain from 'express-subdomain';
|
||||
import { LOG_INFO } from '@/logger';
|
||||
|
||||
import discoveryHandlers from '@/services/discovery/routes/discovery';
|
||||
|
||||
// Main router for endpointsindex.js
|
||||
const router = express.Router();
|
||||
|
||||
// Router to handle the subdomain restriction
|
||||
const discovery = express.Router();
|
||||
|
||||
// Create subdomains
|
||||
LOG_INFO('[MIIVERSE] Creating \'discovery\' subdomain');
|
||||
router.use(subdomain('discovery.olv', discovery));
|
||||
|
||||
// Setup routes
|
||||
discovery.use('/v1/endpoint', discoveryHandlers);
|
||||
|
||||
export default router;
|
||||
@@ -1,40 +0,0 @@
|
||||
import express from 'express';
|
||||
import subdomain from 'express-subdomain';
|
||||
import { LOG_INFO } from '@/logger';
|
||||
|
||||
import DISCOVERY from '@/services/miiverse-api/routes/discovery';
|
||||
import POST from '@/services/miiverse-api/routes/post';
|
||||
import MESSAGE from '@/services/miiverse-api/routes/message';
|
||||
import COMMUNITY from '@/services/miiverse-api/routes/communities';
|
||||
import PEOPLE from '@/services/miiverse-api/routes/people';
|
||||
import TOPICS from '@/services/miiverse-api/routes/topics';
|
||||
import USERS from '@/services/miiverse-api/routes/users';
|
||||
import PING from '@/services/miiverse-api/routes/ping';
|
||||
|
||||
// Main router for endpointsindex.js
|
||||
const router = express.Router();
|
||||
|
||||
// Router to handle the subdomain restriction
|
||||
const discovery = express.Router();
|
||||
const api = express.Router();
|
||||
|
||||
// Create subdomains
|
||||
LOG_INFO('[MIIVERSE] Creating \'discovery\' subdomain');
|
||||
router.use(subdomain('discovery.olv', discovery));
|
||||
LOG_INFO('[MIIVERSE] Creating \'api\' subdomain');
|
||||
router.use(subdomain('api.olv', api));
|
||||
router.use(subdomain('api-test.olv', api));
|
||||
router.use(subdomain('api-dev.olv', api));
|
||||
|
||||
// Setup routes
|
||||
discovery.use('/v1/endpoint', DISCOVERY);
|
||||
api.use('/v1/posts', POST);
|
||||
api.use('/v1/posts.search', POST);
|
||||
api.use('/v1/friend_messages', MESSAGE);
|
||||
api.use('/v1/communities/', COMMUNITY);
|
||||
api.use('/v1/people/', PEOPLE);
|
||||
api.use('/v1/topics/', TOPICS);
|
||||
api.use('/v1/users/', USERS);
|
||||
api.use('/v1/status/', PING);
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user