Adding API Endpoint for featured clients
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
779e7e1478
commit
bb01f7d62d
@ -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;
|
export default ClientRouter;
|
||||||
|
@ -12,6 +12,8 @@ export interface IClient extends ModelDataBase {
|
|||||||
logo?: string;
|
logo?: string;
|
||||||
client_id: string;
|
client_id: string;
|
||||||
client_secret: string;
|
client_secret: string;
|
||||||
|
featured?: boolean;
|
||||||
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Client = DB.addModel<IClient>({
|
const Client = DB.addModel<IClient>({
|
||||||
@ -28,6 +30,8 @@ const Client = DB.addModel<IClient>({
|
|||||||
logo: { type: String, optional: true },
|
logo: { type: String, optional: true },
|
||||||
client_id: { type: String, default: () => v4() },
|
client_id: { type: String, default: () => v4() },
|
||||||
client_secret: { type: String },
|
client_secret: { type: String },
|
||||||
|
featured: { type: Boolean, optional: true },
|
||||||
|
description: { type: String, optional: true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user