decadent
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i decadent

Weekly Downloads

1

Version

1.1.5

License

ISC

Unpacked Size

21.6 kB

Total Files

16

Last publish

Collaborators

  • magicfun1241