Adding API Endpoint for featured clients
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Fabian Stamm 2020-12-20 00:02:36 +01:00
parent 779e7e1478
commit bb01f7d62d
2 changed files with 30 additions and 0 deletions

View File

@ -81,4 +81,30 @@ ClientRouter.get(
})
);
/**
* @api {get} /client/featured
*
* @apiDescription Get a list of clients, that want to be featured on the home page
*
* @apiName GetFeaturedClients
* @apiGroup client
*/
ClientRouter.get(
"/featured",
Stacker(async (req: Request, res) => {
let clients = await Client.find({
featured: true,
});
res.json({
clients: clients.map(({ name, logo, website, description }) => ({
name,
logo,
website,
description,
})),
});
})
);
export default ClientRouter;

View File

@ -12,6 +12,8 @@ export interface IClient extends ModelDataBase {
logo?: string;
client_id: string;
client_secret: string;
featured?: boolean;
description?: string;
}
const Client = DB.addModel<IClient>({
@ -28,6 +30,8 @@ const Client = DB.addModel<IClient>({
logo: { type: String, optional: true },
client_id: { type: String, default: () => v4() },
client_secret: { type: String },
featured: { type: Boolean, optional: true },
description: { type: String, optional: true },
},
},
],