apika
v0.0.10
Published
> **Just.. don't**
Downloads
42
Readme
Apika
Just.. don't
Backend
Setup with Fastify.
import {ApikaServ} from 'apika/serv';
export const apiControllers = {
client_product_loadAll: loadAllController,
...
} as const;
export type ApiControllers = typeof apiControllers;
export const apikaServ = new ApikaServ(apiControllers);
Core.app.post('/api/:controller', async _req => {
return await apikaServ.handle({
controller: (_req.params as any).controller,
body: _req.body,
ctx: {
headers: _req.headers,
},
});
});
Frontend
It is important to import exactly types, not the whole backend code: import type ...
.
import type {ApiControllers} from '@@api';
import {Injectable} from '@angular/core';
import {Apika} from 'apika';
@Injectable({
providedIn: 'root',
})
export class Api extends Apika<ApiControllers> {
url = '/api/';
}
Apika uses HttpClient
, you have to setup it properly:
TODO
Req
Render template if status is Succeed
:
<div *req="loadAllReq.status">
...
</div>
You can provide custom views for Ongoing
and Failed
statuses:
{
provide: ApikaReqOngoing,
useValue: LoadingSpinnerComponent,
},
{
provide: ApikaReqFailed,
useValue: LoadingErrorComponent,
}
TODO
- prettier
- README
- ReqOutlet demo
- tsconfig paths demo
- Controller demo
- Auth demo
- zod demo
- Prisma demo
- err
- tests