Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: method for Projects class to update JWT expiration #8

Closed
wants to merge 10 commits into from
Next Next commit
jwt expiration update method for projects class created
  • Loading branch information
BadgerBloke committed Sep 12, 2023
commit 33e64a25e39c55df1e60c95dbb113b380dbac934
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Models } from './models';
import { Service } from './service';

type Payload = {
[key: string]: any;
[key: string]: unknown;
}

type Headers = {
Expand Down
37 changes: 34 additions & 3 deletions src/services/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import type { UploadProgress, Payload } from '../client';

export class Projects extends Service {

constructor(client: Client)
{
constructor(client: Client)
{
super(client);
}
}

/**
* List Projects
Expand Down Expand Up @@ -282,6 +282,37 @@ export class Projects extends Service {
}, payload);
}

/**
* Update Project JWT Expiration Duration
*
*
* @param {string} projectId
* @param {number} jwtExpiration
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateJwtExpiration(projectId: string, jwtExpiration: number): Promise<Models.Project> {
if (typeof projectId === 'undefined') {
throw new AppwriteException('Missing required parameter: "projectId"');
}

if (typeof jwtExpiration === 'undefined') {
throw new AppwriteException('Missing required parameter: "jwtExpiration"');
}

const path = `/projects/${projectId}/auth/jwt-expiration`;
const payload: Payload = {};

if (typeof jwtExpiration !== 'undefined') {
payload['jwtExpiration'] = jwtExpiration;
}

const uri = new URL(this.client.config.endpoint + path);
return await this.client.call('patch', uri, {
'content-type': 'application/json',
}, payload);
}

/**
* Update Project users limit
*
Expand Down