import { Router } from "express";
import GetAuthRoute from "./auth.js";
import JWTRoute from "./jwt.js";
import Public from "./public.js";
import RefreshTokenRoute from "./refresh.js";
import ProfileRoute from "./profile.js";

const OAuthRoute: Router = Router();
/**
 * @api {post} /oauth/auth
 * @apiName OAuthAuth
 *
 * @apiGroup oauth
 * @apiPermission user Special required
 *
 * @apiParam {String} response_type must be "code" others are not supported
 * @apiParam {String} client_id ClientID
 * @apiParam {String} redirect_uri The URI to redirect with code
 * @apiParam {String} scope Scope that contains the requested permissions (comma seperated list of permissions)
 * @apiParam {String} state State, that will be passed to redirect_uri for client
 * @apiParam {String} nored Deactivates the Redirect response from server and instead returns the redirect URI in JSON response
 */
OAuthRoute.post("/auth", GetAuthRoute(false));

/**
 * @api {get} /oauth/jwt
 * @apiName OAuthJwt
 *
 * @apiGroup oauth
 * @apiPermission none
 *
 * @apiParam {String} refreshtoken
 *
 * @apiSuccess {String} token The JWT that allowes the application to access the recources granted for refresh token
 */
OAuthRoute.get("/jwt", JWTRoute);

/**
 * @api {get} /oauth/public
 * @apiName OAuthPublic
 *
 * @apiGroup oauth
 * @apiPermission none
 *
 * @apiSuccess {String} public_key The applications public_key. Used to verify JWT.
 */
OAuthRoute.get("/public", Public);

/**
 * @api {get} /oauth/refresh
 * @apiName OAuthRefreshGet
 *
 * @apiGroup oauth
 */
OAuthRoute.get("/refresh", RefreshTokenRoute);

/**
 * @api {post} /oauth/refresh
 * @apiName OAuthRefreshPost
 *
 * @apiGroup oauth
 */
OAuthRoute.post("/refresh", RefreshTokenRoute);

/**
 * @api {get} /oauth/profile
 * @apiName OAuthProfile
 * 
 * @apiGroup oauth
 */
OAuthRoute.get("/profile", ProfileRoute);

export default OAuthRoute;
