mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 17:33:09 +02:00
parent
d44fbf58c9
commit
83ec906ee7
2 changed files with 19 additions and 11 deletions
|
@ -41,7 +41,9 @@ const upload = multer({
|
||||||
});
|
});
|
||||||
|
|
||||||
// Init router
|
// Init router
|
||||||
const router = new Router();
|
const router = new Router({
|
||||||
|
prefix: '/api'
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register endpoint handlers
|
* Register endpoint handlers
|
||||||
|
@ -73,7 +75,18 @@ router.get('/v1/instance/peers', async ctx => {
|
||||||
ctx.body = instances.map(instance => instance.host);
|
ctx.body = instances.map(instance => instance.host);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/miauth/:session/check', async ctx => {
|
// Return 404 for unknown API
|
||||||
|
router.all('*', async ctx => {
|
||||||
|
ctx.status = 404;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Register router
|
||||||
|
app.use(router.routes());
|
||||||
|
|
||||||
|
//#region miauth
|
||||||
|
const miauthRouter = new Router();
|
||||||
|
|
||||||
|
miauthRouter.post('/miauth/:session/check', async ctx => {
|
||||||
const token = await AccessTokens.findOne({
|
const token = await AccessTokens.findOne({
|
||||||
session: ctx.params.session
|
session: ctx.params.session
|
||||||
});
|
});
|
||||||
|
@ -95,12 +108,7 @@ router.post('/miauth/:session/check', async ctx => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Return 404 for unknown API
|
app.use(miauthRouter.routes());
|
||||||
router.all('*', async ctx => {
|
//#endregion
|
||||||
ctx.status = 404;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Register router
|
|
||||||
app.use(router.routes());
|
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|
|
@ -17,7 +17,7 @@ import activityPub from './activitypub';
|
||||||
import nodeinfo from './nodeinfo';
|
import nodeinfo from './nodeinfo';
|
||||||
import wellKnown from './well-known';
|
import wellKnown from './well-known';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
import apiServer from './api';
|
import api from './api';
|
||||||
import { sum } from '../prelude/array';
|
import { sum } from '../prelude/array';
|
||||||
import Logger from '../services/logger';
|
import Logger from '../services/logger';
|
||||||
import { program } from '../argv';
|
import { program } from '../argv';
|
||||||
|
@ -55,7 +55,7 @@ if (config.url.startsWith('https') && !config.disableHsts) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use(mount('/api', apiServer));
|
app.use(mount(api));
|
||||||
app.use(mount('/files', require('./file')));
|
app.use(mount('/files', require('./file')));
|
||||||
app.use(mount('/proxy', require('./proxy')));
|
app.use(mount('/proxy', require('./proxy')));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue