Refactoring, Clean up and bug fixes
This commit is contained in:
@ -1,19 +1,25 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import App, { pack, IApp } from '../../../../models/app';
|
||||
import { ILocalUser } from '../../../../models/user';
|
||||
import getParams from '../../get-params';
|
||||
|
||||
export const meta = {
|
||||
params: {
|
||||
appId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Show an app
|
||||
*/
|
||||
export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
const isSecure = user != null && app == null;
|
||||
|
||||
// Get 'appId' parameter
|
||||
const [appId, appIdErr] = $.type(ID).get(params.appId);
|
||||
if (appIdErr) return rej('invalid appId param');
|
||||
|
||||
// Lookup app
|
||||
const ap = await App.findOne({ _id: appId });
|
||||
const ap = await App.findOne({ _id: ps.appId });
|
||||
|
||||
if (ap === null) {
|
||||
return rej('app not found');
|
||||
|
Reference in New Issue
Block a user