Decadent
Simple framework for REST API development
Futures
- Customizable logger
- Swagger documentation generation
- Multipart body
- Rate limiting
- Send responses using precompiled schemas
Example
import {FastifyReply, FastifyRequest} from "fastify";
import {
Factory,
Controller,
Post
} from "decadent";
@Controller({
route: "/users"
})
class Users {
@Post('/hello', {
secure: true,
schema: {
body: {
name: { type: 'string' }
}
}
})
say(request: FastifyRequest<{
Body: {
name: string;
}
}>, reply: FastifyReply) {
reply.send({ hello: request.body.name });
}
}
const app = Factory.create({
controllers: [Users]
});
// Fastify authorization middleware
app.secureHandler = (request, reply, done) => done();
// Swagger secure route annotation
app.secureBuilder = () => ([
{
bearerAuth: []
}
]);
app.listen({ port: 3000 });
License
ISC