
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
If you always have to setup boilerplate code anytime you create a new file, and you need a way to do it faster, then this package is for you.
If you always have to setup boilerplate code anytime you create a new file, and you need a way to do it faster, then this package is for you.
Flease is a command line tool that helps you generate files, and adds your preferred configuration. Think Laravel artisan
in the php world; Except that this is configurable from a single .json
file.
By default, it is designed to generate express files like models
and controllers
and also imports mongoose. However, it is not limited to Node js.
Run npm i -g flease
to install globally.
To run any command, simply run flease [cmd]
. Run flease --help
to list all available commands
For most of my nodejs projects, I generally use mongodb as the data store, and mongoose as the ODM. This means for every model I create, I'd have to import mongoose, setup the schema, export the schema e.t.c. This can become too repetitive.
With flease, run flease make:model User
. You should have a models/User.js
file in your project with the following content;
const mongoose = require('mongoose');
mongoose.Promise = global.Promise;
const userSchema = new mongoose.Schema({
created: {
type: Date,
default: Date.now
},
});
module.exports = mongoose.model('User', userSchema);
You can also create a controller and associate it with a model instantly. Run flease make:controller UsersController --model User
or flease mc UsersController --model User
. You should now have a controllers/UsersController.js
file in your project with the following content;
const mongoose = require('mongoose');
const User = mongoose.model('User');
//
All generated codes are obtained from a single json file. You should publish it so that you can edit accordingly. Run flease publish
. You should get a flease.json
file that looks like this;
{
"models": [
"const mongoose = require('mongoose');\n",
"mongoose.Promise = global.Promise;\n\n",
"const #{name}Schema = new mongoose.Schema({\n",
"\tcreated: {\n",
"\t\ttype: Date,\n",
"\t\tdefault: Date.now\n",
"\t},\n",
"});\n\n",
"module.exports = mongoose.model('#{model}', #{name}Schema);"
],
"controllers": [
"const mongoose = require('mongoose');\n",
"const #{model} = mongoose.model('#{model}');\n\n",
"//"
]
}
You can edit or add new lines in each section. As long as it is a valid json string, it will work fine.
This project uses Jest for automated testing. Run npm test
Some upcoming features include;
Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.
Dont forget to leave a :star: on this repo :wink:
The MIT License (MIT). Please see License File for more information.
FAQs
If you always have to setup boilerplate code anytime you create a new file, and you need a way to do it faster, then this package is for you.
The npm package flease receives a total of 1 weekly downloads. As such, flease popularity was classified as not popular.
We found that flease demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.