summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/api/endpoints/app')
-rw-r--r--src/server/api/endpoints/app/create.ts59
-rw-r--r--src/server/api/endpoints/app/name_id/available.ts31
-rw-r--r--src/server/api/endpoints/app/show.ts38
3 files changed, 10 insertions, 118 deletions
diff --git a/src/server/api/endpoints/app/create.ts b/src/server/api/endpoints/app/create.ts
index c7bc91a079..5df8bd2f25 100644
--- a/src/server/api/endpoints/app/create.ts
+++ b/src/server/api/endpoints/app/create.ts
@@ -3,63 +3,14 @@ import $ from 'cafy';
import App, { isValidNameId, pack } from '../../../../models/app';
import { ILocalUser } from '../../../../models/user';
-/**
- * @swagger
- * /app/create:
- * note:
- * summary: Create an application
- * parameters:
- * - $ref: "#/parameters/AccessToken"
- * -
- * name: nameId
- * description: Application unique name
- * in: formData
- * required: true
- * type: string
- * -
- * name: name
- * description: Application name
- * in: formData
- * required: true
- * type: string
- * -
- * name: description
- * description: Application description
- * in: formData
- * required: true
- * type: string
- * -
- * name: permission
- * description: Permissions that application has
- * in: formData
- * required: true
- * type: array
- * items:
- * type: string
- * collectionFormat: csv
- * -
- * name: callbackUrl
- * description: URL called back after authentication
- * in: formData
- * required: false
- * type: string
- *
- * responses:
- * 200:
- * description: Created application's information
- * schema:
- * $ref: "#/definitions/Application"
- *
- * default:
- * description: Failed
- * schema:
- * $ref: "#/definitions/Error"
- */
+export const meta = {
+ requireCredential: true
+};
/**
* Create an app
*/
-module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
+export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'nameId' parameter
const [nameId, nameIdErr] = $.str.pipe(isValidNameId).get(params.nameId);
if (nameIdErr) return rej('invalid nameId param');
@@ -78,7 +29,7 @@ module.exports = async (params: any, user: ILocalUser) => new Promise(async (res
// Get 'callbackUrl' parameter
// TODO: Check it is valid url
- const [callbackUrl = null, callbackUrlErr] = $.str.optional().nullable().get(params.callbackUrl);
+ const [callbackUrl = null, callbackUrlErr] = $.str.optional.nullable.get(params.callbackUrl);
if (callbackUrlErr) return rej('invalid callbackUrl param');
// Generate secret
diff --git a/src/server/api/endpoints/app/name_id/available.ts b/src/server/api/endpoints/app/name_id/available.ts
index 58101a7e6a..2cd56e92d6 100644
--- a/src/server/api/endpoints/app/name_id/available.ts
+++ b/src/server/api/endpoints/app/name_id/available.ts
@@ -6,41 +6,12 @@ import App from '../../../../../models/app';
import { isValidNameId } from '../../../../../models/app';
/**
- * @swagger
- * /app/nameId/available:
- * note:
- * summary: Check available nameId on creation an application
- * parameters:
- * -
- * name: nameId
- * description: Application unique name
- * in: formData
- * required: true
- * type: string
- *
- * responses:
- * 200:
- * description: Success
- * schema:
- * type: object
- * properties:
- * available:
- * description: Whether nameId is available
- * type: boolean
- *
- * default:
- * description: Failed
- * schema:
- * $ref: "#/definitions/Error"
- */
-
-/**
* Check available nameId of app
*
* @param {any} params
* @return {Promise<any>}
*/
-module.exports = async (params: any) => new Promise(async (res, rej) => {
+export default async (params: any) => new Promise(async (res, rej) => {
// Get 'nameId' parameter
const [nameId, nameIdErr] = $.str.pipe(isValidNameId).get(params.nameId);
if (nameIdErr) return rej('invalid nameId param');
diff --git a/src/server/api/endpoints/app/show.ts b/src/server/api/endpoints/app/show.ts
index 2b98a3f142..6668d0f243 100644
--- a/src/server/api/endpoints/app/show.ts
+++ b/src/server/api/endpoints/app/show.ts
@@ -1,49 +1,19 @@
-import $ from 'cafy'; import ID from '../../../../cafy-id';
+import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import App, { pack, IApp } from '../../../../models/app';
import { ILocalUser } from '../../../../models/user';
/**
- * @swagger
- * /app/show:
- * note:
- * summary: Show an application's information
- * description: Require appId or nameId
- * parameters:
- * -
- * name: appId
- * description: Application ID
- * in: formData
- * type: string
- * -
- * name: nameId
- * description: Application unique name
- * in: formData
- * type: string
- *
- * responses:
- * 200:
- * description: Success
- * schema:
- * $ref: "#/definitions/Application"
- *
- * default:
- * description: Failed
- * schema:
- * $ref: "#/definitions/Error"
- */
-
-/**
* Show an app
*/
-module.exports = (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
+export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
const isSecure = user != null && app == null;
// Get 'appId' parameter
- const [appId, appIdErr] = $.type(ID).optional().get(params.appId);
+ const [appId, appIdErr] = $.type(ID).optional.get(params.appId);
if (appIdErr) return rej('invalid appId param');
// Get 'nameId' parameter
- const [nameId, nameIdErr] = $.str.optional().get(params.nameId);
+ const [nameId, nameIdErr] = $.str.optional.get(params.nameId);
if (nameIdErr) return rej('invalid nameId param');
if (appId === undefined && nameId === undefined) {