Skip to main content
Glama
oAuth2.schema.ts1.24 kB
import { Schema } from 'mongoose'; import type { Client, Token as TokenType } from 'oauth2-server'; import type { User } from '@/types/user.types'; export type Token = Omit<TokenType, 'client' | 'user'> & { clientId: Client['id']; userId: User['id']; }; export const accessTokenSchema = new Schema<Token>( { accessToken: { type: String, required: true, }, accessTokenExpiresAt: { type: Date, }, clientId: { type: String, ref: 'Project', required: true, }, userId: { type: Schema.Types.ObjectId, ref: 'User', required: true, }, }, { timestamps: true, toJSON: { virtuals: true, // keep the automatic `id` getter versionKey: false, // drop __v transform(_doc, ret: any) { const { _id, ...rest } = ret; return { ...rest, id: _id.toString(), }; }, }, toObject: { virtuals: true, transform(_doc, ret: any) { const { _id, ...rest } = ret; return { ...rest, id: _id, }; }, }, } ); accessTokenSchema.index( { createdAt: 1 }, { expireAfterSeconds: 60 * 60 * 24 * 10, // 10 Days } );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server