0.1.7 • Published 2 years ago
generator-fastify-ts v0.1.7
generator-fastify-ts 
Fastify + Typescript boilerplate
Plugins included
- You can choose either "mongoose" or "prisma" for database.
- @fastify/cors
- @fastify/sensible - easier working with response.
- @fastify/swagger and @fastify/swagger-ui - serving Swagger (OpenAPI v2) or OpenAPI v3 schemas, which are automatically generated from your route schemas, or from an existing Swagger/OpenAPI schema.
- @fastify/jwt
- fastify-multer - handle file upload.
- @fastify/redis - Connect and work with ioredis
- @fastify/cookie - adds support for reading and setting cookies.
- fastify-bcrypt - A Bcrypt hash generator & checker
- nodemailer - send email with nodemailer and ejs template engine.
- s3 - upload file to
aws s3(ordigitalocean space).
How to use plugins
All plugins are registered in file src/app.ts. THE REGISTER ORDER are important, because one plugin can depends on another.
After registration, plugin can be accessed through app - which is instance of FastifyInstance.
Example:
// Example using it inside a route
app.get('/api', async (request, reply) => {
const msgFromRedis = await app.redis.get('message');
return reply.send({
message: msgFromRedis,
});
});Installation
First, install Yeoman and generator-fastify-ts using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-fastify-tsThen generate your new project:
yo fastify-tsChangelog
v0.1.7
- Add plugin
bcrypt - Update types for plugins
v0.1.6
- Update types for plugin
s3
v0.1.5
- Replace
@fastify/multipartwithfastify-multer - Fix bug with s3 plugin
v0.1.4
- Fix bug with email plugin
v0.1.3
- Fix bug missing
.gitignorefile
License
MIT © luuhai48