mirror of
https://github.com/He4eT/simple-spaceapi.git
synced 2026-05-04 17:37:24 +00:00
SpaceAPI: custom endpoint
This commit is contained in:
parent
5e788e7a5a
commit
d7a40831d0
2 changed files with 25 additions and 0 deletions
13
src/api/spaceapi/controllers/spaceapi.ts
Normal file
13
src/api/spaceapi/controllers/spaceapi.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import type { Core } from '@strapi/strapi';
|
||||
import type { Context } from 'koa';
|
||||
|
||||
export default ({ strapi }: { strapi: Core.Strapi }) => ({
|
||||
async index(ctx: Context) {
|
||||
const hackspace = await strapi.documents('api::hackspace.hackspace')
|
||||
.findFirst({
|
||||
populate: "*",
|
||||
});
|
||||
|
||||
return ctx.send(hackspace);
|
||||
},
|
||||
});
|
||||
12
src/api/spaceapi/routes/spaceapi.ts
Normal file
12
src/api/spaceapi/routes/spaceapi.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
export default {
|
||||
routes: [
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/spaceapi',
|
||||
handler: 'spaceapi.index',
|
||||
config: {
|
||||
auth: false,
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue